From: Robert Klemme Date: 2012-02-10T19:07:19+09:00 Subject: Re: Symbol garbage collection On Fri, Feb 10, 2012 at 8:28 AM, Dido Sevilla wrote: > I've always wondered why Ruby didn't do garbage collection of symbols, > when Lisp implementations here and there did so, and in fact they are > essential in macro programming because Lisp programs tend to create a > lot of unique symbols at runtime, especially in macro code, with such > contrivances as gensym in Scheme and Common Lisp and uniq in Arc. In Ruby the idea is rather to only use a fixed amount of Symbols in the program and use Strings for everything that changes often. > Once > upon a time I studied how Ruby implemented symbols and while this > representation made symbol garbage collection difficult, it did not by > any means make it impossible. In addition to my work on Ruby I am also > writing an interpreter for Arc in C, and I made it use just about the > same representation as Ruby 1.8 did for symbols. I also devised an > algorithm to do symbol garbage collection with that same > representation. > > http://arcueid-arc.org/2012/02/10/symbols-and-symbol-garbage-collection-arcueid-vs-ruby/ > > I see no reason why the same approach will not work with Ruby as well. Using Symbol in Ruby the way mentioned above avoids allocation and GC overhead giving an overall more efficient program. Ruby and Lisp are sufficiently different languages that I would not automatically subscribe to the idea that what works good in one language would also work good in the other - or is desirable to have at all. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/