by TwentyPosts · 2y ago · 0 comments
What did you actually gain from this, outside of more work?
And since that new Rust compiler might not have much of an optimizer (if it even has one at all), then you recompile rustc with your just-compiled rustc.
Pypy, for instance, implements RPython, which is a valid subset of Python. The compiler is written in RPython. The compiler code is limited on features, but it only needs to implement what RPython includes.
It is much easier to add support for a platform to the compiler backend than to write a new, full compiler with its own, new bootstrapping method.
It's not that it's exceedingly hard in C, but programming languages have evolved in the last millenium, and there are indeed language features that make writing compilers easier than it used to be
I have the most fun when I write x86 MASM assembly. It's a pretty simple language all in all, even with the macro system. Much simpler than C.
But a simple language doesn't always make it simple to write complex programs like compilers.
Given the task is to bootstrap Rust, a Rust subset is a reasonable and pragmatic choice if not literally the only one (Mes, a Lisp, could also work and is already part of the bootstrappable ecosystem).
And once you get past fighting the borrow checker it's a very productive language, with the standard containers and iterators you can get a lot done with high level code that looks more like Python than C.
C isn't even in the same league as Rust when it comes to productivity – again, if you're equally proficient in Rust as in C.
Rust isn’t in a difference class from C, it’s a different universe!
I don't remember it being any easier to write C that passes through a static analyzer like Coverity etc. than it is to write Rust. Think of rustc like a built-in static analyzer that won't let you ignore it. Sometimes that means it's harder to sneak bad ideas past the compiler.
https://bootstrappable.org/ https://github.com/fosslinux/live-bootstrap/
- you can write the bulk of your code in a language you prefer over C
- you end up with a self-hosting rust compiler