From: Gavin Sinclair Date: 2004-10-12T22:23:12+09:00 Subject: Re: Ruby Directions (was Re: quality of error messages) On Tuesday, October 12, 2004, 5:09:37 PM, Robert wrote: >> Some things are best treated "just like a number". Ranges are one of >> them (they're just two numbers and a flag, after all). Some say >> strings should be immutable as well, and I think it's a justifiable >> position. > Personally I prefer the approach Matz has taken with Ruby strings because > of my experience with Java strings. It can be a major performance > drawback if you have to create a new string for every change that you do > to a string (yes, I know there is StringBuffer, but too many methods just > return a String); and in some cases your memory might not even suffice. I'm not weighing in here, but I think the purpose of Java's immutable strings was to somehow improve performance. The gutlessness of Java's string library compared with Ruby's is bound to change the equation, though. Perhaps there are some uses of strings for which immutability makes performance sense, and some uses for which it doesn't. I couldn't be bothered thinking about it :) Considering the occasional usage of value objects, I can see why immutable strings would be conceptually nice (sometimes). I also think tuples (essentially arrays that are fixed on creation) would be nice to have in the language, for the same reason. Neither is a big deal, though. Cheers, Gavin