A line-by-line translation of the OCaml runtime from C to Rust

Great work! Thanks!

Keep in mind that Rust is a massive dependency! And I really mean
massive! :slight_smile:

Two suggestions: Try to compile Rust from source. Then, try to compile Rust from source on a non-Linux system. Then, try to compile Rust really from source, not using a binary bootstrap :slight_smile:
And then, cloc-count the lines of code of the Rust source tarball (hint: plug in your power supply and don’t put your laptop in the sun :). Then, you’ll understand, why it might be a good idea to not depend on Rust :). Last time I run cloc on rustc-1.84.1-src.tar.gz, it took 3x longer than to compile OCaml :slight_smile:

About building Rust from source, the official documentation will tell you that: If you really want to install from source (though this is not recommended) see INSTALL.md.

FYI, if you run “cloc” on the Rust repo, you’ll end up with ~ 4 million lines of code total (OCaml: ~500 kloc). If you run “cloc” on a e.g. rustc-1.84.1-src.tar.gz, you’ll end up with about 50 (!) million loc, of which 20 million lines are Rust code. This includes most dependencies required to build Rust and cargo, e.g. 3 different versions of OpenSSL IIRC and many other vendored libraries are included in 2-3 different versions, so the total numbers are bloated a lot.

Build time: On the same machine where OCaml builds in 3 minutes 30 seconds Rust took 3 hours and 30 minutes (including LLVM). And that is using a binary bootstrap compiler, so it’s not truely “from source”. You need to add the time to compile mrustc (a Rust compiler written in C++, 150k loc) on top of that. Also not included is Python and cmake, both required to build LLVM. The whole bootstrapping process is a lot more “fragile”. It happened to myself that 2 hours into the build something broke because I was not using Linux. The long build times made it a lot more difficult to fix. Also the complexity of the build process itself is a lot more complex in my opinion.

That being said, while Rust is a great language for developing performance- and safety-critical software, it is not a light dependency!

OCaml on the other hand is really great when it comes to bootstrapping itself and by having a relatively low number of dependencies of low complexity.