7 ms·
Here's the point of view from someone who has only written 1 piece of production software with both C++ and Rust. Trying to write C++ I was constantly fighting
by 127 5y ago
Here's the point of view from someone who has only written 1 piece of production software with both C++ and Rust.
Trying to write C++ I was constantly fighting accidental memory copies. With Rust all of this was trivial and everything works as I expect. This is pretty much the reason I chose Rust over C++.
As a beginner I have no idea how I would begin to elegantly write immutable data, parallel code. With Rust it's just .iter() to .par_iter() (everything is immutable by default).
C++ package management is awful (it has none). C++ headers are annoying and pointless.
I know these are strong statements and of course only my opinion but I just see people claiming C++ is fine just having a strong case of Stockholm Syndrome.
Rust is nowhere perfect. Often it can look like line noise, the project folder takes multiple gigabytes even for small-ish projects, the compilations can be slow, the tooling is not always there. This is still multiple orders of magnitudes better than trying to Google how Cmake works step by step.
On the other hand I love rustanalyzer + vscode. It was super easy to get going with and just works. Visual Studio C++ seems to be much more steep as a learning curve.
- iudqnolq 5y ago> the project folder takes multiple gigabytes even for small-ish projects This is a workaround but you can specify a global directory for all those artifacts with the env var CARGO_TARGET. This will deduplicate common dependency versions and lets you stick it in a temp disk/exclude from backups.
- echelon 5y agoC++ is a garbage language. There's literally nothing worse. Not PHP, not Perl, not Bash nor VBScript. C++ is literally the worst language. You have to be an arcane wizard to write safe C++. Your code reviewers have to be all-seeing oracles. You're asked to follow this pattern called RAII, but the language does nothing to tell you this or enforce it. Creating declarations and header files is so ceremonious and tiring that it's a pain to prototype. By the time your ideas are concrete, you've already introduced bugs. Anyone who says they can program C++ safely is either a robot or is lying. Mozilla's single most important contribution is Rust. It's a literal godsend for systems programming. The ecosystem is maturing more and more every year, and it's now just about time we put C++ out to pasture. There's no saving it.
- pjmlp 5y agoIf an OS vendor was passionate about Modula-3, Ada or Eiffel, Rust wouldn't be needed, but unfortunely other paths were taken.
- carlmr 5y agoI don't know Modula-3 and Eiffel, but I do know some Ada. From my experience Rust, with the borrow checker, still brings a lot to the table compared to Ada. Although Ada has things that Rust doesn't have, too, like delta types, which are immensely useful in embedded programming, and SPARK. Ideally Rust would adopt some of these, or Ada in the next standard.
- pjmlp 5y agoAda is adding borrow checker like capabilities to SPARK. In fact this is what I consider Rust's biggest contribution to the computing world. Even if Rust dies tomorrow and eventually fades away, it has brought Cyclone and ATS ideas to the masses, to the point that many languages have done, are in the process of doing, design decisions to integrate affine or linear types to some extent with their type systems.
- throwaway894345 5y agoI would rather see more mainstreaming of sum types, although affine types are nice as well.
- keithalewis 5y agoOne good thing about C++ is that it scares off dumb people. :-)
- jhgb 5y agoSadly it also scares off smart people.
- Rochus 5y agoWell, it's good that you have the choice. Mastering C++ takes many years, and each edition of the standard adds a few hundred pages.
- rhn_mk1 5y agoWhile I agree with most of what you wrote, CMake feels supercharged compared to the build system part of Cargo. Cargo is failing hard on the integration front, both on integrating things, and being integrated. build.rs is a minimal substitute of a build system: "deal with it yourself". The way Cargo wants to have total control, on the other hand, makes it hard to integrate with existing projects: those which don't use Rust at the top level. The only great thing about Cargo's build system is that it works well on the happy path of Rust-only, crates.io-only software.
- deleted 5y ago[deleted]
- emidln 5y agoRust integrates pretty seamlessly into Bazel projects via rules_rust (https://github.com/bazelbuild/rules_rust https://github.com/bazelbuild/rules_rust). The existing rules even allow for c calling rust and rust calling c. Example: https://github.com/bazelbuild/rules_rust/blob/main/examples/ffi/c_calling_rust/BUILD.bazel https://github.com/bazelbuild/rules_rust/blob/main/examples/...
- throwaway894345 5y agoI was a C++ developer in a past life and Cmake was a big reason I moved on to greener pastures. It’s the only language that is more toilsome to use than C++ itself, and that by an enormous margin. It’s stringly typed (no, that’s not a typo, everything is a string), it’s syntax is obscure, it extends so poorly that it just bakes-in support for building popular libraries (e.g., Google’s test framework, Qt, etc iirc), imports are implicit so it’s tedious to track down the definition for a particular symbol, it completely punts on package management—not only were builds not reproducible but you couldn’t even get it to download and install dependencies for you from a declarative list. Cmake isn’t a build system, it’s a toolkit for scripting your own bespoke build system (and a crumby one at that) which basically means that every project is a unique snowflake with its own distinct quirks which are tedious to learn and maintain—even though 99% of projects would be covered by something like cargo. Those are some of the things I remember off the top of my head ten years later (it was also doggedly slow and things would break across minor releases, but I’m told those things have improved). Cargo is imperfect, but it’s the right tool for the job 99% of the time.
- skocznymroczny 5y agoI think a lot of those issues are more related to how bad C++ s rather than how amazing Rust is. I abandoned C++ several years ago for D and I can't imagine ever going back to C++. Similar issues, header files, no package management.