29 ms·
You should learn Rust if you want to write fast code. There’s a discussion on lobsters “C++ or Rust?” (https://lobste.rs/s/0akqy7/are_there_any_good_reasons_us
by armchairhacker 3y ago
You should learn Rust if you want to write fast code.
There’s a discussion on lobsters “C++ or Rust?” (https://lobste.rs/s/0akqy7/are_there_any_good_reasons_use_c_over_rust https://lobste.rs/s/0akqy7/are_there_any_good_reasons_use_c_...) and the general consensus is that Rust is better except for legacy reasons. I disagree, I believe there are niche cases C++ is better even on new projects with new teams (maximum performance, no care about safety, most on the team don’t care about “functional programming”, something like UI or game dev), but they are niche and the benefit is marginal. Which means Rust has a good chance to become the future.
Even if you end up writing C++, Rust teaches concepts which translate to C++ specifically and writing fast code in general. Including concepts related to the “functional” aspect which will help you write better, safer C++.
Also learn Rust if you want to learn more about low-level abstractions and functional programming, primarily for writing fast code.
However, I still believe you shouldn’t learn and use Rust for writing general-purpose code, unless you care about learning performance. Because languages with garbage collectors (JVM languages) and weaker memory models (Swift) are “fast enough” in most cases. And I’m very skeptical that most people would implement something faster in Rust than they would in Kotlin, TypeScript, OCaml, even C# or Java; because the borrow checker does create overhead. Unless they need to go back and optimize for performance (or they are writing idiomatic code in Rust but not in the other languages; most of the functional paradigms from Rust, like small structures, typed wrappers, polymorphism, composition, even ad-hoc multiple inheritance (extensions or default methods) and pattern-matching can be applied to all the languages mentioned above).
- FullyFunctional 3y agoI don't love Rust because of "fast code", I love it because it leaves me less stressed and less frustrated, IOW, happier. There's so much emphasis on the memory safety of Rust that it overshadows everything else that is awesome about it. Rust (largely) gives me the power of Haskell strong types, but with fantastic tooling and a much much richer library (if you include crates.io). I find the difficulty of Rust overstated; much of the borrowing challenges can be avoided by cloning/copying wherever required and limiting borrowing to where that approach becomes an actual performance problem. As Python's success proves, developer productivity trumps runtime efficiency.
- wrcwill 3y agodefinitely. I couldn't go back to a language without result types, null safety, and a way to control mutability. Unfortunately the list is pretty short.. rust, haskell, and now gleam are three that i've found nice. gleam and haskell control mutability by being immutable, and rust is kindof have your cake and eat it too with the borrow checker
- drogus 3y agoSpeed is not the only thing why Rust makes sense: 1. Safe Rust disallows data races at compile time, see for example: https://msrc.microsoft.com/blog/2020/04/the-safety-boat-kubernetes-and-rust/ https://msrc.microsoft.com/blog/2020/04/the-safety-boat-kube... 2. WASM is getting more and more usage (also on the server side) and Rust is one of the best languages to compile to WASM at the moment 3. If you need to support multiple programming languages with one library it might make sense to write a Rust core and wrappers in other languages 4. Rust has explicit error handling, so it might make sense to write a Rust application in critical applications where you need to be sure you handled as much error conditions as possible 5. Sometimes an application doesn't necessarily need to be ultra fast, but needs to have predictable performance. In some situations Java or Go won't be much slower (or could be even faster) than Rust, but in Rust it might be easier to get lower latency variance. There is probably more, but I choose Rust for many projects that do not need Rust's speed and I believe this is also the case for many people writing Rust.