From: Tord Kallqvist Romstad Date: 2002-08-08T18:25:56+09:00 Subject: Re: Compiling Ruby to Native Code? llothar@web.de (Lothar Scholz) writes: > Tord Kallqvist Romstad wrote in message news:... > > web2ed@yahoo.com (Edward Wilson) writes: > > > > > What prevents Ruby from acheiving native compilation, dynamic > > > typing? > > > > Not at all. There has been excellent, optimizing Common Lisp > > compilers (generating code comparable to, and occasionally faster > > than, the code generated by C compilers) for at least a decade. I am > > sure a native-code Ruby compiler would be technically possible. > > I also must repeat myself here. There are only two ways to get good > lisp speed > using (the) to introduce static typing or reduce the security level of > the compiler so that you must provide always the correct type. You are right here, of course. In order to achieve C-like performance, you will have to use type declarations in parts of your code. However, 1. You still have all the benefits of dynamic typing while developing your program. There is no need to add any type declarations before the program is completed and you discover that it is not fast enough. 2. Even without any type declarations, compiled Lisp code performs rather well. It is certainly much faster than interpreted languages like Ruby. My knowledge of Ruby is still rather limited, but I don't see why adding a native-code compiler should be more difficult than for Lisp. Even with dynamic typing, the compiled code would probably perform much better than interpreted Ruby. Add optional type declarations (like in Lisp), and it should be possible to achieve the same speed as with optimized Lisp code. Do you disagree? If so, what properties of Ruby make it harder to compile than Lisp? > Never written a compiler - right ? Of course I have. I doubt that there are many Lisp programmers who have not (at least) written a compiler for some subset of Scheme. -- Tord Romstad