rosenfeld (Rodrigo Rosenfeld Rosas) wrote:
>
> Have no idea! My suspect is that someone thought: "hey maybe it would
> be a great idea if we could optimize some constant strings - we could
> create a symbol for that - hey, look at my micro-benchmarks, it really
> is a great idea!".

Ruby's symbols hail directly from Smalltalk (early 1970's) and are analogous
to Lisp atoms (early 1960's.)


I think the challenge in Ruby is there are multiple competing reasons symbols
are used, from a developer perspective:

 - performance (A symbol exists once in memory and can be compared quickly)

 - immutability (Symbols implicitly behave as though 'frozen')

 - appealing syntax (If symbols were uglier to create than strings, instead
                     of being totally sexy, we likely wouldn't be having this
                     discussion.)


Presumably many Rubyists gravitate toward the appealing syntax, without
being aware of Symbol's other properties -- and, well, the accompanying half-
century of computing history?


Personally I'd love for symbols to be able to be garbage collected, though I
understand the technical challenges.  I'd be happy if a symbol-string
"indifferent" Hash alternative were available in core (is there a better name
than the Rails thing?)  If we were starting over at Ruby 1.0, I probably would
be fine with the :symbol syntax just being an alternative way to create
regular strings.  Today, though, symbols are part of the language, and they're
distinct from strings.  I'm OK with that.


Regards,

Bill