From: Rafael 'Dido' Sevilla Date: 2002-08-07T12:32:56+09:00 Subject: Re: Compiling Ruby to Native Code? On Tue, Aug 06, 2002 at 10:19:54AM +0900, Edward Wilson wrote: > What prevents Ruby from acheiving native compilation, dynamic typing? > If so, could Ruby implement a `require static' to force strict type > checking to provide for machine level compilation. > I don't think dynamic typing is the problem. We've had an Objective-C compiler in GCC for about ten years or so, and the fact that Objective-C is even more rabidly dynamic than Ruby hasn't stopped the folks at NeXT and the GCC developers from producing a native-code compiler for it. True, it makes the compiler more complicated and slower, but that didn't hold them back. > If Ruby could compile to native, forget byte compilation. The one > thing that's been on my Java Christmas List for almost a decade now > (7yrs) has been native compilation. Just give me a `native' compiler, > I'll manage the rest. > Byte compilation does have its uses. Given the fact that it's a lot of work to write a native code compiler for a given architecture, it allows a programming language to be used anywhere the bytecode interpreter can be built, which is usually a matter of porting a C program, while not totally trivial, is trivial when compared to writing a full native code compiler for a new architecture. Getting GCC to support a new architecture for example, means the creation of a new patch to binutils in addition to the work involved in writing the GCC backend. That's the logic behind the existence of the OCaml bytecode compiler; it allows the language to be used with reasonable performance on many more platforms than would otherwise be possible, as well as providing a means for bootstrapping a compiler. > Game over, if Java or Ruby provides native compilation; it won't make > sense to code with anything else. I humbly disagree. While Java and Ruby are very good general-purpose languages, I think that there's still a place for more specialized languages to solve particular problems, even if it's just for prototyping. I've found that languages like OCaml and Haskell are excellent for prototyping problems involving complex data structures, and give you new and better insights into how the problems might be solved. Result: you have cleaner, more elegant code that's easier to understand and maintain, once you go from your prototype to the actual design in the target language. If for nothing else but increasing mental flexibility, other languages are useful. -- Rafael R. Sevilla +63(2)8123151 Software Developer, Imperium Technology Inc. +63(917)4458925