Live data from Hacker News

C isn't a hangover and Rust isn't a cure

scribe.rip

1–10 of 20 posts

Re: C isn't a hangover and Rust isn't a cure

#6
The reason why Rust and other languages have bounds checking that approaches C’s speed is less to do with the compiler being able to prove away bounds checks and more to do with those languages making the bounds easy to carry around.

Bounds checks themselves aren’t that expensive, if you already have the length to check against in a register or some other convenient spot.

And - if the bounds are convenient to find and known to be immutable then it does make it easier for the compiler to eliminate those checks using the same techniques it would use to eliminate all kinds of redundancies. C has many redundancies that we don’t have to think about because they’re straightforward for the compiler to reason about.

Re: C isn't a hangover and Rust isn't a cure

#7

The reason why Rust and other languages have bounds checking that approaches C’s speed is less to do with the compiler being able to prove away bounds checks and more to do with those languages making the bounds easy to carry around. Bounds checks themselves aren’t that expensive, if you already have the length to check against in a register or some other convenient spot. And - if the bounds are convenient to find an…

You'll have to enlighten me on how Rust makes passing bounds any easier. Spans and views are pretty common in C++ and C codebases these days.

Re: C isn't a hangover and Rust isn't a cure

#8
I'm really excited to see something like Xr0 https://xr0.dev/learn get some traction. Feels like the best of both worlds. You a low-level language with optional safety guarantees. Especially for legacy code bases that shouldn't be replaced, Xr0 would be gold. I love Rust, and it does so much more than just memory safety, however there is a place for C if the memory safety can be fixed.

Re: C isn't a hangover and Rust isn't a cure

#9
Feels like most people reacting to this think it's about C vs Rust. And part of it is, but the bigger conclusion is: If you're starting a new programming project, you probably shouldn't be using a systems language at all. Go, Java, C#, Swift, Python, or Ruby are probably better choices for most projects.

Go in particular has a lot of the advantages of C/C++ and Rust--fully-compiled binary, easy access to system calls, high performance--without the overhead of needing to constantly think about memory management.

Re: C isn't a hangover and Rust isn't a cure

#10
"Academia stopped teaching C++, moving to Java and then to Python."

There are a lot more practical and lucrative skills for a young programmer to focus on than C or C++. Many will be able to have good careers without going that low level.

What impact will that have on the economics of legacy C/C++ code bases in the 15-30 year time frame?

Post reply on HN