Live data from Hacker News

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

news.ycombinator.com

21–30 of 156 posts

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

#21

I find this comparison much easier than comparing C and Rust. C has an extensive and still unparalleled set of libraries available using the C calling conventions; both C++ and Rust can call those libraries but often want a translation layer that adapts to the conventions of the language. C++ and Rust both have extensive libraries of their own; while C++ has been around longer, you'll still often find yourself needin…

>> I prefer a smaller language with a large library ecosystem

I think this is the reason why Java is so popular and Go is becoming increasingly popular. The average programmer can succeed with combination and become productive faster.

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

#22
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 don't think you can unequivocally dismiss Rust, we've seen Dropbox and other companies pick it up(just yesterday Facebook announced a Mercurial alternative written in Rust).

As with each case, it depends. If you've got a well scoped project that is happy with a C ABI(or just stand alone exec) I think there's a compelling case for Rust.

I'd also argue if you're looking for top candidates having Rust in-house could be a perk rather than a negative.

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

#23
post #3

This is all personal opinion so take it with a grain of salt. I think Rust could do some serious C++ competition if it could dethrone C++ from some platform or have a worthy alternative. That is I think Rust really needs a killer app/platform/problem similar to how Swift has Apple devices and DevOps now have Go. If Rust could get into a gaming platform or have a really good gaming library like Unity it could have a g…

Regarding microservices; it's my hopes https://github.com/fractalide/fractalide moves into this space.

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

#24
post #7
post #5

I have a big C++ legacy code, and it gives me a lot of headhaches. I'm using Rust in some small projects and it's great, no problens with null pointers :). I think a great feature of Rust is that it is easy to use inside C/C++ projects, so u can upgrade your current legacy code without rewrite it :)

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?

linking a static lib with rust and linking with the final executable. other users posted the links I used :)

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

#25
post #19

Rust has been pretty critical to me for getting my work up and running with minimal debugging (I'm in CS grad school, working on deep learning and optimization). I'm super productive programming in Rust, which is also generally a pleasure to write in. Just last week I had to land a pretty major refactoring (swapping out a single wrapper type for a differentiable "operator" with an implicit operator graph instead). It…

Curious since you say you work on deep learning/optimization. I'm a data scientist who does most everything in Python, but I've been interested in learning Rust. What is the state of "data science" toolkit for Rust at this point? For reference, I regularly use sklearn, Pandas, and Spark and would be looking for similar tools.

I'm not sure that there's a mature Rust alternative to "all of the above" quite yet. Some things that I've had to build for my own work (not always "built," sometimes I just wrote FFI bindings) include:

* N-D dense arrays, fashionably simply called tensors these days ;) (this I wrote from scratch to suit my own needs, but there are several implementations of this in Rust, as well as in C++)

* linear algebra (bindings to BLAS, LAPACK etc.)

* numerical integration (bindings to GSL or QUADPACK)

* optimization and machine learning (this I work on day-to-day)

* neural networks (I also work on this)

* multicore/manycore/GPU/distributed support (and this)

There's also the more practical aspects of using Pandas/iPython (Jupyter)/Spark for data science, including ETL, interactive work, and plotting, which IMO are not quite there yet in the Rust ecosystem. But I think that a lot of the pieces are there, e.g. bleeding fast CSV parsing libraries (https://github.com/BurntSushi/rust-csv), and what's left is the important last mile of bringing these things together in ergonomic libraries or frameworks.

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

#26
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 don't think you can unequivocally dismiss Rust, we've seen Dropbox and other companies pick it up(just yesterday Facebook announced a Mercurial alternative written in Rust). As with each case, it depends. If you've got a well scoped project that is happy with a C ABI(or just stand alone exec) I think there's a compelling case for Rust. I'd also argue if you're looking for top candidates having Rust in-house could b…

To be more accurate, they didn't announce an alternative to Mercurial, but rather new Mercurial server software.

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

#27

Earlier quoted context omitted.

I don't think you can unequivocally dismiss Rust, we've seen Dropbox and other companies pick it up(just yesterday Facebook announced a Mercurial alternative written in Rust). As with each case, it depends. If you've got a well scoped project that is happy with a C ABI(or just stand alone exec) I think there's a compelling case for Rust. I'd also argue if you're looking for top candidates having Rust in-house could b…

To be more accurate, they didn't announce an alternative to Mercurial, but rather new Mercurial server software.

Yup you're right, I should have been a bit more explicit there, meant to say backend replacement.

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

#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 the lessons learned are useful regardless of if you use the language in the future or not.

But to say that there's no interest at all is pretty ridiculous, and there's plenty of people looking at rust and deploying it. That last statement made me feel you might just be a bit burnt out by change in general. Don't lose perspective. Going out of your comfort zone might be exactly what you need.

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

#29
post #12

Earlier quoted context omitted.

Like all legacy code, it will not be replaced. Now if people wanted to bifurcate their codebase they can easily add Rust libraries to existing C++ codebases. In my experience I find Rust to be more productive than C++ and easier to write. Obviously that's a pure opinion.

I do agree with you, and I hope this is the future. However, in big organizations, which are not exactly nimble, this is even hard to say, "Okay we've been developing in C++ for 20 years, now the next part of our infrastructure will be written in Rust". This will be seen as an unwanted risk, associated with a training cost. You will have to demonstrate unequivocally Rust's advantage.

Yes, companies that don't want happy employees make these types of monetary decisions. It's their responsibility to their shareholders to do this. It comes at the expense of long-term support of their software though.

There are long lists of dead languages still in legacy systems, C and C++ aren't there yet, but I think they are headed that way.

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

#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 part the biggest hurtles are in two parts. One is that at the boundaries of speed versus provable safety. At some point I don't need and can't afford the cycles added by boundary checks and other Rust guarantees, and the mechanisms provided to mitigate them are as cumbersome as writing (unprovably) safe C++ code (e.g. "const&", "std::move" and other similar constructs) compared with the equivalent Rust. The other is a more a branding problem: gratuitous maligning of C++ is problematic, and projects a sort of arrogance that I find subjectively distasteful.

Post reply on HN