US government wants devs to stop using C and C++
theregister.com
theregister.com
Feds: Critical Software Must Drop C/C++ by 2026 or Face Risk (01.11.2024)
They miss the fact we aren't in 1980's any longer, Infosec and pentesting is standard procedure before deployment in many industries, insurances and companies now have a ball in the game regarding cibersecurity and nation state sponsored attacks.
But really, no, one could, but one won’t. It’d be easier to convince everyone to switch to Rust than to a safer C.
Any instance of undefined behavior in safe rust is a language or compiler bug. The only things you really need to check are unsafe blocks, which are rare enough to individually review line by line on a regular basis.
But I think a safe C that has similar guarantees as Rust is quite possible and we can gradually move there.
But frankly, if you’re going through all that trouble, it’s probably worth considering a newer language that fixes those things today. I mentioned Rust as one example, not the end-all solution to all problems. Nim also plays on the same space and it’s quite nice. The broader point is that I believe it’d be easier to start writing new code in a different language that can easily call existing C code.
First, all those new languages also have various downsides, and trade-offs, which may make them a less than ideal choice for many applications. Second, there are an incredible amount of existing C code. We will not get rid of C in the next at least 50 years even if we wanted to (not that I want to). Incrementally improving that code is far more useful than adding other languages into the mix.
In almost all cases for preconditions, that's solvable by better practices that could be identified in a review. It's the same underlying problem as C, but dramatically more manageable.
And of course, any C is liable to be misused in C++ where the committee's current position is that the problem is unsolvable.
You can't fix this with minor changes in the language or improved tooling. You need a complete overhaul of how the standards and implementations deal with UB.
If there were actually an appetite to eliminate it, I suspect we could probably eliminate 70% of J.2 with a few straightforward changes. Many of these aren't completely amenable to static analysis, like signed/shift bounds, but they're workable at the language level. The members of the C++ committee I've talked to were skeptical about the actual chances here though.
The rest of annex J is at least partially addressed with existing efforts like checked C and Coral ("constraints"), so at least there's a path forward with tooling.
Currently, all of that work has to come with a little asterisk saying "except for undefined behavior". I can't constrain where UB might be in the system, or how it might violate the safety model. In short, if I do my job properly I shouldn't assume C/C++ semantics at all. Obviously that's not reasonable, so everyone goes around pretending this isn't an issue to their safety models and their regulatory filings and so on.
Obviously I think that's wrong, but there haven't been ways to address it in C and C++. It's possible in Rust.
But I do not see how Rust helps? Rust has no standard and its reference implementation is subject to change. How did you convince yourself that what ISO C leaves not-standardized is any worse than what is not being standardized in the first place? There seems to be a double-standard here.
For example, Rust has an in-progress specification, here's the (currently empty) repo: https://github.com/rust-lang/spec. There's also MIR, a de-sugared internal representation that's sufficiently well specified to build formal models of (see https://github.com/rust-lang/a-mir-formality and https://github.com/rust-lang/miri), as well as the ferrocene spec (https://spec.ferrocene.dev/general.html) that's suitable for certification authorities (if not actually useful) and of course the rust reference/RFCs that are actually usable by people.
Plus, the fact that everyone in the rust community has standardized on one compiler and one package manager (for better or worse) means that the language team has a much better insight into specification breakages than the ISO process of languages like C and C++.
I can start writing stuff today and be confident that any changes will be minor if necessary when the language catches up.
I'm more than happy to have this discussion over email if you want to move it off HN, too.
Update: From your CVE "Clear warning that read ucode[] may out-of-bounds." So it seems this was catched by tooling.
Do you just mean, successfully make an OS? Because there are multiple examples of Rust based operating systems that are complete or nearly so.
Or by “successful”, do we mean that it is popular? Because popularity has rarely correlated with technical superiority in the past ( or present ). Windows is much more popular than Linux. Linux surged to popularity when FreeBSD was more complete and technically superior. Plan 9 has entered the chat.
Popularity depends on totally different skills and circumstances than technical excellence. Memory safety, performance, and security do not necessarily drive popularity.
What do we mean by success?
They should write an OS that is "so good" that people start talking about it as much as the options we have now, then people actually start using it on their servers (replacing GNU/Linux), then on their desktops. So good that companies like Google and Apple would consider making their next OSs or userland utilities in Rust.
It already happened for some programs like Alacritty, ripgrep but failed to do so in some other domains like user-space window managers.
The common argument against it is complexity and learning curve (compared to C).
Perhaps I'm not the one who should voice his opinion on this but anyway, I don't like _two_ languages in Linux kernel especially one that increases compile time and imposes heavy storage requirement on the development machine. If they want to add it, they should consider migrating everything to it IMO.
Is the proposal here to replicate the 30 million lines of code of Linux? Anything short of that is going to have massive adoption problems, much like Linux did in the past, much like FreeBSD/Illumos/etc do now, due to the lack of drivers. It took so long, and devices still don't properly support Linux; there is no way another free and open source system will take off like Linux did, ever again.
> failed to do so in some other domains like user-space window managers
Do things like Way Cooler and COSMIC not count?
I have seen Way Cooler mentioned as being used a couple times, and COSMIC gets regular coverage for its development progress.
Is that true? Is there somewhere to read up on that? Why Linux became more popular than FreeBSD especially?
Shame because I'm not opposed to a shift to Rust tools for safety's sake.
https://www.gao.gov/products/imtec-91-70br
Pursuant to a congressional request, GAO obtained information on the Department of Defense's (DOD) implementation of legislation which mandated using the Ada programming language for all software development, where cost-effective.Folks that play the Ada card don't get then issues regarding compiler prices for Ada, versus C and C++ free UNIX compilers (it was an additional license on UNIX SDKs), the hardware requirements, the salaries for devs with Ada skills, and yet those 7 companies manage to stay in business.
This misses the point. The point is to start moving in that direction, not instantaneously.
Literally anyone can call themselves a Software Engineer, which one the one hand is great because it's accessible, but also a curse in terms of making it a respected profession.
A better comparison would be "would I let someone who self-learned wiring up houses, and then spent five years working under an expert, before finally branching on his own, wire up my house". And the answer is yes.
Engineers have to be responsible for their work. If you held software engineers to that same legal standard, the occupation would be sued out of existence within a year, even for people who are doing everything possible to do it right.
Of course if they ignore a licensed engineer, they'd have their version of "Against medical advice" to sign off that liability to the company. Sure, there's still be unknown unknowns that come up and screw over the engineer, but I imagine a lot of the lawsuits would be redirected to the companies that prioritized shipping any kind of slop over all these engineering principles.
Especially in a world where disclaiming liability is the norm on all sorts of agreements, why should general software be different?
Software related to life safety tends to have real liability attached.
The gas cerified person gets repercussions because someone found leaks in the pipe fittings this certified person made. The leak is a smoking gun.
OTOH The software dev, certified or not, will not get repercussions because of their racey constructs, since it is much harder to point out they did not follow some certified procedure other than some (non airtight) tests and reviews before release. There's no smoking gun pointing to uncertified way-of-work. There's only this one in a million happenstance of a race condition making the system fail. That's where the common sense comes in, only that will prevent/solve possible race condition. There simply is no certified way about it like in pipe fitting.
I kinda sorta agree with you, but I see two immediate issues
1. There's such a variety of domains in software. And even in a domain you're always finding odd, unique problems that no test prepares you for. There's too many skills each domain needs to boil down to one universal test
2. The main reason I'd love a license is to cut down on interview gauntlets. But I'm too cynical to believe we still won't just end up with 4-7 stages of something else. Or even the exact same damm thing. What's the point of a license if no one trusts it over their cruddy beauracracy they call an "interview"?