Better HN
topnewbestaskshowjobs
Log inSign up

thomashabets2

1,012 karma · joined Jan 19, 2015 (11y ago) · 406 submissions

https://blog.habets.se
Submissions

comment 2w ago · link · parent

It's a different model of development. One that doesn't invite collaboration outside full timers, or "committers".

SVN is CVS done right, but since the model is inherently ineffective for open development, you can't simply fix it.

They appear to be doing some NIH with "got" (https://gameoftrees.org/) but it's so aggressively uninviting (see the FAQ) that I don't want to spend any time looking at it, if they don't want me.

comment 2w ago · link · parent

> There's no fundamental reason why all the checks applied by say, a Rust compiler, couldn't be applied to a piece of C code.

I've certainly thought about how to improve my C++ after internalizing Rust. Unfortunately I've come up with very little. For every implementation of a Rust safety, I've come up with a way to easily (accidentally) break it.

So in the language, while I'd love to see it, I'm not so sure.

Now, if we can just get "a sufficiently smart compiler", then that'd be great. But that's rarely how that works. (cf. https://wiki.c2.com/?SufficientlySmartCompiler)

I've not looked much at formally proven code, but for such code, sure. Note that there are plenty of examples of bugs in formally verified code, too. Partly this is because one formally verified the wrong thing. And aside from that I understand that there are reasons you can't "just" add formal verification to whatever project you have.

Maybe AI can write prefect assembly directly. Then we can all stop arguing about languages.

But in any case, if you want to make the case against my "nobody can write safe C" (or C without UB), and the argument is that they can, if an AI verifies every line. Then yeah, sure. But 1) who was actually writing the code, then? And 2) to the extent that the human was involved in writing the C, they probably made things worse, not better.

Even for AI coding C, there just needs to be one missing thing in the LLM's context, and a buffer could overflow. But for whole classes of bugs (though not all), the difference between Rust-without-unsafe and formally verified doesn't matter. I.e. you don't need formally verified against memory safety if it compiles, and there was no `unsafe` use.

> Gotta have developer velocity, right?

Not having AI at least review the code delta before pushing a release I would say is misconduct, today. It's the equivalent of editing your Perl cgi-bin in an editor live on the production server. That's not "production".

> pick a random open source project,

This is what I mean by not being "production". I won't judge anyone live-yoloing their blog, or "it works for my use case, it's GPL, provided AS-IS don't bother me", which is perhaps most opensource. You don't care if it works? Fine.

But you do care if it works, and/or is safe, and you push releases without AI review: yer fired.

Yes, we have to get from here to there, and I'm not saying release freeze until the entire codebase backlog has been AI-fixed, but yes today you need to have AI review the release delta. Ideally pre-commit.

comment 2w ago · link · parent

Seems I misremembered. Two reported bugs in find, but didn't want to get yelled at (again) so did not report the cat one. Cat -n is not in any standard, but at least in my opinion there's no way openbsd's behaviour on "cat -n a b" when "a" doesn't end in a newline is desired.

Yup, they did merge both find bugs.

The ignored ones seem to be my reported doas bug (not security problem, but directly contradicts manage about a config keyword detail) and efiboot.

IIRC the latter bug was like... this can never have worked.

I just checked the GitHub mirror, and those two are still not picked up.

comment 2w ago · link · parent

Sigh.

Yes, I reported some of them. Some got fixed, some got ignored. You can search my name on openbsd-tech and misc for proof.

I found more, but the ratio of ignored to fixed is too high to bother.

Years ago I also fixed bugs in the MPLS implementation. Like bugs I found immediately upon using the feature. (IIRC e.g. implicit null was erroneously pushed explicitly)

comment 2w ago · link · parent

It's not derogatory. Less than 0.1% is accurately described as almost nobody.

I like openbsd in theory, but every time I've tried something practical prevents actual use.

It's old now, but here are some thoughts of mine from 2019: https://blog.habets.se/2019/10/OpenBSD-in-2019.html

comment 2w ago · link · parent

