From: Marnen Laibow-Koser Date: 2009-12-06T10:57:59+09:00 Subject: Re: Why doesn't Ruby "compile" strings? Iñaki Baz Castillo wrote: [...]> This clearly shows that using a constant string is faster than using a > string > writen into the script. So I wonder: why doesn't Ruby "precompile" > internally > the strings appearing in the script? Well, it would make garbage collection difficult. > > This is, when Ruby interpreter is parsing the script and founds > "hello_world", > couldn't it create the string *just once* and keep in memory forever so > next > time same string is accessed Ruby doesn't need to initiate it? > Is it imposible due to the design of Ruby? It's not impossible at all: just use symbols instead of strings. > > PS: I don't know if other languages (Python, PHP, Perlo...) do it or > not. I don't think PHP interns strings. Best, --  Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.