Live data from Hacker News

Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

news.ycombinator.com

71–80 of 92 posts

Re: Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

#71

Earlier quoted context omitted.

I'm approaching this from an enterprise perspective of "how confident am I that this code is safe and correct?" If you hand me a pile of c++03 code that happens to compile, my confidence in it meeting both of those criteria is fairly low. If you ask the standards committee or bjarnes, what they're going to tell you is to rewrite it in modern C++, which constantly evolves. Contrast that with rust where it's probably f…

> standards committee or bjarnes, what they're going to tell you is to rewrite it The same will be true for Rust in 50 years (assuming Rust doesn't die any time soon). If they didn't think it was worth modernizing, they'd just leave C++ alone (which I think they should, but that's another matter). For old C++, you run valgrind and a linter on it and if nothing comes up it's also "probably fine". At least it's hard fo…

Would you bet your life/money/application security on valgrind and a linter being sufficient to catch all of those issues, knowing that a single mistake invalidates every guarantee the standard gives you? That's the situation we're in with C++.

When you're building old code, the compiler can't check that it upholds the standard to the degree that it can for modern C++. That's why the advice is to update the code, because the tooling can't save you otherwise.

Rust by contrast guarantees that you either have a compiler/runtime bug or the issue is more narrowly localized than "potentially every single line of code". Sure, I'd like better, but it's an improvement.

Re: Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

#72
post #58

I am a retiring engineer/entrepreneur. I made a lot of money with C++. It is hard for me to tell anyone not to use it. I recently developed an oil and gas derivative tool in Rust. IMO Rust has a long way to go. It reminds me of OCaml. I spent 2 years developing a Compliance System on DEC/OSF1 in OCaml. We made the mistake of adopting that language too early. Also, the C++ community is a lot more tolerant. A big plus…

> Also, the C++ community is a lot more tolerant. A big plus for C++. Well I completely disagree with this. The C and C++ communities seem to me personally to be a lot more "elitist", engaging in extreme pedantry or dunking on each other over knowing obscure language trivia. Both the language and the community are beginner-hostile in comparison to Rust. Not that the Rust community is perfect, because it's obviously n…

This echos my personal experience as well.

I would also add that there now seems to be more of an emphasis around being intentional in how languages foster community. The C and C++ communities (in my opinion) became how they are not by design, but mostly by accident or chance.

Re: Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

#73
post #20

Rust has a method for enforcing better memory safety. That is great for deployed applications, but can be annoying when you’re still exploring / mutating your code to figure out the right shape of things.

I have never had the experience that being precise about what I mean slowed me down, if anything it was the opposite.

because sometimes you don't know precisely what you mean. if you don't already know the shape of your solution the 'safety' features restrain you.

Re: Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

#74

Earlier quoted context omitted.

> standards committee or bjarnes, what they're going to tell you is to rewrite it The same will be true for Rust in 50 years (assuming Rust doesn't die any time soon). If they didn't think it was worth modernizing, they'd just leave C++ alone (which I think they should, but that's another matter). For old C++, you run valgrind and a linter on it and if nothing comes up it's also "probably fine". At least it's hard fo…

Would you bet your life/money/application security on valgrind and a linter being sufficient to catch all of those issues, knowing that a single mistake invalidates every guarantee the standard gives you? That's the situation we're in with C++. When you're building old code, the compiler can't check that it upholds the standard to the degree that it can for modern C++. That's why the advice is to update the code, bec…

> Would you bet your life

Definitely not. But it's rare that so much is at stake. I would not bet my life on the borrow checker either, there's a lot of things that can go wrong in a program.

Money is of course a question of how much. Application security is just "the above". The "undefined behavior can explode your PC, travel back in time and become your father" problem is not to be underestimated. However, in cases where old code works well for years but really has some lurking bad UB, one can disable some optimizations and be conservative with compiler choice. A lot of people dislike the trend towards compilers being ever more punishing of UB and I can see their point, while it's of course hard to argue for (let alone find) a balance between performance and some robustness to ubiquitous and almost inevitable code issues.

Rust's giarantees are nice and I sure would prefer working on a modern Rust project than any C++ project, as well as a modern C++ project compared to C99-with-classes. Modernizing existing code is a different matter. I've seen very few attempts at modernizing a big and old C++ codebase, no attempts where it clearly paid off and one attempt where it went wrong...

Re: Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

#75
post #66

Earlier quoted context omitted.

Rust has good FFI with C++ meaning that you can write Rust libraries that are consumed by C++ programs. C++ developers understand all of the concepts needed to easily pick up Rust. As long as it's not a quick project that will be immediately thrown away getting C++ to use Rust will be worth it.

Rust has good FFI with C, and do does C++. The Rust C++ FFI experience is still a bit rough.

even C++ C++ is rough as soon as you're dealing with object code...

Re: Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

#76
post #68

Some arguments in favor of C++: 1. Much faster compilation speed. 2. Having to syntactically specify ownership is annoying and a waste of time in many cases. Unless you need the hand-holding, but then low-level programming isn't for you. :P 3. Multiple compilers. Ironing out bugs is easier when you have both clang, gcc, and msvc. 4. Valgrind and other tools for debugging, profiling, and analysis. 5. Personally, I fin…

3. and 4. sound a bit like like "For C++ you have nice tools that solve problems that don't arise with Rust in the first place"

Re: Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

#77
As a random datapoint I learned recently the Solana blockchain consensus software, written in Rust and notorious for absolutely dismal performance, is being completely rewritten…in C.

I’m curious if they’ve thought that through as it introduces an entire class of bugs Rust inherently protected them from previously.

> Firedancer is written in C, in contrast to the Rust codebase of the original Solana validator

https://firedancer-io.github.io/firedancer/guide/firedancer....

Re: Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

#78

Earlier quoted context omitted.

I'm approaching this from an enterprise perspective of "how confident am I that this code is safe and correct?" If you hand me a pile of c++03 code that happens to compile, my confidence in it meeting both of those criteria is fairly low. If you ask the standards committee or bjarnes, what they're going to tell you is to rewrite it in modern C++, which constantly evolves. Contrast that with rust where it's probably f…

> standards committee or bjarnes, what they're going to tell you is to rewrite it The same will be true for Rust in 50 years (assuming Rust doesn't die any time soon). If they didn't think it was worth modernizing, they'd just leave C++ alone (which I think they should, but that's another matter). For old C++, you run valgrind and a linter on it and if nothing comes up it's also "probably fine". At least it's hard fo…

> If they didn't think it was worth modernizing, they'd just leave C++ alone (which I think they should, but that's another matter).

What about C? That's being modernized too, sometimes with novelties from C++ modernization, like `nullptr`! :p

https://www.open-std.org/JTC1/SC22/WG14/www/docs/n3042.htm

Re: Ask HN: Are there any good reasons to use C++ over Rust for new projects today?

#79
post #68

Some arguments in favor of C++: 1. Much faster compilation speed. 2. Having to syntactically specify ownership is annoying and a waste of time in many cases. Unless you need the hand-holding, but then low-level programming isn't for you. :P 3. Multiple compilers. Ironing out bugs is easier when you have both clang, gcc, and msvc. 4. Valgrind and other tools for debugging, profiling, and analysis. 5. Personally, I fin…

3. and 4. sound a bit like like "For C++ you have nice tools that solve problems that don't arise with Rust in the first place"

That's the price you pay for #1. ;D
Post reply on HN