I think a "better C" is the biggest hole in the programming language world today. Rust doesn't do it to me, because what makes C great is that it's so simple, and easy to write a compiler for. Rust is a different class.
I think a "better C" is the biggest hole in the programming language world today. Rust doesn't do it to me, because what makes C great is that it's so simple, and easy to write a compiler for. Rust is a different class.
I also object to the idea that it's easy to write a C compiler. A toy compiler might be easy, but a good one takes UINT_MAX man-hours at least.
I think Walter could legitimately claim this is only true if your int size is 11 bits (so about one man-year) or thereabouts.
And yes, I meant it's easy to write a simple/"toy"-compiler. TCC is a good example, and I've actually used it for a real in-house project. Not every application requires perfect compatability and good optimization, and it makes it easy to get started on more elaborate compilers.
Off the top of my head: simplicity, strings, no globals, easier allocations, automatic memory management, no LLVM dependency, hot reloading, faster compilation times: https://vlang.io/compilation_time
- It uses outdated libraries - `rustc_serialize` instead of `serde`, and `hyper`'s synchronous API (which no longer exists) instead of `reqwest`'s synchronous or `hyper`'s asynchronous API.
- It spawns eight threads, whereas the Go example (and presumably the V example too?) uses eight fibers.
- A thread-safe incrementing counter would be better done using an `AtomicUsize` rather than a `Mutex<usize>`, in which case the entire `next` function is a single call to `AtomicUsize::fetch_add`.
A modern Rust example could either continue to use the eight threads, in which case it would look quite similar in terms of the length of the code.
But more likely someone writing the code today would use fibers via futures and tokio, which would not have the Mutex or "manually chunk the work among eight workers" stuff. I think that it would be a bit shorter and clearer than the current code, but I would have to write it out to be sure.
Indeed it's a bit shorter than the original, and hopefully clearer without the line noise of locking and manually chunking work.
(I don’t work on that stuff personally, to be clear.)
Got some help :)
It's definitely less "simple", contrary to what the text introducing it says, compared to letting futures+tokio handle the concurrency for you. Not to mention less efficient.
But I suppose it needs to be this way so as to be equivalent to the other languages' examples.
It had ownership and templates but was mainly meant to be directly translatable to C.