pahanix & IT

yet another passionate programmer

Notes &

@augustl: Good arguments against Ruby 1.9 encoding

For me, I absolutely hate all this encoding stuff in ruby 1.9, and I’ll try to explain why here.

In ruby 1.8, if I write an expression like “s3 = s1 + s2”, where s1 and s2 are strings, this is easy because it’s a one-dimensional space. As long as s1 and s2 are strings, then I know that s3 will be a string, consisting of the bytes from s1 followed by the bytes from s2. End of story, move to the next line.

But in ruby 1.9, it becomes a multi-dimensional problem. The number possibilities now explodes. What are the possible encodings that s1 might have at this point in the program? What are the possible encodings that s2 might have at this point? Are they compatible, or will an exception be raised? What encoding will s3 have going forward in the next line of the program?

It’s ridiculously complicated. string19.rb contains around 200 examples of behaviour, and could form the basis of a small book. It’s a +String+ for crying out loud! What other language requires you to understand this level of complexity just to work with strings?!…

Filed under ruby ruby19 ruby 1.9 strings