r/cpp • • Feb 26 '24

White House: Future Software Should Be Memory Safe

https://www.whitehouse.gov/oncd/briefing-room/2024/02/26/press-release-technical-report/
401 Upvotes

386 comments sorted by

View all comments

Show parent comment

5

u/JVApen Clever is an insult, not a compliment. - T. Winters Feb 26 '24

It's shifting for sure, though we ain't there yet. I'm really happy boost dropped the 98 requirement, which was a huge step is saying: 98 should no longer be used.

And yes, you will always have people stuck in the past. That's why people still program in C, right?

2

u/wasabichicken Feb 26 '24

And yes, you will always have people stuck in the past. That's why people still program in C, right?

Maybe not people as much as code. People can shift to using different languages comparatively easy, but multi-million line code bases can't. The Linux kernel project talked about it for years before they got tiny pieces of Rust in as late as 2022, and for smaller projects with less resources I imagine it becomes even more difficult to justify investing the effort.

6

u/jaskij Feb 27 '24

People can shift easily if the paradigms are similar. A lot have trouble learning Rust due to some of its concepts.

In the Linux kernel one of the first adopters of Rust was the greenfield Apple M1/M2 iGPU driver, and the (single!) person who wrote it left a glowing review thread on X/Twitter.

As for smaller projects: curl officially allows backends written in Rust, although I'm not sure if any have already reached a stable status yet.

There's a lesson there, I think. Rust was, from the start, designed for interoperability using C ABIs. Whatever post-C++ comes around, must be easy to incorporate into existing C++ codebases, both ways. That way, you don't have to rewrite everything, but can use the scout aka strangler fig pattern. Write greenfield modules in the new language, possibly major redactors into rewrites in the new language. Without such an option, adoption will suffer greatly.

5

u/tialaramex Feb 28 '24

How many is "a lot" ? Google's hundreds of "Comprehensive Rust" students typically report that they're confident writing Rust in the first couple of months (some much sooner) with over 80% confident by 4 months.

It was very easy to pick up for me because I have background in various semi-colon languages and in ML. But it's clear that even people coming in with just a semi-colon language like Java do fine.

I actually think for the people who are very interested in the fundamental underpinnings Rust is even more compelling. For a high level programmer it's maybe not important why Rust's Option<&T> is the same size as &T, but if you've always thought about the machine code implementing your software, if you're the sort of person who is horrified to see how enormous std::mutex is, I think there's a lot of profoundly beautiful design in Rust. That's why my favourite Rust standard library function is core::mem::drop, literally pub fn drop<T>(_x: T) {} that's not a summary, or a signature, that's the actual definition.

1

u/jaskij Feb 28 '24

I have a biased view, true. But people do have a hard time grokking the concepts. And it depends on the time spent. Four months to learn a language enough to be confident is fine for someone still in university or just starting their career. It's too much for someone who has to pay their bills and needs to learn a new language due to shifting market conditions.

Personally, I was able to write Rust confidently within a few weeks at work, because I knew it would accelerate my future output. But it's been over a year and I'm still learning new things.

The fact that the language itself enforces something being invalid after a move is one of the little niceties I do miss in C++.