Congratulations to the authors/contributors of actix-web on the 1.0 release!
Congratulations to the authors/contributors of actix-web on the 1.0 release!
The biggest hurdles for me (I'm still learning) compared to JS is the borrow checker, lifetimes, and strings (they are handled very precisely in Rust).
The benefits are huge though. My time coding in JS feels like 50% coding & writing tests, 40% debugging my app, 10% reading documentation. The "debugging" portion can sometimes be painful when fixing race conditions. Rust on the other hand, feels like 30% reading documentation, 30% coding, 30% getting my code to compile, and the other 10% debugging/testing my app. For the most part, if your code compiles and your logic is correct, your app is guaranteed to run the way you expect it to.
That's the theory anyway. I haven't gotten any data from people trying that on real-world apps, though. There could be non-obvious problems with it.
https://www.php.net/manual/en/features.gc.collecting-cycles....
It seems like people who often use Rust's Rc and Arc will long for some way to implement generic cyclic garbage collection. I don't yet see a way (other than unsafe code), but I may be missing something.
The "high level" stuff baked into Rust makes it great for "low level" tasks, notably imo:
- Tests (and micro benchmarks, with nightly) alongside code, without dependencies or build system hackery.
- An incredibly powerful macro system, supplanting a lot of the templated code generation I've done in C++ which is a nightmare. Not that proc macros are perfect (yet) but at least they're legible.
- If you've ever tried to do away with dynamic dispatch via templates in place of inheritance, then Rust's generics with trait bounds are an absolute godsend
- A gosh darn dependency solution (now with custom repositories on stable!) makes dependency hell is less hellish
Low-level programming is possible in Rust, as it is in many high-level languages, but it is discouraged. Use of "unsafe" is rightfully met with scepticism.
C++ is also a high level language, but does not enforce use of high-level safety abstractions by default. Web programming in C/C++ is possible, and frameworks exist to do it, but memory safety (security) concerns make it undesirable.
And I think it’s a bit more subtle than you’re giving credit for.
It's not like the C/C++ specs are particularly precise. I think people tend to have a mental model of specs as equivalent to formal semantics, which they very much are not.
If you’ve noticed that lately there are a lot more pieces of systems software built in the architecture of “a daemon plus a client executable that talks to it over a control-channel Unix domain socket, but where that same control-channel [with different auth logic] can also be exposed over the Internet” — that’s thanks mostly to people writing things in Go, and Go making that architecture easy to set up (with the simplest option being a gRPC-protocol connection, but a RESTful HTTP service layer being only a little bit more work.)
Now it’s easy to set up such a RESTful service layer for your daemon in Rust, too!
At least I would only reach out for Rust at the moment for performance critical code, and then don’t leave easy optimizations on the table due to lifetimes.
I do agree though that the tooling is very immature compared to other ecosystems, and Rust is generally quite boilerplate heavy and slower to develop.
It can still be a good choice if you need really high performance/low resource consumption - or you are going for high correctness and robust error handling.
But for most web backends Rust won't make much sense.
(I say this as someone who even writes web frontends with Rust via wasm, where it is even less optimal - mainly due to the high compile times)
With Rust I don't think you have to choose.
Once you "get" the borrow checker and understand the ownership model Rust becomes very productive and feels like a high level language. There's a little noise in the syntax but what you get in return is so worth it. There are quite a bit of high level features to take advantage of that "compile away" with so called zero-cost abstractions.
It's a legit low level language in the sense that you can write a legit OS. No GC, guaranteed memory safety. It's bonkers.
I believe it is blurring the lines of what it means to be high/low level.