Live data from Hacker News

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

news.ycombinator.com

61–70 of 156 posts

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

#61

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…

One thing that's nicer is that because Rust is a compiled language, Cargo produces a (statically-linked) binary. Python and your Python environment always needs to be set up on the machine that you're going to run it on.

statically-linked by default except for on Linux where it links to glibc dynamically by default IIRC, but going fully static there is easy, and going fully dynamic is easy too.

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

#62
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 tend to think carefully about lifetimes, resource ownership and writing secure code. I am careful with threading, use language idioms to enforce safety and also use tools (such as valgrind, but also static analysis) to check the code.

This is not as reliable as Rust's compile-time safety checks, but in practice it works well enough for me. I don't think this is typical for all C++ projects or programmers e.g. I am not particularly impressed by the (little) Firefox code I've seen.

I hope C++ continues to evolve safety features and get closer to Rust's guarantees. I don't think automotive or aviation will switch too soon.

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

#63
post #28
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…

To sit on the sidelines and wait till the technology and market matures is a smart decision. There's a lot of new things popping up, and not everything sticks. This is particularly true if you're running a business and you need to pick the right tech. Learning a new language though is not a wasted effort, even if eventually the language becomes obsolete. It only takes a few days to get going with something new, and t…

But one doesn't pick what to learn just between several languages, in fact I think they're a pretty poor investment after a certain count. When learning Obj-C I didn't get much out of it. I like several Swift idioms, but it was hardly worth it to learn a language for that.

In contrast I finished an architecture course recently that I expect will bring me 10x value of knowing both of the above languages.

Please see my answer to vvanders regarding interest vs industry interest.

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

#64
post #30

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 have just a couple of points. First, please be careful with the "experts" broad brush. Not all, and possibly not most, experts will agree on many things. Moreover, actual experts will understand that there are pros and cons that are context dependent. I would hesitate to label as "expert" anybody who categorically prefers one over the other for all cases. That's more like zealotry than expertise. Second, for my par…

The Rust team puts a lot of effort into not gratuitously maligning anything, including a "competitor" language like C++: discussions of other languages try to be as factual as possible, and, Rust is very happy to adopt the good ideas of them (and of course acknowledge this), e.g. Rust's closures are modeled after C++11's lambdas.

As with anything, some people who like Rust might get a bit enthusiastic about discussing its benefits compared to other languages, but this is frowned upon and IME usually called out, especially in spaces with some sort of "official" Rust moderation presence.

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

#65
post #7

Earlier quoted context omitted.

Do you mean C/C++ and Rust interop? Maybe link them together to form the final executable binary? Can you share more experience on how do you do that?

Rust produces standard linkable system libraries. You can produce dynamic libraries or static libraries on all supported platforms. For actual examples of using Rust with other languages through these libraries this site is great: http://jakegoulding.com/rust-ffi-omnibus/

More information about platform support can be found here: https://doc.rust-lang.org/book/getting-started.html

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

#66
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…

Whatever happened to learning something to broaden your view? I doubt I'll get a job in Clojure anytime soon - but learning it has been the biggest eye opener to me as a programmer in the last 5 years. > The answer to all these questions seems to be "no". In conclusion you shouldn't be learning it and good luck to the company trying to hire people for Rust positions? You're saying you should only learn what the indus…

Learning something to broaden my view is one of my favourite things to do. Except "something" is not a programming language.

If there's a worthwhile project that I want to contribute to, I will learn Rust. At least in automotive the industry is not necessarily pushing towards specific tools, they have constraints that limit choices to particular languages.

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

#67
post #55

Earlier quoted context omitted.

Sorry but that's bullshit. C++ is just a dinosaur plagued with issues inherited by design decisions made before most of people here were born. Trying to replace it has nothing to do with looking for a perfect language. Rust could have absolutely 0 memory safety features over C++ and it would still be a massive improvement over the mess that is C++ package management and build systems with Cargo. Same is true for many…

That would be true if changing programming languages or adding new languages would be zero-cost. Then we could iterate fast to some close-to-ideal language. This black and white thinking is just a sign of immaturity, not of knowledge of a deeper truth. All mainstream languages are capable of delivering business value. I happen to prefer certain characteristics that led me to C++, but I also found Java to be quite fin…

I don't hate C++, saying rust offers nothing other than memory safety is just wrong, just by being a modern language with zero cost abstractions with stuff expected of modern languages such as modules, package management, sane build system, potential for lower compile times, etc. It's not hard justifying costs of migration when considering C++ problems if something replaces it adequately. Rust has the potential to do that.

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

#68

Earlier quoted context omitted.

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…

Ah, I see. The main difference I can see is that it's opinionated, because everything else can be done by pip too (you can install utilities right in your path with it).

I agree that being opinionated is a big help. Everyone in Python-land uses virtualenv and pip, but it would be great if (as is actually happening now), they were bundled with the language and were the One Blessed way of creating a new project:

virtualenv myenv

source env/bin/activate

pip-compile requirements.in

pip-sync requirements.txt

Rust does get a few benefits from being statically linked, but yes, I see now that people compare cargo to mostly C/C++ tooling, and not to something like Python, thank you.

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

#69

Earlier quoted context omitted.

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`.

First of all, I agree that cargo blows the C/C++ tools out of the water in terms of ease of use. But I think it's even easier than newer stuff too. It's by far the best dependency manager I've used. I haven't used pip-tools, but I have used pip, npm, bower, and other more modern dependency mangers that work for non-systems programming languages. Cargo has never given me any trouble. Pip has occasionally given me weir…

Hmm, I've had problems with npm too, but none with pip. The trick there is to make sure you're working in the virtualenv of your project, by activating it or using something like virtualfish or the bash equivalent (virtualenv-wrapper, I think).

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

#70

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 still work regularly on C++0x11

... but that's not due for another year!

Post reply on HN