Why bootstrap?


I’m sorry for what may sound like a weird question, but why is Crystal’s compiler written in Crystal rather than C/C++? It seems to complicate cross-compatibility; for example, there’s no Raspbian package, and my attempts to build Crystal with MacPorts have failed.

The language itself looks like a thing of beauty :slight_smile:.

And we like to program more in Crystal than in C/C++ :smile:
It’s also a way to keep using the std-lib itself

1 Like

Another reason: we (or at least I) don’t know how to program in C/C++ at the scale of doing a compiler (the only knowledge I have about C++ is some classes in university, so from that you can guess my level :grin:). We do know Ruby, and that’s what we used. And since Crystal is very similar to Ruby, we eventually ported it to Crystal.


That said, one day we could make the compiler compile to C instead of LLVM. Then you could bootstrap it from C…

Now that I think about it… I wonder if there’s an LLVM IR -> C translator somewhere already… :thinking:


Fair enough, all! Thank you for prompt responses.

Hoping to get to play with all this hotness soon. :slight_smile:

FWIW I don’t think that porting to a new platform is complicated by bootstrapping. The hard part here is mostly ABI compatibility and then stdlib compatiility to plaform specific behavior of libc & kernel APIs. As Ary hinted we could probably gain some things for free here by being a C transpiler rather than an LLVM frontend, but whether that frontend or transpiler is written in Crystal or C/C++ doesn’t really matter at all at this point :)

1 Like