The beauty of the unsafety of C is partially that it's pretty easy to spin up a compiler on a new platform. The same cannot be said of Rust.
The beauty of the unsafety of C is partially that it's pretty easy to spin up a compiler on a new platform. The same cannot be said of Rust.
In my opinion, the verification of the implementation should be separate from the task of translating that implementation to bytecode. This leaves you with a simple compiler that is easy to implement but still with a strong verifier that is harder to implement, but optional.
That's a very unkind assumption of my argument.
I ask that you read https://news.ycombinator.com/item?id=45314707 to hopefully better understand my actual argument. It doesn't involve calling anybody stupid or lazy.
Sure its not impossible for C to get that, but at the same time, they are trying to write git not fix C.
* My point is, that hash maps and data structures like that are clearly not the priority of C or they would **exist by now.
** by exist I mean either in C standard, or a at least a community consensus about which one you pick, unless you need something specific.
See: https://news.ycombinator.com/item?id=45120171
Nobody needs to change a language standard for 9 lines of code. When you really want to use a hash map, its likely that you care about performance, so you don't want to use a generic implementation anyway.
> or a at least a community consensus about which one you pick
There is a hash table API in POSIX:
GNU libc: https://sourceware.org/glibc/manual/latest/html_node/Hash-Search-Function.html
Linux hsearch(3): https://man7.org/linux/man-pages/man3/hsearch.3.html
hsearch(3posix): https://www.man7.org/linux/man-pages/man3/hcreate.3p.htmlBut like, so does LLVM.
I prefer to ask another question: "Is this useful". Would it be useful, if we were to spin up a different platform in the future, to be able to do so without LLVM. I think the answer to that is a resounding yes.
That doesn't leave rust stranded. A _useful_ path for rust to pursue would be to defined a minimal subset of the compiler that you'd need to implement to compile all valid programs. The type checker, borrow checker, unused variable tracker, and all other safety features should be optional extensions to a core of a minimal portable compiler. This way, the rust compiler could feasibly be as simple as the simplest C compiler while still supporting all the complicated validation on platforms with deep support.
mrustc is a bootstrap Rust compiler that doesn't implement a borrow checker but can compile valid programs, so it's similar to to your proposed subset. Rust minus verification is still a very large and complex language though, just like C++ is large and complex.
A core language that's as simple to implement as C would have to be very different and many people (I suspect most) would like it less than the Rust that exists.