Live data from Hacker News

Ask HN: Learn C++11 or Rust in 2022?

news.ycombinator.com

71–80 of 161 posts

Re: Ask HN: Learn C++11 or Rust in 2022?

#71
post #70

I remember when Stroustrup's C++ came out in 1986. I used to be able to cite the Annotated Reference Manual (ARM) by chapter and verse. But if I were a young programmer in 2022 and looking at learning either C++ or Rust I'd choose Rust in a heartbeat. Why? Many reasons. For starters, C++ is 40 years old at this point and embodies software engineering practices from the late 70's to early 80's (for you young folks, st…

Honestly, I think the shift you are already seeing is from C++ -> a GCed language (python, javascript, java).

While C/C++ are everywhere, they are mostly in very low level places. You don't find a lot of new backend projects that go the C++ route.

Rust will likely eat up a significant chunk of C++'s current market share and SOME of the backend service market share (where CPU and Memory are REALLY important). However, I don't find it terribly likely that it will grow much beyond that.

As for the Cobol analogy, a good one, but you have to also realize there are about 1,000,000x more lines of C++ in the wild than Cobol. For cobol to die takes some institutional investment that most companies are not willing to burn. C++ will have a MUCH harder time being purged.

Re: Ask HN: Learn C++11 or Rust in 2022?

#72
post #44

Not for everybody, and I’m sure it’s not the most efficient way to approach it, but I personally felt that learning modern C++ was a good intermediate step before learning Rust. Going to rust directly has been a very frustrating experience and made me give up. Instead I spent time learning C++, I found out I could more easily transfer my knowledge/skills there. Once you become more proficient with the basics you lear…

One reason C++ experience is so helpful with Rust is because the language was created by C++ programmers for C++ programmers, so most books and even documentation are written from that perspective.

Re: Ask HN: Learn C++11 or Rust in 2022?

#73
post #66
post #2

Between C++ and Rust, my bet would be that you decide Rust. But—also learn Zig in addition to Rust. Having seen first-hand how so many threat vectors these days are now supply chain attacks, having reported CVEs and earned P1 bounties in memory safe languages, and having worked on static analysis systems to detect zero day exploits—I'm also impressed by Zig's overall approach towards safety, as being more than only m…

Counterpoint: Zig is unstable (as in, Stick to C++ or Rust, which I won’t weigh in on here. But both are much more mature.

Also there's no job market for it.

Re: Ask HN: Learn C++11 or Rust in 2022?

#75
Today, I think it comes down to what you want to build and what dependencies or SDKs (if any) that requires. If you want to build something greenfield with simple dependencies, I would go Rust. However, if you want to build something that depends on existing software, there's a good chance that you're going to have an easier time today doing that with C++ due to its dominant ecosystem.

For example, one of my products embeds Chromium (via CEF), which itself is a huge C++ project. I'm interested in working with Rust, but it's simpler for me to just use C++ rather than working against the grain.

Re: Ask HN: Learn C++11 or Rust in 2022?

#76

Earlier quoted context omitted.

I'm confused when people preach Zig and then safety in the same sentence. Zig has basically all the same problems that C++ has with a few extra bells and whistles. There are perfectly good reasons to like Zig, but it being "safe" is not one of them. > For example, this comes through in little things like Zig's extreme simplicity and explicitness "Simplicity" does not mean safety. In fact simplicity means you can't de…

> I'm confused when people preach Zig and then safety in the same sentence. Zig enforces correctness much more than C or C++ does (e.g. no implicit 'lossy' conversions, much stricter and enforced error handling, no implicit null, etc.), so it's completely fine to say that Zig is much safer than C or C++. The main difference between Zig and Rust is the borrow checker, but a lot of memory corruption issues in C and C++…

Except the little detail about sloppy use after free.

Re: Ask HN: Learn C++11 or Rust in 2022?

#77
Learn Rust, I write both and I find it and the tooling around it to be an absolute delight. It has a decent amount of traction and jobs too. It being relatively young I think this is the language in that space to watch.

Re: Ask HN: Learn C++11 or Rust in 2022?

#78
post #67

Here’s a fun way to decide. Do Raytracing in One Weekend[1] in one of them. Then rewrite it again in the other. That should give you a good sense for which one you want to invest in. Spoiler: I did this exercise myself. I found Rust to be more convenient in some ways. The Rayon crate made adding parallelism (threads) pretty easy. Some other crates made things pretty terminal output easier. C++ feels more familiar to…

I'm not ready to go back to C++ for this, but I know exactly what you're talking about regarding polymorphism. It's all magic and fairy dust for me, I'm really enjoying Rust. But once you want a dyn trait instead of a simple function, suddenly half of the magic doesn't work any more, and the language explodes into all riddles. (Interesting ones, I admit, and often there is some valuable insight at the end. But still a distraction.)

I guess as C++ veterans, we have to re-learn which approaches will work straight-forward, and which are the ones are asking for trouble. (I eventually found decent solutions for my problems that, while not the ones I had in mind initially, didn't require solving any hard puzzles.)

Re: Ask HN: Learn C++11 or Rust in 2022?

#79
In a word: Yes!

Learn Rust because it has things to teach. Learn C++ for what it has, too, and because it is the language work gets done in.

They are much more similar than different. Rust builds in prescribed solutions for what its designers have deemed the most pressing problems. C++ builds in more power for library designers to address what each considers the most pressing problems.

There is broad agreement on what are problems, but with different solutions. Both languages work. I personally find Rust unable to express what I want to write, but it is evident not everybody wants to write those things.

Knowing both will make you a better programmer in either.

Practically all of the highest-paid coding work is conducted in C++. That will be true for many years to come. More people pick up coding C++ professionally, in any given week, than the total paid to code Rust. That has been going on for years, and is accelerating: attendance at C++ conventions, and the number of them, is exploding.

So, keep up with C++, and keep an eye on Rust.

Re: Ask HN: Learn C++11 or Rust in 2022?

#80

Earlier quoted context omitted.

With C++ realistically memory management is so hard that if you want to go solo, and you don't want to debug segfaults all the time, Rust is definitely the way to go. It teaches you manual memory management like nothing else.

> With C++ realistically memory management is so hard Honest question as I'm not a C++ developer: Even with all the new C++17/20 stuff?

Problems with memory management are a fading memory when coding modern C++.

All the things Rust advocates insist cannot be done safely in C++ are now trivial. Use-after-free, leaks, buffer overruns, what-have-you, no longer need any attention to avoid if you stick to modern C++. Some people insist on coding as if it were C, and bring along all of C's failings. Leave them behind.

Post reply on HN