Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

💀 Symbols

💀 Symbols

⚡️ Talk based on a Hacker News comment (https://news.ycombinator.com/item?id=9197412). Presented at RubyConf India and the Ruby User Group Berlin.

Erik Berlin

April 07, 2015
Tweet

More Decks by Erik Berlin

Other Decks in Programming

Transcript

  1. Symbols are Useless 1. Calling Symbol#to_s on every symbol in

    your program would not change its semantics. 2. Symbols are an archaic optimization. They were useful 20 years ago, but not today. 3. Symbols and strings have converged into one type.
  2. N = 1_000_000 measure { N.times { "string" } }

    measure { N.times { "string".freeze } } measure { N.times { :symbol } } Benchmark
  3. 1. Symbols and frozen strings perform identically. 2. Allocating a

    million strings takes about twice as long as allocating one string, putting it in into a hash table, and looking it up a million times. 3. You can allocate a million short strings in about a tenth of a second on a typical 2015 laptop computer. Takeaways