From: Avi Bryant Date: 2005-04-08T18:34:40+09:00 Subject: Re: Seven new VMs, all in a row George wrote: > I'm curious - how good a fit are Ruby semantics for Smalltalk VMs? They fit almost exactly, which is why 20-30x is not an outrageous speed claim, and why comparisons with Mono, JVM, Parrot etc are entirely missing the point: this is not equivalent to compiling Ruby to Java classes, say, but to realising that Sun's Hotspot team had been writing a VM *specifically to run Ruby* all along - which they effectively were before Sun crippled it, but that's another story. > Do > Smalltalk VMs/bytecode provide the following Ruby facilities, and, if > not, how easily can they be emulated? > > - blocks (with Ruby semantics in case they're different from > Smalltalk's) Yes. > - mixins Yes. Lothar also asked about singleton methods, to which the answer is also Yes. > - instance variables that don't need to be predeclared with the class Not exactly as Ruby does, but you can simply add new instance variables to the class definition whenever you compile a method that uses a new one. > - class variables & constants Yes. > - throw/catch Yes. > - exceptions Yes. > - continuations Yes (depending on the VM; Squeak, VisualWorks, and Dolphin all support them). > - support for OS facilities like select, signals etc Not portably; the OS facilities and binary extension mechanisms are highly specific to VMs. One thing nobody's asked about is variable and optional arguments for methods. Some VMs (like Squeak's) can handle this just fine, but some may require that the number of args pushed onto the stack match the selector. In any case, to do it optimally it would require generating bytecode, not Smalltalk code, which makes targetting a whole range of VMs difficult; to do it portably would mean creating an extra Array on every message send. Avi