You're painting a picture that code written with love is perfectly safe. It's not.

Yes, openbsd has not had a torrent of bugs found, but I would say that the vastly bigger reasons for that are: 1) orders of magnitude people care about burning tokens and money to find the bugs in an OS almost nobody uses, and 2) it's simply much smaller. Can't have Bluetooth bugs if you don't have a Bluetooth stack.

I've pointed LLMs at obsd stuff, and even the simplest code, e.g. cat & find, had bugs and buffer overflows.

OpenBSD also has a poor patch tracking system, since they're still on CVS. A patch has an extremely good chance of just falling through the cracks. Security or not.

So no. Nobody can write safe C. Not hobbyists, and not "those evil corporations".

comment 4w ago · link · parent

Well, it was a mix. Win32, then the Lotus family just refused to conform.

And some others. IP? No, we are a NetWare IPX network!!

comment 4w ago · link · parent

I believe this is https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p14... and seen in 4.1.2p6 of https://eel.is/c++draft/intro.abstract, and then p7 lists what the time travel gates (observable behavior) is.

Now if this actually made it into the C++26 standard, I've not paid to get the official one, but it's in the N5050 draft: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/n50...

comment 4w ago · link · parent

Author here.

Of course I would also prefer a warning, or at least a guarding trap instruction. And maybe compilers should try harder to be friendly in this way.

But they can't be perfect, because the program specified something syntactically valid, but semantically invalid. The module/compiler pass that could theoretically detect it may simply not be issued the necessary information. E.g. a solver may be given the input that a value is in a given range, and from that simplify an operation. If the input is wrong, so is the output.

Reminds me of:

    On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
In the example from the article, though, there could be a pass that simply eliminated dead code. That pass is not a parser of the raw code, so how is it to know that actually, the "dead code" isn't?

And a standard that would require dead code elimination to replace not with empty, but with a trap instruction, could go very wrong. You don't want `if (false) { … }` to become `if (false) { trap(); }`. You want it just removed, if a previous pass deemed it dead. Or do you want `int main() { for(;;) {cli_loop();} }` to force adding a trap in the unreachable code after the loop? That's a lot of generated trap instructions.

So in general this means solving the halting problem. Yes, specifically in the post's example, "surely a sufficiently smart compiler could detect something this obvious". Maybe so, but how often is the bug actually this obvious?

comment 1mo ago · link · parent

Free Anti Matter!

Anti Matter did nothing wrong!

comment 1mo ago · link · parent

To elaborate on the other reply to your comment: In Rust, if you don't use `unsafe` and still manage to trigger UB, then that's a bug in the compiler or the library code you called (which in turn has to have used unsafe somewhere to trigger UB).

So the fact that `unreachable!()` does not require the use of the keyword `unsafe` means that it can't be like C++ `std::unreachable()`.

comment 1mo ago · link · parent

Author here.

No. That's just one of the MANY ways to trigger UB. In the article I also trigger UB by dereferencing a null pointer instead.

In fact, here's an example where calling `unreachable()` and dereferencing a null pointer produce the EXACT same assembly: https://godbolt.org/z/538qfj9z9

comment 1mo ago · link · parent

Author here.

Yes, into the shame cube I go. It doesn't change anything, and it applies equally to C and C++, but you are correct. Thanks.

comment 1mo ago · link · parent

C++26, IIRC, adds "no time travel" to C++. But note that your example still creates exploding chocolate, so what do you mean by "immune"? C compiler with -std=c23 -O1 produces literally the exact same assembly output.

comment 1mo ago · link · parent

> This is sort of true, except that behavior can be undefined in the standard but defined in your implementation.

But then it's not UB, and not the topic at hand. So I wouldn't call it "sort of true" for a statement about UB, because it doesn't apply to not-UB.

It's also different in a consteval context. But that doesn't make it less true outside consteval context.

comment 1mo ago · link · parent

Author here.

> "the definition of std::unreachable is: invokes undefined behaviour" does not mean that all undefined behaviour is equivalent to calling std::unreachable.

