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
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.