Today I Learned

Blog to learn English

Friday, 5th Oct. 2018 - Write a Ruby interpreter in Ruby

Today, there was an event in my company. It is based on a book which is named "RubyでつくるRuby". We wrote a subset of Ruby interpreter in Ruby in this event. The subset is called "MinRuby".

I implemented a MinRuby interpreter, and the interpreter can execute by itself (self-hosting). Implementing self-hosting is difficult because MinRuby only has a few features. For example, MinRuby does not have method call1, so we cannot use Array#each, Array#size and so on.

After implementing self-hosting, I tried making it faster. I optimized it by about 3~4 times.

You can find my work here.


BTW, I ate cherry burger at Burger Mania for lunch. It was very delicious. Sometimes I order it with Uber Eats. I recommend it.

f:id:Pocke:20181005124042j:plain


  1. We can use function call in MinRuby, in other words, we can use method call only without receiver.