Well, obviously not. The definition of UB is that anything can happen, so by transitive property it means that std::unreachable can trigger any behavior.

That's the whole point of UB, and the point of my post: It's UB! You cannot reason about what will happen! The whole point of the post is "No you CANNOT reason about what will happen". So of course I am making no claims about what will happen, just three interesting observations about what did in fact happen when I happened to try it, to prove this point.

> If you wanted a trap instruction, maybe this compiler reliably generates one from a hardcoded null deref.

No, even in the examples in my post I show that it's not reliable. It's UB!

Hell, we get very different output just between -O1 (https://godbolt.org/z/33e1nGE38) and -O2 (https://godbolt.org/z/3coTqP31W).

comment 1mo ago · link · parent

Author here: yes and no.

UB can also be things that the compiler is unable to express. It's NOT "haha, now I can do anything", it's like asking what the correct answer is to a logically inconsistent question. The compiler cannot even express the question.

Let's say the compiler encodes some GC information in the low two bits of int pointers. What does it mean if a function is called with an unaligned pointer, then? Mu, unask the question. It's UB, and no diagnostic required nor even feasible.

comment 1mo ago · link · parent

Vibe coding may produce a lot of code, but I'd say LLMs can already find more than 99% of bugs, and I extrapolate that they therefore won't add them to living systems.

But even if new code gets bugs, we run a bug finding pass on the delta. So the vulnporalypse will end.

And in my prompts I've seen LLMs find complex interaction bugs that a human would basically never find (and the bug was added by a human).

You say polluted by vibe coding. But in terms of bugs, especially in the last like 6 months, you could argue that humans are the polluters.

E.g. while I've seen "ai deleted our database", but if what you're saying is true, we should be seeing "AI added this buffer overflow". But we don't, because humans are the polluters of that.

Yes, there have been "ai coded up client side password checking", but I've not seen that recently. Only like 6 generations and three years ago.

At some point it's like telling the cab driver to just follow Google maps directions. Like... sorry, cabbie (Black Cabs in London with their "the Knowledge" is what I'm thinking), your memorization, while impressive, is worse than the app.

The painter, while impressively skilled, is a worse documentarian than the camera.

And that point is probably behind us. At least for typing. And it's climbing up in abstractions.

comment 1mo ago · link · parent

It could lead to a mess, sure. But my favourite prompt on an LLM-untouched codebase is along the lines of "find UB and other bugs. If the fix is less than 5 lines, fix it and commit it. One change per commit". Then I of course check the commit history before pushing.

My experience over the last couple of years with this type of prompt is that eventually you run out of bugs to find (meaning you reach "I see what you mean, but I disagree").

And those fixes don't cause messes.

And a new model may find something new, but not even remotely the volume seen the first time. This indicates to me that the supply of bugs is finite, and after this period of house cleaning, it should go down.

But anyway, a mess (decoherence) doesn't necessarily mean an exploitable mess.

Reading that good article, I find myself thinking that we did not need LLMs to get decoherence in complex software or systems. At least LLMs don't have personal fiefdoms, egos, and company politics adding to encouraging decoherence.

comment 1mo ago · link · parent

> The bugs will only disappear until the model that was used to security test the generated code becomes obsoleted.

I think you're ignoring the distinct possibility that even if the code is not formally verified, LLMs could simply stop writing bugs, or this kind of bugs. No matter how smart an attacker AI, it cannot exploit bugs that are simply not there.

But hell, even formally verified ones can only verify back to the spec. There are plenty of examples of bugs in formally verified software.

I place a higher likelihood on LLMs winning (producing fewer bugs than formally verified) over the long run. Mostly because verified software can, IIUC, only verify back to the spec. Whereas LLMs can go "uh, your spec itself has a bug, you really want me to codify that?".

comment 1mo ago · link · parent

Luckily we have newer models going back and fixing these things.

In terms of the set of all bugs, the AIs from 2022-2023 pale in comparison with the amount of bugs written by hand in previous half century, even if 2022 AIs were worse than the average programmer.

