ThePhD
thephd.dev · Personal blog · on HN since 2021
JeanHeyd Meneide (ThePhD) writes about C and C++ standardization, ABI, undefined behavior, and language features like #embed and defer.
What HN saysHN commenters link it for its account of the C23 embed saga and standards committee process, and for discussion of C ABI and closures.
112HN people shared it
75linked it in comments
78stories submitted
2.2Kstory points
3 months agolast shared
2021people per year2026
Most-shared posts
- 1Embed is in C2318 people · 489 points · first shared 2022 · 338 comments on HN
- 2I Am No Longer Speaking at RustConf 202312 people · 1 points · first shared 2023 · discussion on HN
- 3The Defer Technical Specification: It Is Time11 people · 148 points · first shared 2025 · 68 comments on HN
- 4Conformance Should Mean Something: Fputc, and Freestanding9 people · 20 points · first shared 2022 · 2 comments on HN
- 5To save C, we must save ABI7 people · 180 points · first shared 2022 · 128 comments on HN
- 6Lambdas, Nested Functions, and Blocks (2021)7 people · 54 points · first shared 2021 · 9 comments on HN
- 7Binary Banshees and Digital Demons7 people · 51 points · first shared 2021 · 9 comments on HN
- 8Undefined Behavior, and the Sledgehammer Principle6 people · 7 points · first shared 2023 · 1 comments on HN
- 9C23 is finished: Here is what is on the menu5 people · 259 points · first shared 2022 · 196 comments on HN
- 10Why not just do simple C++ RAII in C?5 people · 188 points · first shared 2024 · 253 comments on HN
- 11Progress on C235 people · 98 points · first shared 2021 · 56 comments on HN
- 12Why the C Language Will Never Stop You from Making Mistakes5 people · 73 points · first shared 2021 · 35 comments on HN
- 13A Special Kind of Hell: intmax_t in C and C++ (2020)5 people · 33 points · first shared 2021 · 31 comments on HN
- 14Ever Closer: C23 Draws Nearer5 people · 4 points · first shared 2022 · discussion on HN
- 15Improving _Generic in C2y4 people · 53 points · first shared 2024 · 21 comments on HN
What HN people wrote when they linked it
pjmlp · 2026-08-07
Not only, there is also XPC and IO/DriverKit on Apple, Android IPC, D-BUS, FIDL on Fucshia,....
Also C ABI also does not exist, people keep mistaking the ABI of their favourite C compiler with the OS ABI, which only overlap if the OS was written in C to start with.
For example on mainframes and micros, naturally not written in C, it is either a bytecode based ABI like TIMI on IBM i, or language environments like on z/OS, ClearPath MCP, OS 2200 and so forth.
And as a reminder, from a famous WG14 and WG21 member, and former Rust contributor,
"To Save C, We Must Save ABI"
https://thephd.dev/to-save-c-we-must-save-abi-fixing-c-function-abi
fg137 · 2026-05-17
(having no first hand experience with WG21)
Many people think there are a lot of problems with C++ committee and the standards process. Some would claim that the ISO governance model doesn't work at all. There is a lot of drama that the outside world has no idea about, because much of the discussion is behind closed doors.
You can look it up (e.g. on blogs and /r/cpp), but I am not linking to anything because lots of content is very biased and hard to verify.
Something that is not controversial and worth a read is https://thephd.dev/embed-the-details and you can see the point.
I do feel the TC39 (the group behind the ECMAScript/JavaScript standard) seems more practical and effective. There are disagreements and dramas but not nearly as bad as with C++.
__phantomderp · 2025-12-13
For what it's worth, that is the primary feature of the proposal linked in the blog post. It's just not talked about in the post because that post is about... performance!
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Functions%20with%…
kccqzy · 2025-11-15
Agree with a lot of what you said. Definitely to a lot of corporations C++17 was the peak of the language. Apple prioritized Swift afterwards and Google started doing Carbon and begrudgingly accepted Rust.
First time hearing about the embed issue and god that person’s experience is awful: https://thephd.dev/finally-embed-in-c23 and it feels like a job for only the best project managers.
omoikane · 2024-11-25
> Stories of people trying their best to participate in the C++-standard committee process across multiple years
This links to:
https://thephd.dev/finally-embed-in-c23
It was a fascinating story, particularly about how people finally coming to terms with accepting that a seemly ugly way of doing things really is the best way (you just can't "parse better").
The feature itself is interesting too.
https://gcc.godbolt.org/z/jGajc6xd5
zokier · 2024-08-23
It's worth noting that modern x86 CPUs have specialized extensions for bit manipulation. Furthermore C23 added stdbit.h that has some operations for bit manipulation
https://en.wikipedia.org/wiki/X86_Bit_manipulation_instruction_set
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Modern%20Bit%20Ut…
sigsev_251 · 2024-01-31
With all respect, please don't say nobody cares. There many people in the C community that want this but it's not easy to add a fat pointer to C after all these years. Though, there are people who are planning to work on this exact solution [1]. The best thing the rest of the ecosystem can do, is support them.
[1]: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Non-owning%20Size…
trealira · 2024-01-17
I'm sure legacy C and C++ will be around for a long time, but their process for authoring new standards also seems somewhat unsustainable.
It seems like people making contributions to the C and C++ standards are also at risk of getting burnt out: https://thephd.dev/finally-embed-in-c23
> It was all worth it.
> …
> Or. That’s what I keep telling myself. Because it doesn’t feel like it was worth it. It feels like I wasted a lot of my life achieving something so ridiculously basic that it’s almost laughable. How utterly worthless I must consider myself, that hearing someone complain about putting data in C++ 5 years ago put me on the track to decide to try to put something in a programming language standard. That I had to fight this hard for table scraps off the Great C Standard’s table.
> What a life, huh?
throwaway2037 · 2023-10-03
It sounds like a generic length function in Unicode in 2023 is no longer a good idea. These articles complaining about the variety of lengths in Unicode are annoying at this point. Pretty much all of them can be summed up as, "Well, it depends." And, that isn't wrong. But nerds love to argue until they are blue in the face about the One Correct Answer. Sheesh.
This is the most interesting comparison article I have seen in years about Unicode processing in C++: https://thephd.dev/the-c-c++-rust-string-text-encoding-api-landscape
The author is also the lead on an open source C++ Unicode library called ztd.txt: https://github.com/soasis/text
spacechild1 · 2022-03-13
In fact, he is the project editor: https://thephd.dev/editing-the-c-standard
He is also the author of sol2, arguably the best C++ Lua bindings library out there :-)
His writing style might be a bit idiosyncratic, but he certainly is a brilliant person.
mananaysiempre · 2025-01-10
> everybody could (and should?) just start declaring size parameters before their respective buffer parameters in new code
I know that was a common opinion pre-C23, but it feels like the committee trying to reshape the world to their desires (and their designs). It's a longstanding convention that C APIs accept (address, length) pairs in that order. So changing that will already get you a score of -4 on the Hard to Misuse List[1], for "Follow common convention and you'll get it wrong". (The sole old exception in the standard is the signature of main(), but that's somewhat vindicated by the fact that nobody really needs to call main(); there is a new exception in the standard in the form of Meneide's conversion APIs[2], which I seriously dislike for that reason.)
The reason I was asking is that 'uecker said it was requested at the committee draft stage for C23 by some of the national standards orgs. That's already ancient history of course, but I hoped the idea itself was still alive, specifically because I don't want to end up in the world where half of C APIs are (address, length) and half are (length, address), when the former is one of the few C conventions most everyone agrees on currently.
[1] https://ozlabs.org/~rusty/index.cgi/tech/2008-04-01.html
[2] https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Restartable%20and…
fl0ki · 2024-04-07
My problem is that if you're an actual C superset, you're carrying a lot of baggage that will permanently compromise the best case of what you can ever become.
These days, with C standards back on a regular cadence, the thing you have to be a superset of is also a moving target, and you have to make sure your extensions don't end up incompatible with future C changes. If you succeed enough, the C standard has to be worried about compatibility with you in return.
Even the most conservative C supersets like non-standard GNU C have created friction for what the actual ISO standard can do in future, including the highly demanded addition of nested functions [1]. One could almost argue that the long-term value of that C superset will be net-negative precisely because it was successful enough to become a permanent interoperability hazard for C itself. (They could have avoided that by not claiming to be C at build time, but that would have also avoided anyone ever using it, just like almost all of the other supersets).
C++ isn't even a C superset and still that relationship creates friction both ways [2].
Now if you're not a C superset, you have a more difficult adoption story and that is enough to kill a language before it ever has a chance. Even so, far more languages have succeeded by tackling interoperability problems than by being supersets.
Rust has a fair amount of friction binding to C, but people see enough value in overcoming that; and part of what people claim to…
Joker_vD · 2024-01-31
> I think most C programmers frustrations with UB stem from knowing that the C standard has fundamental flaws and modern compilers abuse that fact for "optimizations" on UB
Do they actually know that? I don't think so. Let's take [0] for instance (the author is an expreienced C programmer who loves the language and wrote a re-implementation of bc in it):
There seemed to be a lot of misunderstandings; I could not get a handle on what this person thought UB meant. I finally figured it out: this person’s definition of UB was not “the language spec can’t guarantee anything.” Instead, it was “compilers can assume UB does not exist and optimize accordingly.” Wat. Yep. Apparently, that was news to him, even though C implementations have been behaving like that for about 30 years already, and you can read the rest of the post for the "this is evil, we the users must do something about it" take. And the proposed "something" is not "we should instead use a language with actually defined semantics", oh no. It's "use compiler flags to force more reasonable behaviour, hopefully" and "somebody should write boringcc, unfortunately, I am myself a bit too busy for that". Well, despite numerous pleas and several attempts, nobody has managed to write boringcc which is telling of something, I'm just not sure of what exactly. So... I think it is about imprinting: "Oh, it's a wonderful language, well, it would be if it was actually implemented the way I used to think it is…
amluto · 2023-09-13
I can indeed "quite easily" hack this up. But this is C++, and C++ string manipulation is infamously unsafe and error-prone, and I really have very little desire to hack this up, write tests, etc, when I'd rather not think about UTF-8 at all.
For an example of how unsafe and error-prone C++ string manipulation is, from simdutf's very own documentation:
> simdutf_warn_unused size_t convert_latin1_to_utf8(const char * input, size_t length, char* utf8_output) noexcept;
Eww, this literally cannot be safe in the sense of "free from memory-safety errors when called carelessly" (like Rust or almost any GC language would expect). Look, takes a single pointer to an output array with no length or other limit. It overruns the buffer unless you get it exactly right. (ThePhD has a very on-point rant or two [0] about this, and ztd.text IMO (and in his opinion) gets this right.) Also, for all that simdutf is really quite fast, it's really not obvious how to transcode latin-1 to utf-8 in a single pass, because you apparently need to compute the length first.
I think one of the great strengths of safer languages is that they fight back when you try to design an API like this.
[0] https://thephd.dev/output-ranges
arp242 · 2023-05-28
It's possible, but those weren't mentioned unless I missed something. The keynote was "start of the day, shared slot with somebody else, 30 minutes".[1] No mention of different length after the change, but I would assume it will mean a different timeslot.
I think what happened is just the regular chaos and hub-hub that's involved with organising these things; since JeanHeyd himself already indicated he wasn't sure he wanted to give keynote the organisers probably figured it didn't matter much to him. Classic expectation mismatch. For reasons that are not entirely clear to me JeanHeyd assumed "somebody is pulling very weird strings behind the scenes", "shadowy decisions that are non-transparent", and "vindictive behavior". The best explanation I can come up with for that is that this is not so much about this talk, but rather expressing general unhappiness with the Rust leadership, and this is merely the "the final straw". But who knows...
[1]: https://thephd.dev/i-am-no-longer-speaking-at-rustconf-2023
leoc · 2026-08-10
There's some discussion of how C29 defer ended up in a TS at https://thephd.dev/c2y-the-defer-technical-specification-its-time-go-g… .
sparkie · 2026-08-10
> What practical patterns are enabled by TCO in C?
Continuation Passing Style - an important construction for interpreters, but which is also useful for compilers as it's a nice way to do control flow analysis, data flow analysis and more.
The missing feature is closures - functions which capture values from their static environment, which are basically needed to make CPS useful. GCC has nested functions, but they cannot capture without making the stack executable, which is terrible. There's a proposal[1] to get closures into C, but at present you need to simulate the capturing yourself, which is cumbersome, but can be done efficiently.
[1]:https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Functions%20with%…
tigen · 2026-03-18
This ought to help with that.
https://thephd.dev/c2y-the-defer-technical-specification-its-time-go-g…
babalark · 2026-02-20
Yes!! One step closer to having defer in the standard.
Related blog post from last year: https://thephd.dev/c2y-the-defer-technical-specification-its-time-go-g… (https://news.ycombinator.com/item?id=43379265)
skavi · 2026-01-03
I think maybe this post would make more sense if you were familiar to its antecedent [0] which compares existing closure extensions to C. IIRC the comparison was in the context of considering designs for standardization.
[0]: https://thephd.dev/the-cost-of-a-closure-in-c-c2y
fuhsnn · 2025-12-11
IMO the C way is to allow users to explicitly manage context area, along the lines of posix ucontext.h or how the author's closure proposal handle closure allocation[1]. [1] https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Functions%20with%…
crosser · 2025-11-18
C standard _may_ eventually have a feature semantically equivalent, but very different syntactically:
https://thephd.dev/_vendor/future_cxx/technical%20specification/C%20-%…
Discussion:
https://thephd.dev/_vendor/future_cxx/papers/C%20-%20Improved%20__attr…
M3Henry · 2025-11-17
Reminds me of the story of #embed[1]. Hopefully something workable comes of this eventually.
[1]: https://thephd.dev/finally-embed-in-c23#the-fight
aw1621107 · 2025-10-15
All three of the languages you list are still actively updated. Coincidentally, the latest standard for all three of them is from 2023(ish):
- C23: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf
- Cobol 2023: https://www.incits.org/news-events/news-coverage/available-now-2023-ed… (random press release since a PDF of the standard didn't immediately show up in a search)
- Fortran 2023: https://wg5-fortran.org/N2201-N2250/N2212.pdf
C2Y has a fair number of already-accepted features as well and it's relatively early in the standard release cycle: https://thephd.dev/c2y-hitting-the-ground-running
ncruces · 2025-10-01
I encourage you to read (at least) this section of this blog before making simplistic suggestions: https://thephd.dev/just-put-raii-in-c-bro-please-bro-just-one-more-des…
How do you mandate initialization, handle copies, move objects, prevent double frees? What's RAII without any of that?
scoopr · 2025-10-01
Then there is the proposal to add standard `defer` to C2y[0]
[0] https://thephd.dev/c2y-the-defer-technical-specification-its-time-go-g…
teo_zero · 2025-07-26
Correct, complex types must be typedef'd. At least, until c2y integrates _Record as per N3332: https://thephd.dev/_vendor/future_cxx/papers/C%20-%20_Record%20types.h…
minetest2048 · 2025-06-27
This is embedded C where standard abuse is a thing: https://thephd.dev/conformance-should-mean-something-fputc-and-freesta…
kragen · 2025-05-07
JeanHeyd's side of the RustConf thing: https://thephd.dev/i-am-no-longer-speaking-at-rustconf-2023
shakna · 2025-04-06
Attributes, mostly. Which have become so common that defer is very likely to be in the next C standard. [0]
bool function_with_cleanup(void) { // Allocate first resource int* buffer1 __attribute__((__cleanup__(free))) = malloc(sizeof(int) * 100); if(!buffer1) { return false; } // Allocate second resource int* buffer2 __attribute__((__cleanup__(free))) = malloc(sizeof(int) * 200); if(!buffer2) { return false; } // Open a file FILE* file __attribute__((__cleanup__(fclose))) = fopen("data.txt", "r"); if (!file) { return false; } return true; } [0] https://thephd.dev/c2y-the-defer-technical-specification-its-time-go-g…