Live data from Hacker News

Ask HN: What is the state of C++ vs. Rust?

news.ycombinator.com

41–50 of 156 posts

Re: Ask HN: What is the state of C++ vs. Rust?

#41

Long time C++ dev here(~15 years) currently loving Rust. Someone can probably put together a more eloquent comment however here's my top marks. 1. No memory corruptions/null pointers. Legit holds up to the promises here. 2. The path of least resistance is single-ownership which is far and away the best way I've seen to structure C/C++ applications. 3. Cargo: Pure awesome. Simply one of the best dependency management/…

I've only used Rust lightly, but can someone explain what Cargo does differently from pip-tools? As far as I can tell, you have two files in both systems: One with the dependencies you'd ideally like to use, and one with the ones you actually used (and tested with). That way, you can update when convenient, but people who get your software have an exact known good environment. What makes Cargo that much better than p…

When people talk about `cargo` being awesome, they're comparing it to the similar tools for, say C++ or C or other systems programming languages. No one is comparing `cargo` to `pip-tools`.

Re: Ask HN: What is the state of C++ vs. Rust?

#42
post #2

Rust is promising but C++ is here to stay. If you have a legacy C++ code base, it is much easier to sell that you are just upgrading the compiler to get new language features, that you are rewriting everything from scratch. Now we'll have to see in the next few years if, for new projects, Rust is chosen over C++ wherever it was used traditionally and in which proportion.

I think culture will do its thing here.

Getting into C++ now is harder then getting into Rust.

Re: Ask HN: What is the state of C++ vs. Rust?

#43

Long time C++ dev here(~15 years) currently loving Rust. Someone can probably put together a more eloquent comment however here's my top marks. 1. No memory corruptions/null pointers. Legit holds up to the promises here. 2. The path of least resistance is single-ownership which is far and away the best way I've seen to structure C/C++ applications. 3. Cargo: Pure awesome. Simply one of the best dependency management/…

I've only used Rust lightly, but can someone explain what Cargo does differently from pip-tools? As far as I can tell, you have two files in both systems: One with the dependencies you'd ideally like to use, and one with the ones you actually used (and tested with). That way, you can update when convenient, but people who get your software have an exact known good environment. What makes Cargo that much better than p…

I'm not super-familiar with pip-tools however I'll try and explain what I like about Cargo.

You're right on the dependencies, there's a lock file to make sure you get the exact build environment. So from a dependency management perspective it sounds similar.

What I like about Cargo is it's just slightly opinionated about how you want to build a Rust project. Creating a new project is as simple as "cargo new myproject" and boom, away you go. Same thing with unit testing, running all tests in a Rust project is as simple as "cargo test".

If you've worked on a moderately large C/C++ codebase you'll know that those two things alone can be a huge source of annoyance.

It also makes it really easy to install Rust-based tools like racer/rustfmt/etc with "cargo install " which pulls the source, builds and puts the executable on your path.

In short, all the annoying stuff around project management that in C/C++ is neatly handled into a few short commands. In my mind it's a huge productivity win.

Re: Ask HN: What is the state of C++ vs. Rust?

#44
post #14

They are both great languages but rust is clearly the one that experts in both generally prefer. I have some friends who make some strange arguments for c++ but I continue to be interested why people don't want to make the switch. That being said LEGACY

I would be careful about what you generalize from "experts in both generally prefer rust", as there is likely a survivor bias in there. Since C++ has been around much longer the situation is likely "many C++ experts try Rust, the ones that love it become Rust experts", basically if "preferring Rust" ends up being a soft prerequisite to becoming a Rust expert then those who are experts in both will prefer Rust. I also…

> not necessarily through any intrinsic benefit of the language, instead through a selection of who is writing that language

I'd say that such selection is intrinsic benefit of the language.

Re: Ask HN: What is the state of C++ vs. Rust?

#45
post #18

Wrong place to ask the question. HN has a high proportion of people with an unusual interest in trying out programming languages and I would say the average visitor doesn't particularly like C++. From my point of view, Rust doesn't offer any benefits that would justify a switch. I would lose a lot of experience, libraries, a mature stable platform and job opportunities in exchange for more memory safety - something t…

> I would lose a lot of experience, libraries, a mature stable platform and job opportunities in exchange for more memory safety - something that's not a particularly pressing issue for me.

May i ask why memory issues are not a pressing issue for you? having to hunt down memory corruptions / access to dangling pointer / memory leaks is a pretty frequent occupation for me (as a C/C++ developer). There are tools like valgrind that help, but well, it is a pain to deal with these issues.

Re: Ask HN: What is the state of C++ vs. Rust?

#47
post #44
post #14

Earlier quoted context omitted.

I would be careful about what you generalize from "experts in both generally prefer rust", as there is likely a survivor bias in there. Since C++ has been around much longer the situation is likely "many C++ experts try Rust, the ones that love it become Rust experts", basically if "preferring Rust" ends up being a soft prerequisite to becoming a Rust expert then those who are experts in both will prefer Rust. I also…

> not necessarily through any intrinsic benefit of the language, instead through a selection of who is writing that language I'd say that such selection is intrinsic benefit of the language.

I just meant to point out that if broad usage actually implies worse average code, then the same thing would happen if rust "wins". You can't use it as an argument for what should win since "has won" will always lead directly to a "shouldn't be winning" argument.

Re: Ask HN: What is the state of C++ vs. Rust?

#48
post #31
post #18

Wrong place to ask the question. HN has a high proportion of people with an unusual interest in trying out programming languages and I would say the average visitor doesn't particularly like C++. From my point of view, Rust doesn't offer any benefits that would justify a switch. I would lose a lot of experience, libraries, a mature stable platform and job opportunities in exchange for more memory safety - something t…

* can I get a good job programming in this? Without moving to another country or continent. Yes, there are many large companies which are either actively deploying Rust, or planning to. Easily found if you search. * is my industry showing interest in it? Yes: security, high reliability, availability and safety oriented industries. Any industry looking to get themselves out of the entrenchment of C/C++ but still needs…

Find me an interesting job in Stockholm requiring Rust and I am your man!

Re: Ask HN: What is the state of C++ vs. Rust?

#49
> But then there is the idea of ignoring legacy C++ and treating Modern C++ as a new language altogether.

There is no "ignoring legacy C++", when you will have to deal with this or that library written 10/15 years ago. C++ is a language where you can't just ignore some parts of it just because they are inconvenient.

As for C++ vs Rust, Rust is memory safe, C++ is not and will never be despite all the bells and whistles it gets.

Re: Ask HN: What is the state of C++ vs. Rust?

#50
post #18

Wrong place to ask the question. HN has a high proportion of people with an unusual interest in trying out programming languages and I would say the average visitor doesn't particularly like C++. From my point of view, Rust doesn't offer any benefits that would justify a switch. I would lose a lot of experience, libraries, a mature stable platform and job opportunities in exchange for more memory safety - something t…

> I would lose a lot of experience, libraries, a mature stable platform and job opportunities in exchange for more memory safety - something that's not a particularly pressing issue for me. May i ask why memory issues are not a pressing issue for you? having to hunt down memory corruptions / access to dangling pointer / memory leaks is a pretty frequent occupation for me (as a C/C++ developer). There are tools like v…

I don't think that bulb ever dismissed entirely the idea of learning Rust for fun or for acquiring knowledge, did he?
Post reply on HN