|
|
|
Ask HN: Modern C++ or Rust and why?
|
|
15 points
by sptth
1507 days ago
|
|
It's a simple question still there are many opinions out there. I want to ask this here as it is one of the most active comunities amongst programmers. So if you are a C++ developer who migrated to Rust or viceversa, please tell me what you miss or what you dont miss from your former programming language. Also any links to benchmarking or studies stating one is better than the other would be interesting. Thanks in advance ;) |
|
If you learn C++ first, and then learn Rust, you'll find that Rust is sort of a pleasant syntactic cleanup over modern C++ idioms. You'll be happy with the high-quality standard library, mechanically-enforced best practices around nullptr/const, and a core language team that is actively engaged with driving forward progress.
If you learn Rust first, and then learn C++, you'll be amazed by the wealth of libraries that are available. There are still entire ecosystems (looking at gRPC and Protobuf here...) that are C/C++ first, with bindings to other languages, and basically no first-party support for Rust. There's a lot of benefit to being able to reuse existing work.
And once you've learned both, and gotten a handle on the FFI syntax, it becomes natural to write greenfield code in Rust while being able to "drop down" into C/C++ when necessary.
The number one rule here is you must focus on modern C++, not old-school stuff with void* pointers and reinterpret_cast<> everywhere. It's easy to learn low-level programming the wrong way, which will cause your C++ code to be low-quality and frustrate your learning of Rust because you'll constantly be colliding with the guardrails.