My first rust project - a C-ish compiler. And why I'll continue using rust.

81 points run-gs

Hello everybody!

I have spent the last month coding a compiler in rust, mainly following the theory from the book "Engineering a Compiler, 2nd edition" by Torczon & Cooper. The compiler itself is nothing extraordinary and pretty mediocre, but I've wanted to write a compiler for quite some time.

This was my first long-term completed project in rust (I also have a GBA emulator currently DNF), after years of C++ and Python (and SystemVerilog).

I must say, the compiler messages are more than sufficient to keep me using rust. They are always ahead of you. Some issues they solved probably would require hours of debugging in C++. I loved the Option and Result types, and enums were fundamental in many occasions.

As I am still a novice with the language, I have just mentioned the tip of the iceberg. For instance, I know cargo is great, while I did not need many extra-packages for this project. Also, I have not explored any concurrent programming so far and not taken full advantages of traits. However I prefer learning stuff as soon as I actually need them.

In the end, I feel like there is nothing I miss from C++ that I cannot achieve with rust in these kinds of project that don't rely on other codebases. Please change my mind if needed.

If you want to have a look at it, here is the link.