I would like to experiment with Crystal however I am using OpenIndiana (Solaris) and since there is no native distribution I cannot compile Crystal. The “Build from sources” section located at
clearly specifies that I have to “Install the latest Crystal release. To compile Crystal, you need Crystal :).” So how am I supposed to build Crystal?
That’s one of the hard parts about a self-hosted compiler. It can be cross-compiled from another machine, though.
One point of friction you might run into, though, that support for Solaris appears to be pretty minimal (it’s listed as tier 3 and CI doesn’t run against it for either tests or compiler builds). So while it might work, there’s no guarantee.
Thank you very much for your reply. However, I am wondering how did you create the first compiler of the language? If it was written in the language itself, then it is impossible to compile it. On the other hand, the Rust compiler was initially programmed in OCaml and then people wrote it in Rust and used the first compiler to create the real compiler written in Rust. So where is this first compiler and why you do not distributed it?
The process is called bootstrapping compiler. First the compiler needs to be written in a language already available on a platform. Then, when it advanced enough, compiler can be rewritten in a language itself.
In case of Crystal first compiler was written in Ruby a long long time ago.
I haven’t tried OpenIndiana so the exact instructions may vary. (My bigger concern is how to get Crystal into those Solaris distributions’ package/port repositories.)
It was originally written in Ruby. Eventually, the stdlib grew enough to support building the compiler in Crystal. That’s generally how all self-hosted compilers work.
The Ruby-based compiler was replaced by the Crystal implementation. Since git commits are built on top of all previous commits, the Ruby implementation still exists in the git history and you could try it if you like, but the language has evolved a lot since then and it probably wouldn’t compile many modern Crystal programs. The same is probably true of Rust — I imagine the OCaml-based compiler probably wouldn’t compile most modern Rust programs.