From: Charles Oliver Nutter Date: 2010-09-30T04:04:57+09:00 Subject: [ruby-core:32640] Re: Proposal for Optional Static Typing for Ruby On Wed, Sep 29, 2010 at 3:10 AM, Joshua Ballanco wrote: > On Sep 29, 2010, at 12:33 AM, Bill Kelly wrote: > >> Is everyone familiar with the approach Charles Nutter has >> taken with his Mirah language (formerly Duby)? > > It's been a while since I've taken a close look at Mirah/Duby, but my understanding is that the performance gains that Charles has achieved have less to do with static vs dynamic typing and much more to do with Mirah's type system being a closer match to Java's type system (for which the JVM is already optimized). Incorrect. The performance gains come from being able to specify direct invocations or raw numeric operations statically, avoiding the type checks and numeric boxes that normally are required for Ruby code. JRuby can probably get within 2-3x Java's invocation performance, and perhaps closer to 1x Java's performance with invokedynamic, but in all cases dynamic languages must pepper their optimizations with type guards, modification checks, and so on, just in case someone changes something or an unexpected type floats through the system. Mirah (and other statically-typed languages) avoids this VM-confounding behavior by making compile-time guarantees about what subset of types the code will see, allowing the VM to be more aggressive in its optimizations. - Charlie