Dynamic languages trade some of the compile-time safety properties of statically typed languages for greater flexibility for a programmer to write correct programs that a static compiler would turn down as potentially faulty. There is a recent trend to integrate aspects of both disciplines, commonly by "adding types" to languages originally designed as dynamic.

There has been interest in the Ruby community to explore such an approach: Yukihiro Matsumoto devoted his keynote at RubyConf 2014 to the potential implementation of static typing in the language. The topic is complex: a Ruby tightly corseted by types would not be true to the essence of the language.

Under a gradual typing discipline, type annotations can be specified at will: interesting parts of the program can be given explicit types and their type safety checked statically. We propose an implementation of gradual typing in Matz's Ruby Interpreter, drawing inspiration from similar additions to other dynamic languages, with strictly optional type annotations consistent with Ruby's DRY and "lazy" philosophy and an evaluation of the practical usefulness of gradual typing.





  • Tony Arcieri
  • bai