My previous article, “We don’t need a string type“, caused a bit of stir. Though the feedback is mixed, there is a common theme of a

The string type is broken – Musing Mortoray

submited by
Style Pass
2021-06-23 01:00:06

My previous article, “We don’t need a string type“, caused a bit of stir. Though the feedback is mixed, there is a common theme of a string being a useful feature. After doing a bit more research I can determine only one thing: most current string types are broken!

Many of us believe our strings are capable of more than what they actually do. We rely on their functionality without actually checking that its valid. This can easily lead to programs which do not work correctly, particularly with respect to internationalization. In most cases it seems we would be better off without a string type.

I looked at how strings behave in a few basic situations. I’ll go over each situation, giving the expected result and some of the actual results. I considered showing a matrix with the results, but since all the tested languages behave so poorly it didn’t seem useful.

1. Does it print correctly? Yes, most languages are capable of doing this. Though the ideone.com interface seems to break the output (so be careful with testing).

Leave a Comment