comment 1mo ago · link · parent

That study is from 2022, with at most a last update 2023? (if I read it right)

I'm not at all saying that "oh 3 weeks ago, discard", but three years ago absolutely has a "before and after".

Three years ago AI generated code could basically not be used at all, and I had to rewrite just about every line. Today I have to watch out for generated code making steps in the wrong strategic and architectural direction, and over engineering, no longer hallucinating nonexisting APIs and forgetting to check the auth token.

I still look for those kinds of mistakes, but I think citing a 2022 paper for "can AI do X" is not useful.

comment 1mo ago · link · parent

> C that does the right thing based on assumptions about the platform is possible

What does that mean? "The right thing based on assumptions about the platform"?

I hope it's not "but we know what this will actually do on my platform", because I just wrote another blog post about how UB is not predictable: https://blog.habets.se/2026/10/Attention-people-who-think-UB...

comment 1mo ago · link · parent

Most things in the world are not made of zinc. But to therefore say that we live in a world without zinc in production is not a correct conclusion (https://youtu.be/jWpPrWHBHcQ).

> running in a browser written in C++

As other have pointed out, that browser would not render fonts without Rust. You use your browser without fonts? I mean, it's not impossible. Some people navigate the web using screen readers.

> running on an OS written in C/++

Except the parts that are written in Rust or other languages, sure.

So tautologically, the parts that are not written in other languages, are written in C and C++. That's technically correct, the best kind of correct.

> Whatever higher-level language you use, it's powered by C/++

"Powered by" in that it runs on an OS written in C, assembly, and C++, sure. Still not relevant. Languages tend to want to "self-host".

> Your game engines are written in C/++

Well, most gaming hours in the world are probably spent on games written in C#, Java, Kotlin, Swift, and Objective-C. And JS.

JetBrains 2025 study has 40% of game development as C#. C++ just 29%.

AAA games, sure. But it's understatement of the year to say that because AAA games are written in C++ that means it's the only production language.

> Your fucking car is written in C

I think you're stuck in the past. This is no longer a categorically true statement.

The world changes. It used to be a true statement that "americans don't even have passports". In 1989 only 3% had passports, and the world could mock that figure. Today it's 48% and rising.

Just like you should no longer say "americans don't even have passports", because while the percentage may not be a record, it's no longer true, you should stop saying other things when they are no longer true.

> literally 0% of the software anyone uses being written in Rust.

As I have others have repeatedly proved to you, this is literally (actual literally, not as a rhetorical device) false.

I guess you could live in a world with 0% Rust. Your car is old, your Linux kernel was compiled to exclude Rust parts (not sure this is possible. Haven't checked), and you don't run anything Chromium-based, or Firefox. And you don't own an Android phone.

But you saying (asserting without evidence) that it's only minor systems in these omnipresent systems that use Rust, then… uh… what's your point? In a car, if C controls fuel injection and Rust controls the power steering, does that "not count", and you'd still claim "literally 0%"?

But… like, if you have an iPhone instead, do you think it doesn't run anything Objective-C or Swift?

I think it's accurate enough to say that "Cloudflare runs on Rust".

You think you, and normal people, never use Cloudflare? Cloudflare hosts like a a quarter of web traffic.

A quarter of web traffic runs on Rust. In production. Right now.

> You're talking about how "writing new C in 2026 is misconduct" like it's a relic of a bygone era

Just like with Cobol, in an existing system it does have its place for extending existing code.

But that "new" is key.

> world around you is a world written entirely in C

Entirely? No. Nobody's saying there's no C code in existence. I don't know why you care to defend against that imagined claim.

> rounded to a whole percent, literally 0% of the software anyone uses being written in Rust.

Does it matter, if (say for example) your pacemaker or car ignition runs Rust?

Come back, zinc, come back.

comment 1mo ago · link · parent

What is your point?

I pointed to a jetbrains study, and then there's a stackoverflow survey[1] showing C neck and neck with PHP at 11th place among professional developers.

We all know there's lots of important C code out there. I don't see anyone going "RIIR!!!" in this thread.

But obviously yes, the 11th place language will have MANY programmers working on it. Not as many as JS by far. But many. In that survey Go is just after PHP. There are also many many Go programmers.

We are not yet at risk of running out of C programmers, like the Cobol situation. Nor do I want us to.[2]

But what point are you trying to make by so strongly defending C and the comment "grownups with important jobs write C"?

[1] https://survey.stackoverflow.co/2025/technology#most-popular... [2] relevant comment: https://news.ycombinator.com/item?id=50187384

comment 1mo ago · link · parent

Cobol powers the world's money and international travel. Not sure how that matters.

> Think about what Rust software people actually use

More and more Chrome, Google, Android, Cloudflare, Prime Video, and phone basebands, parts of Linux kernel, and many other things.

Normal users literally use those all day every day.

Are they 100% Rust? Of course not (well, I don't actually know if some phone basebands are, by now. Naturally very closed source). But they're not 100% another-language either.

If C disappeared from the world, the world would stop, yes. Same with Cobol. Same with Java. Same with C++. Same with assembly.

If I were to guess (completely without basis for my guess) about the number of lines of code that normal users exercise in a normal day (counting each line just once), my bet would be on Java or JS.

Would the Java be able to run without the C code? No. But normal users would not be able to do anything if only C was left. And all banks would be gone.

And in any case C would not be able to do anything without transistors.

comment 1mo ago · link · parent

> Undefined behavior does not mean that a language is useless.

Never said it was useless. But it's pretty damning that literally nobody can write correct code in the language. And my point is that it's been enough time that it can't be seen as a skill issue.

> C is quite nice to write as an abstraction over assembly, and I highly recommend writing C code and thinking about (and checking) what assembly it compiles into.

Absolutely. I think in order to understand programming you need to be able to write C, and be able to read assembly.

C isn't "high level assembly", with the whole discussion about the spec talking about the abstract machine, but one does not need to be a C language lawyer to be a good programmer.

But to your point about checking the output: That goes for Rust too, and godbolt.org supports Rust too, for this workflow.

So I'm not saying C is useless. But I am saying that if someone were to decide to write their greenfield project in C, then if it plans to have actual users (as opposed to a fun project), then it's basically misconduct.

Cf. Steve Gibson writes his software in assembly, still. Because he enjoys it, and his enjoyment is the primary user. I respect that. But I would NEVER hire someone to write whole applications like that in assembly. Or C.

comment 1mo ago · link · parent

Well, "grownups with important jobs write C" can be taken in two ways. Non-snarky, sure. There are MANY people who write C professionally.

Not as many as there are Python, Java, JS, or C++ programmers. Depending on the survey, C seems to be neck and neck with PHP.

I read the comment the other way, though. The way that says that those other more popular languages are not serious, and NOT for grownups with important jobs.

Edit: actually, Jetbrains 2025 survey has C neck and neck with Rust: https://www.jetbrains.com/lp/devecosystem-data-playground/ . Both "below the fold" and less than 10% of Java.

comment 1mo ago · link · parent

Do you know if the code bases are of the kind where dynamic memory (among many other features) is disallowed?

comment 1mo ago · link · parent

Are you just being snarky, or do you have something more specific to say about something that's choosing C?

Considering that it's been 54 years, and we've yet to find any human being, any at all[1], who can write C without UB, I'd say that writing C in 2026 when there's any other option is basically misconduct and a good case could be made that if the code touches money in any way, then it could be a SOX violation too.

Writing C today is like still writing Cobol. Yes, if you are adding a new type of savings account to your bank, and the rest is in Cobol, then sure write it in Cobol.

Some microcontroller projects may have an ecosystem in C that makes other options harder in practice, but it's still a worthy investment to not use C. There's a reason phone baseband firmwares are moving away from C.

[1] No, not even djb, who people like to bring up.

12345
14