I expect a lot of C code may be quite mechanically translated to Zig (by help of LLMs). Unlike C->Rust or C->C++, where there's more of a paradigm shift.
There's solid reason for the translation here; the Zig core team is aiming to eliminate duplicated code and C functions, and avoid the need to track libc from multiple sources. In the future, LLMs could serve as part of this, but they are currently quite terrible at Zig (as far as I understand it, it's not a lack of Zig code samples, it's an imbalance of OLD Zig to NEW Zig, as Zig changes quite frequently).
You would need to consider if it is even worth it translating your C code. If the paradigm is identical and the entire purpose would be "haha it is now one language," surely you could just compile and link the C code with libzigc... In my opinion, it's not worth translating code if the benefit of "hey look one language" requires the cost of "let's pray the LLM didn't hallucinate or make a mistake while translating the code."
"Furthermore, when this work is combined with the recent std.Io changes, there is potential for users to seamlessly control how libc performs I/O - for example forcing all calls to read and write to participate in an io_uring event loop"
This is exciting! I particularly care more about kqueue but I guess the quote applies to it too.
This strikes me as a very agent-friendly problem. Given a harness that enforces sufficiently-rigorous tests, I'm sure you could spin up an agent loop that methodically churns through these functions one by one, finishing in a few days.
Have you ever used an LLM with Zig? It will generate syntactically invalid code. Zig breaks so often and LLMs have such an eternally old knowledge cutoff that they only know old ass broken versions.
The same goes for TLA+ and all the other obscure things people think would be great to use with LLMs, and they would, if there was as much training data as there was for JavaScript and Python.
Try it again. This time do something different with CLAUDE.md. By the way it's happy to edit its own CLAUDE.md files (don't have an agent edit another agent's CLAUDE.md files though [0])
To be fair, this was true of early public LLMs with rust code too. As more public zig repositories (and blogs / docs / videos) come online, they will improve. I agree it's a mess currently.
i find claude does quite well with zig. this project is like > 95% claude, and it's an incredibly complicated codebase [0] (which is why i am not doing it by hand):
[0] generates a dynamically loaded library which does sketchy shit to access the binary representation of datastructures in the zig compiler, and then transpiles the IR to zig code which has to be rerun to do the analysis.
Cool idea, for sure, but I can't help but wonder: for the code that's been ported, is there a concern that you'd have to perpetually watch out for CVEs in glibc/musl and determine if they also apply to the Zig implementations?
The very same day I sat at home writing this devlog like a coward, less than five miles away, armed forces who are in my city against the will of our elected officials shot tear gas, unprovoked, at peaceful protestors, including my wife.
This isn't some hypothetical political agenda I'm using my platform to push. There's a nonzero chance I go out there next weekend to peacefully protest, and get shot like Alex Pretti.
Needless to say, if I get shot by ICE, it's not good for the Zig project. And they've brought the battle to my doorstep, almost literally.
My 85 year old mom lives in Portland and she attends rallies frequently. If you know of any way to support you or other local people doing this work, I'm very interested. My email is on my profile page.
I have a friend who is in Minneapolis. He's involved in caravans which are tracking ICE. He wasn't the driver in the last one. But, the ICE vehicle they tailed suddenly started going in a very direct path, instead of randomly driving. The driver figured it out first. They drove to the driver's house and then stood outside of their car for ten minutes staring at his house. Cars in Minnesota have their license plates on both the front and the back.
Is there any justification for that kind of intimidation? Did any of the Trump supporters vote for that? I hear about paid agitators on the left but not that kind of compensated actors. Is his name in a database now once they did the lookup?
In the Federal model of US government, state authority overrides centralized government except in the explicit cases enumerated by the Constitution.
So yes, of course they mean their local officials, because in this case there isn’t an explicit line in the Constitution explaining why the feds are allowed to invade Minnesota.
The Supreme Court has disagreed with you on the matter of federal immigration constitutional authority for more than a century. There isn’t any “invasion”; that’s a propaganda device.
Andy stay safe. We gotta all come to realization that none of this is possible if we let our democracy slip away. Millions before us died to preserve it. We owe it to them to put up a good fight.
Pushing politics is explicitly against the Hacker News guidelines though.
If Andrew wants to make Zig the woke programming language for American Liberals, he is of course free to do so, but then he probably should not be posting on Hacker News in an attempt to proselytize.
If Andrew only wrote “I object to murder” we wouldn't have this discussion. We're here because he wrote “Abolish ICE” instead. That's not denouncing murder, it's denouncing federal immigration law.
The woke don't object to murder. They cheered the murder of Charlie Kirk, they lamented the assassination attempts on Donald Trump because they _failed_, they celebrate Luigi Mangione as a martyr for their cause. Has Andrew ever used the Zig programming blog to condemn any of these (attempted) murders? I bet he hasn't—but feel free to prove me wrong!
So it's pretty clear that Andrew, just like most of the woke, doesn't object to murder. He loves murder. He only objects to democracy, to the rule of law, to the majority of Americans who don't support illegal immigration to the extent that he does.
If Andrew wants to use his programming language to take a stand against murder, he is welcome to do so! He has chosen to never do it. He has only used his platform to push woke politics, by supporting illegal immigration, and opposing law enforcement.
Objecting to murder is still politics, no? In fact, US republicans and democrats can't seem to agree who is fine to murder.
Republicans say that abortions are murder, but often also that prisoner executions are fine. Democrats tend to be in favor of abortions, but not of the death penalty.
I'm not making a moral judgement here, but I do want to ask. Is it just politics you don't agree with that you don't want Andrew to express?
I just want to say that I agree completely with you here. I had a suspicion of what kind of person Andrew was when I saw him with colored hair (so called 'danger hair') and basically knew it was over.
> It’s kind of like enabling LTO (Link-Time Optimization) across the libc boundary, except it’s done properly in the frontend instead of too late, in the linker
Why is the linker too late? Is Zig able to do optimizations in the frontend that, e.g., a linker working with LLVM IR is not?
Seems like it ought to be able to do inlining and dead code stripping which, I think, wouldn't be viable at link time against optimized static libraries.
Right, but I think that's what the question of "Why is the linker too late?" is getting at. With zig libc, the compiler can do it, so you don't need fat objects and all that.
---
expanding: so, this means that you can do cross-boundary optimizations without LTO and with pre-built artifacts. I think.
As I understand it, compiling each source file separately and linking together the result was historically kind of a hack too, or at least a compromise, because early unix machines didn't have enough memory to compile the whole program at once (or even just hold multiple source files in memory at a time). Although later on, doing it this way did allow for faster recompilation because you didn't need to re-ingest source files that hadn't been changed (although this stopped being true for template-heavy C++ code).
A lot of languages claim to be a C replacement, but Zig is the second language I've seen that seemed like it had a reasonable plan to do so at any appreciable scale. The language makes working with the C ABI pretty easy, but it also has a build system that can seamlessly integrate Zig and C together, as well as having a translate-c that actually works shockingly well in the code I've put through it.
The only thing it didn't do was be 99% compatible with existing C codebases...which was the C++ strategy, the first language I can think of with such a plan. And frankly, I think Zig keeping C's relative simplicity while avoiding some of the pitfalls of the language proper was the better play.
This is very exciting for zig projects linking C libraries. Though I'm curious about the following case:
Let's say I'm building a C program targeting Windows with MinGW & only using Zig as a cross compiler. Is there a way to still statically link MinGW's libc implementation or does this mean that's going away and I can only statically link ziglibc even if it looks like MinGW from the outside?
If you specify -target x86_64-windows-gnu -lc then some libc functions are provided by Zig, some are provided by vendored mingw-w64 C files, and you don't need mingw-w64 installed separately; Zig provides everything.
You can still pass --libc libc.txt to link against an externally provided libc, such as a separate mingw-w64 installation you have lying around, or even your own libc installation if you want to mess around with that.
That's cool. I imagine I could also maintain a MinGW package that can be downloaded through the Zig package manager and statically linked without involving the zig libc? (Such that the user doesn't need to install anything but zig)
That's a good way to sell moving over to the zig build system, and eventually zig the language itself in some real-world scenarios imo.
This affects static libc only. If you pass -dynamic -lc then the libc functions are provided by the target system. Some systems only support dynamic libc, such as macOS. I think OpenBSD actually does support static libc though.
> I think OpenBSD actually does support static libc though.
How does that work, with syscalls being unable to be called except from the system’s libc? I’d be a bit surprised if any binary’s embedded libc would support this model.
> How does that work, with syscalls being unable to be called except from the system’s libc?
OpenBSD allows system calls being made from shared libraries whose names start with `libc.so.' and all static binaries, as long as they include an `openbsd.syscalls' section listing call sites.
For static executables, “the system’s libc” is of course not a thing. To support those, OpenBSD requires them to include an exhaustive list of all addresses of syscall instructions in a predefined place[1].
(With that said, OpenBSD promises no stability if you choose to bypass libc. What it promises instead is that it will change things in incompatible ways that will hurt. It’s up to you whether the pain that thus results from supporting OpenBSD is worth it.)
cies | 8 hours ago
I expect a lot of C code may be quite mechanically translated to Zig (by help of LLMs). Unlike C->Rust or C->C++, where there's more of a paradigm shift.
Retro_Dev | 7 hours ago
You would need to consider if it is even worth it translating your C code. If the paradigm is identical and the entire purpose would be "haha it is now one language," surely you could just compile and link the C code with libzigc... In my opinion, it's not worth translating code if the benefit of "hey look one language" requires the cost of "let's pray the LLM didn't hallucinate or make a mistake while translating the code."
dnautics | an hour ago
hard disagree (example elsewhere)
nesarkvechnep | 8 hours ago
This is exciting! I particularly care more about kqueue but I guess the quote applies to it too.
nemo1618 | 8 hours ago
henning | 8 hours ago
The same goes for TLA+ and all the other obscure things people think would be great to use with LLMs, and they would, if there was as much training data as there was for JavaScript and Python.
Graziano_M | 7 hours ago
ale | 5 hours ago
benatkin | 4 hours ago
0: https://news.ycombinator.com/item?id=46723384
rudedogg | 3 hours ago
Claude getting the ArrayList API wrong every time was a major reason why
It’s AI generated but should help. I need to test and review it more (noticed it mentions async which isn’t in 0.15.x :| )
ezekiel68 | 6 hours ago
dnautics | an hour ago
https://github.com/ityonemo/clr
[0] generates a dynamically loaded library which does sketchy shit to access the binary representation of datastructures in the zig compiler, and then transpiles the IR to zig code which has to be rerun to do the analysis.
AndyKelley | 5 hours ago
jzelinskie | 8 hours ago
AndyKelley | 6 hours ago
xrd | 7 hours ago
adzm | 7 hours ago
matheusmoreira | 7 hours ago
AndyKelley | 6 hours ago
https://www.kptv.com/2026/01/31/live-labor-unions-rally-marc...
This isn't some hypothetical political agenda I'm using my platform to push. There's a nonzero chance I go out there next weekend to peacefully protest, and get shot like Alex Pretti.
Needless to say, if I get shot by ICE, it's not good for the Zig project. And they've brought the battle to my doorstep, almost literally.
Abolish ICE.
xrd | 6 hours ago
I have a friend who is in Minneapolis. He's involved in caravans which are tracking ICE. He wasn't the driver in the last one. But, the ICE vehicle they tailed suddenly started going in a very direct path, instead of randomly driving. The driver figured it out first. They drove to the driver's house and then stood outside of their car for ten minutes staring at his house. Cars in Minnesota have their license plates on both the front and the back.
Is there any justification for that kind of intimidation? Did any of the Trump supporters vote for that? I hear about paid agitators on the left but not that kind of compensated actors. Is his name in a database now once they did the lookup?
baggy_trough | 6 hours ago
Did you mean your local officials?
kstrauser | 5 hours ago
So yes, of course they mean their local officials, because in this case there isn’t an explicit line in the Constitution explaining why the feds are allowed to invade Minnesota.
baggy_trough | 4 hours ago
actionfromafar | 4 hours ago
kstrauser | 4 hours ago
dnautics | an hour ago
ghthor | 4 hours ago
<3 zig and want io interface in everything!
lvl155 | 4 hours ago
xeonmc | 6 hours ago
himujjal | 3 hours ago
But I would really suggest keeping politics out of Zig stuffs.
I don’t even know what ICE is. Just read about it.
This is a show of power.
Like: “I am an American and since I am building the software, I am going to push MY politics into your throat”.
That means, to show similar power, I need to build a software as influential as Zig so that I can push my agendas of my country down your throats.
Heck let me do just that.
Keep politics to politics forums, keep code to code.
heavyset_go | 3 hours ago
sltkr | 3 hours ago
If Andrew wants to make Zig the woke programming language for American Liberals, he is of course free to do so, but then he probably should not be posting on Hacker News in an attempt to proselytize.
rjrjrjrj | 2 hours ago
sltkr | 2 hours ago
If Andrew only wrote “I object to murder” we wouldn't have this discussion. We're here because he wrote “Abolish ICE” instead. That's not denouncing murder, it's denouncing federal immigration law.
The woke don't object to murder. They cheered the murder of Charlie Kirk, they lamented the assassination attempts on Donald Trump because they _failed_, they celebrate Luigi Mangione as a martyr for their cause. Has Andrew ever used the Zig programming blog to condemn any of these (attempted) murders? I bet he hasn't—but feel free to prove me wrong!
So it's pretty clear that Andrew, just like most of the woke, doesn't object to murder. He loves murder. He only objects to democracy, to the rule of law, to the majority of Americans who don't support illegal immigration to the extent that he does.
If Andrew wants to use his programming language to take a stand against murder, he is welcome to do so! He has chosen to never do it. He has only used his platform to push woke politics, by supporting illegal immigration, and opposing law enforcement.
rjrjrjrj | 2 hours ago
Cool tirade.
hakrgrl | an hour ago
KingMob | an hour ago
You were ranting about how Alex Pretti's murder was justified just a few comments up.
STFU.
dminik | an hour ago
Republicans say that abortions are murder, but often also that prisoner executions are fine. Democrats tend to be in favor of abortions, but not of the death penalty.
I'm not making a moral judgement here, but I do want to ask. Is it just politics you don't agree with that you don't want Andrew to express?
jpnc | 15 minutes ago
meisel | 7 hours ago
Why is the linker too late? Is Zig able to do optimizations in the frontend that, e.g., a linker working with LLVM IR is not?
ibejoeb | 7 hours ago
comex | 7 hours ago
LTO essentially means “load the entire compiler backend into the linker and do half of the compilation work at link time”.
It’s a great big hack, but it does work.
ibejoeb | 6 hours ago
---
expanding: so, this means that you can do cross-boundary optimizations without LTO and with pre-built artifacts. I think.
gary_0 | 4 hours ago
OsamaJaber | 7 hours ago
LexiMax | 31 minutes ago
A lot of languages claim to be a C replacement, but Zig is the second language I've seen that seemed like it had a reasonable plan to do so at any appreciable scale. The language makes working with the C ABI pretty easy, but it also has a build system that can seamlessly integrate Zig and C together, as well as having a translate-c that actually works shockingly well in the code I've put through it.
The only thing it didn't do was be 99% compatible with existing C codebases...which was the C++ strategy, the first language I can think of with such a plan. And frankly, I think Zig keeping C's relative simplicity while avoiding some of the pitfalls of the language proper was the better play.
generichuman | 5 hours ago
Let's say I'm building a C program targeting Windows with MinGW & only using Zig as a cross compiler. Is there a way to still statically link MinGW's libc implementation or does this mean that's going away and I can only statically link ziglibc even if it looks like MinGW from the outside?
AndyKelley | 5 hours ago
If you specify -target x86_64-windows-gnu -lc then some libc functions are provided by Zig, some are provided by vendored mingw-w64 C files, and you don't need mingw-w64 installed separately; Zig provides everything.
You can still pass --libc libc.txt to link against an externally provided libc, such as a separate mingw-w64 installation you have lying around, or even your own libc installation if you want to mess around with that.
Both situations unchanged.
generichuman | 4 hours ago
That's a good way to sell moving over to the zig build system, and eventually zig the language itself in some real-world scenarios imo.
dnautics | an hour ago
while we're talking about printf, can i incept in you the idea of making an io.printf function that does print-then-flush?
tiffanyh | 4 hours ago
Because doesn’t OpenBSD block direct syscalls & force everything to go through libc.
https://news.ycombinator.com/item?id=38039689
actionfromafar | 4 hours ago
AndyKelley | 3 hours ago
winterqt | 2 hours ago
How does that work, with syscalls being unable to be called except from the system’s libc? I’d be a bit surprised if any binary’s embedded libc would support this model.
pretendgeneer | 2 hours ago
oguz-ismail2 | 2 hours ago
OpenBSD allows system calls being made from shared libraries whose names start with `libc.so.' and all static binaries, as long as they include an `openbsd.syscalls' section listing call sites.
mananaysiempre | 2 hours ago
(With that said, OpenBSD promises no stability if you choose to bypass libc. What it promises instead is that it will change things in incompatible ways that will hurt. It’s up to you whether the pain that thus results from supporting OpenBSD is worth it.)
[1] https://nullprogram.com/blog/2025/03/06/
AndyKelley | 2 hours ago
squirrellous | 4 hours ago
lioeters | 2 hours ago
kibibu | an hour ago
https://www.zlib.net/
anitil | 2 hours ago
LarsKrimi | an hour ago
Just joking of course. Those are sadly only in glibc.. :)