Why does Ruby expose symbols?

ruby, symbols

Solution

Part of the issue is that Ruby strings are mutable. Since every string Ruby allocates must be independent (it can't cache short/common ones), it's convenient to have a `Symbol` type to let the programmer have what are essentially immutable, memory-efficient strings.

Also, they share many characteristics with `enum`'s, but with less pain for the programmer.

Problem

Why does Ruby expose symbols for explicit use? Isn't that the sort of optimisation that's usually handled by the interpreter/compiler?

Original source