Like many others, I always hold true that "A pure compiler will never exist for Ruby because the language is far too dynamic for a static compiler to work."
But I recently stumbled upon these:
The Crystal programming language at GitHub
Statically compiled Ruby
Both projects seem to be very interesting. They could give us the speed of a native-compiled language (and the often commercially-required, obfuscated code of a compiled language) while keeping all (or most) of the elegance and flexibility of Ruby. Add a good support library (or, more likely, the possibility to access the existing C++ libraries) and you can easily understand why this stuff could be interesting.
Has anybody tried the Crystal language? (I didn't yet, because of compilation problems with ruby-llvm)
Which was his/her feeling about it?
Do you think that, given those design choices, would it be actually possible to develop a native-code (machine-code) compiler for Ruby (with a reasonable effort and in a reasonable amount of time)? Would it be meaningful?
Crystal is a programming language that can be easily understood by humans and compiles to fast programs. It's a statically-typed, compiled language, that achieves performance close to c/c++ while having a syntax as readable as Ruby.
Crystal is currently in active development. It is released as free and open-source software under the Apache License version 2.0.
Ruby is a compiled language in much the same way that Java is. While ruby is not compiled down to native machine code, it is compiled into a set of bytecode instructions that are interpreted by a virtual machine.
Like many interpreted languages, Crystal will let you do pretty much whatever you want in as few lines of code as possible, and in a way that is readable and aesthetically pleasing. For this reason, Crystal is sometimes advertised as similar to Rust but easier to read and write.
I'm the developer of crystal. Currently not everything is implemented from the bulleted point list. In fact classes were just started to be implemented.
I really like the idea of it though. But I need to think more about how to implement it. And I also need more time, hehe.
The second article has a completely different approach because it won't introduce a new language: it'll just try to compile a subset of Ruby, or maybe will be compiled to native code but still allow some dynamism with performance costs (I talked to the author of that article some months ago).
My feeling toward both approaches: I really with it could happen. We need a fast language with an elegant, readable, joy to use syntax and library (like what Ruby offers).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With