Stoppt die Vorratsdatenspeicherung! Jetzt klicken &handeln! Willst du auch an der Aktion teilnehmen? Hier findest du alle relevanten Infos
  und Materialien:

Skip to content


Why a self-hosted system is great

I’ve been asked recently, why writing a Ruby compiler in Ruby would make any sense. The argument was, that by compiling Ruby code to native machine code, you’d lose all the benefits of a ’scripting language’.
Now, you could argue, if you’d want to degrade Ruby simply to a scripting language – and I don’t think that Ruby is only that (whatever a ’scripting language’ may be…) – then you’d lose quite some flexibility (e.g. simply changing a file and run it again etc.).

But there’s a more important thing to consider here:
All the implementations out there currently are (mostly) written in another language. JRuby in Java, IronRuby in C#, MRI (default Ruby intepreter) in C and even Rubinius is written to great part in C++.
The reason is simple: Since you need some way to actually get your code running, you’ll need a host language to get the Ruby VM running on.

Now consider writing a native Ruby compiler in Ruby itself:
Once you’re able to bootstrap the compiler (meaning, to be able to compile it with itself), you’ve got a natively compiled executable, written in Ruby, where you don’t need any runtime/VM for. You could actually write a Ruby Interpreter / VM completely in Ruby itself, since you could also compile it with the native compiler. Additionally, making changes and understanding the source code of all these parts would be much easier for a normal Ruby programmer than any other system, since it’s all written in the language it’s targeting.
Now this would be awesome, wouldn’t it?
Any Ruby programmer could actually work on the language platform with the language itself. I think this would just be really cool.

So once the compiler would work well enough to actually compile quite large programms, it shouldn’t be too hard to get a Ruby Interpreter written in Ruby. :)

Of course, writing a language implementation in the language it’s implementing isn’t something new. Most Lisp implementations have been written in Lisp, the same goes for C & C++ compilers. In the case of Lisp, we have a dynamically typed language which gets compiled. And if you take a look at some performance benchmarks, you’ll see that there are Common Lisp implementations out there, that are really fast for a dynamic language (very well comparable to the speed of C!). This obviously takes some time, but it shows what can be possible. ;)

Posted in General. Tagged with , , , , , , , .

One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. I don´t know if it is possible to come near to C/C++-Speed but it´s of course a big advantage for every programmer who uses the compiler written in the language they are programming in.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.


Ihr Browser versucht gerade eine Seite aus dem sogenannten Internet auszudrucken. Das Internet ist ein weltweites Netzwerk von Computern, das den Menschen ganz neue Möglichkeiten der Kommunikation bietet.

Da Politiker im Regelfall von neuen Dingen nichts verstehen, halten wir es für notwendig, sie davor zu schützen. Dies ist im beidseitigen Interesse, da unnötige Angstzustände bei Ihnen verhindert werden, ebenso wie es uns vor profilierungs- und machtsüchtigen Politikern schützt.

Sollten Sie der Meinung sein, dass Sie diese Internetseite dennoch sehen sollten, so können Sie jederzeit durch normalen Gebrauch eines Internetbrowsers darauf zugreifen. Dazu sind aber minimale Computerkenntnisse erforderlich. Sollten Sie diese nicht haben, vergessen Sie einfach dieses Internet und lassen uns in Ruhe.

Die Umgehung dieser Ausdrucksperre ist nach §95a UrhG verboten.

Mehr Informationen unter www.politiker-stopp.de.