Live data from Hacker News

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

news.ycombinator.com

151–156 of 156 posts

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

#151
post #66

Earlier quoted context omitted.

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.

Not that long ago, the idea of trying to get into the automotive industry with a web background would have been laughable. Now, I frequently get inquiries from auto companies interested in my JavaScript experience, despite the fact that I left the Detroit area a few years ago. Even the auto industry changes when faced with a better way to do things, and its constraints actually seem to align well with Rust's core des…

They will use JS where it makes sense, e.g: web UIs to drive some background components. These are new projects.

Let's see if that first mover decides to show up.

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

#152
post #62

Earlier quoted context omitted.

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…

>I tend to think carefully.. What about a team? If you are leading a team of programmers, would you rather use Rust (where finding if the code is doing anything unsafe using a simple grep) or C++ where finding dangerous code is a lot harder? I think the point of using langauges like Rust and Haskell only comes into play when the development is done by a team. It is one thing to hope that every one in your team is as…

Depends on the team. If they're not experienced writing safe C++, I'd go with a safer language (e.g. Java) or teach them if that's not possible. But this also depends a lot on the project, usually it's the case that C++ is the only option available.

We can't start using any languages we want, we have to consider industry standards, resource availability and other constraints.

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

#153
post #87

Earlier quoted context omitted.

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

And it sounds like he works in the auto industry. This is pretty depressing that the paycheck weighs more heavily than the safety factor. Toyota killed people with their bad code.

From the little that I know, safety-relevant code might be modeled in a high-level language that generates C. I don't work directly on safety-relevant features, but I'm sure there are other processes and practices in place.

Some bad news for you though: all automotive companies typically use the same tools and processes. Aviation is also like that. And they use a ton of C and C++.

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

#154

Earlier quoted context omitted.

It is not already faster and there are benchmarks that proves that. Check out of the The Computer Language Benchmarks Game, for example. Lots of language communities make the claim that "their" language either is or will eventually be faster than C. Haskell, Julia, Go, Java, Swift... But the proof of the pudding is in the eating and so far none of these safer languages has beaten C.

There's been a lot of variance on the benchmark game lately since things are so close; a couple of months ago, Rust was #2 overall, beating out C++ and just a tad slower than C. The areas where Rust lost the most were because explicit SIMD isn't stable yet. We also upgrade LLVM regularly, and that can cause some fluctuations from time to time. (Rust is currently beating C on one benchmark, within a few tenths of a se…

> The areas where Rust lost the most were because explicit SIMD isn't stable yet

That was last year, before rustc 1.0.0-alpha

> There's been a lot of variance on the benchmark game lately

With Swift, because programs written for Swift 2.0 failed with Swift 3.0

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

#155
post #82

Earlier quoted context omitted.

Probably because people with experience know how to handle these things up front so that they don't occur. I've been writing C and C++ for a decade now and for the last 6 years or so i have had very few issues which stem from any of the things you mention.

> Probably because people with experience know how to handle these things up front so that they don't occur. bla bla bla. especially if you are dealing with a large code base with shifting requirements, where the code has been written over a long time by a lot of people; in a real world system you just can't make these assumptions regarding 'skill' at all. Even skilled people will have to deal with issues like invali…

another example that i had the other day: lets say you have a cache of some sorts, now you keep adding entries to the cache without deleting them, in the end it blows up because it is out of memory. Now technically it is not a leak, but the result is that of a leak.

Now good luck solving that with smart pointers and reference counting, etc.

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

#156
post #153
post #87

Earlier quoted context omitted.

And it sounds like he works in the auto industry. This is pretty depressing that the paycheck weighs more heavily than the safety factor. Toyota killed people with their bad code.

From the little that I know, safety-relevant code might be modeled in a high-level language that generates C. I don't work directly on safety-relevant features, but I'm sure there are other processes and practices in place. Some bad news for you though: all automotive companies typically use the same tools and processes. Aviation is also like that. And they use a ton of C and C++.

We had our chance and lost it, the DoD was doing great things with Ada. But 1) the compilers sucked 2) they were hard to get ahold of and 3) there wasn't nearly as much training material on how to use Ada well. Then the DoD acquiesced on Ada and permitted embedded dev in C/C++.

I am totally fine with a high level tool emitting C. C is a fine portable target. But the high level system should pass some provable rigor.

Post reply on HN