Announcements made at the conference:
– types are worked on in a collaboration with the Ruby core team;
– types will be part of Ruby 3 stdlib source!
– https://t.co/zCFtnzZEQt – website is out!
– try IDE-like experience at https://t.co/uF06whah7N https://t.co/ojUaj5kzo7
— Dmitry Petrashko (@darkdimius) April 19, 2019
Though Yukihiro Matsumoto, or “Matz,” has long been opposed to introducing types to Ruby, Ruby 3 will introduce types. The announcement was made in the Ruby Kaigi 2019 Press Conference. There, Stripe engineers Paul Tarjan and Jake Zimmerman demonstrated a type checker they created for Ruby. The type checker is called Sorbet and Stripe was able to successfully adopt it into their existing code base constituting millions of lines of code. What solidifies the announcement of types systems is the fact that Sorbet will be supported by Ruby from the ground up; Ruby 3 will standardize types in its stdlib source.
— Sam “I have some almighty take” Phippen (@samphippen) April 18, 2019
Here’s example code that you can find on Sorbe.run
The project to typify Ruby has been years in the making. In 2015, Matz first announced Ruby 3×3, the goal being to make Ruby 3 become 3 times faster than Ruby 2. In an interview a year later, Matz said:
In the design of the Ruby language we have been primarily focused on productivity and the joy of programming. As a result, Ruby was too slow, because we focused on run-time efficiency, so we’ve tried to do many things to make Ruby faster. For example the engine in Ruby 1.8 was very slow, it was written by me. Then Koichi came in and we replaced the virtual machine. The new virtual machine runs many times faster. Ruby and the Ruby community have continued to grow, and some people still complain about the performance. So we are trying to do new things to boost the performance of the virtual machine. Even though we are an open source project and not a business, I felt it was important for us to set some kind of goal, so I named it Ruby 3×3. The goal is to make Ruby 3 run three times faster as compared to Ruby 2.0. Other languages, for example Java, use the JIT technique, just in time compilation; we don’t use that yet in Ruby. So by using that kind of technology and with some other improvements, I think we can accomplish the three times boost.
In order to boost Ruby’s speed, Matz also tossed around optimizing caching methods and implementing currency into the core Ruby language.
What he didn’t mention in that interview was a type system. The inclusion of the type system was perhaps an inevitable concession Matz was going to have to make. Part of Ruby’s philosophy is having multiple ways to do things so as not to restrict the user. However, this philosophy causes complications when apps built with Ruby grow in size. Properly documenting the code becomes difficult and the inherit slowness of dynamic typing hampers speed. In order to achieve the 3×3 goal, typing was probably needed.