Better Ruby

From JVMLangSummit
Jump to navigationJump to search

JRuby, Duby, and Juby: Building a better Ruby — Charles Nutter

File:JVM Languages Summit 2009 - JRuby.pdf


JRuby, Duby, and Juby: Building a better Ruby — Charles Nutter

You know JRuby is an implementation of Ruby for the JVM. But have you heard about Duby or Juby? Duby is Ruby syntax with Java's type system and static typing. It utilizes local type inference to keep code as clean as Ruby, but runs as fast as Java. Juby is Duby's dynamic cousin, totally dynamically-typed and using invokedynamic for all dispatch. Both Duby and Juby have been research conduits for the next generation of JRuby work, which will incorporate techniques from both languages. We'll talk about all three.



  • making optimizations for things like returining from closures
  • Invoke Dynamic (indy):
    • eliminates generated handles, simplifies things
    • inlines a lot of otherwise complex logic
    • getting faster
  • Duby is an experiment in optional static typing that may be rolled into JRuby
  • new optimizing compiler now that they have a "real compiler guy" on the JRuby team


  • a side-project
  • "like Ruby but as fast as Java; essentially Java with Ruby syntax"
  • typing works kinda like Scala
  • no runtime library
  • purpose: an implementation language for JRuby, mobile applications
    • "doesn't add too much"
  • code example: only different between Ruby and Duby is specifying the type of some arguments to methods
  • "" is hard-coded to object creation, not a method call
  • status:
    • type and method definitions work
    • importing types, Java object construction works
    • todo: arrays, reopening classes, mixins, closures, runtime libraries in Duby, Java 5 features,
    • possible LLVM backend or in other languages


  • another side-project
  • exactly Ruby syntax
  • dynamically typed ("not quite as crazily dynamic as Ruby")
  • dynamic dispatch (indy)
  • minimal runtime library (indy dispatcher)
  • scriptable, but no interpreter
  • "as fast as Java (can do indy)"
  • goals: experiment with indy, help the implementors test, try things outside JRuby
  • code examples: really identical to Ruby
  • bunch of stuff still to do
  • Java version of fib example (only) 40% faster than Surinx version