HNHacker News
TopNewBestAskShowJobs

kristoff_it

5,909 karma · joined February 19, 2016

vp of community @ zig software foundation

Zig Livecoding: https://twitch.tv/kristoff_it YouTube: https://youtube.com/@ZigSHOWTIME Blog: https://kristoff.it

I curate Software You Can Love: https://softwareyoucan.love

submissionscomments
kristoff_it··on I'm too dumb for Zig's new IO interface
The Reader/Writer changes are perfectly compatible with the upcoming async I/O stuff and you won't need to change any code that just deals with streams.

No promises about potential future changes though :^)

kristoff_it··on PYX: The next step in Python packaging
Is this going to solve the combinatorial explosion of pre-building native dependencies for every possible target?

Python should get rid of its training wheels :^)

https://kristoff.it/blog/python-training-wheels/

kristoff_it··on Asynchrony is not concurrency
We plan to have in Zig a testing `Io` implementation that will potentially use fuzzing to stress test your code under a concurrent execution model.

That said, I think a key insight is that we expect most of the library code out there to not do any calls to `io.async` or `io.asyncConcurrent`. Most database libraries for example don't need any of this and will still contain simple synchronous code. But then that code will be able to be used by application developers to express asynchrony at a higher level:

   io.async(writeToDb)
   io.async(doOtherThing)
Which makes things way less error prone and simpler to understand than having async/await sprinkled all over the place.
kristoff_it··on Asynchrony is not concurrency
> If the client were to execute before the server and fail to connect (the server is not running to accept the connection) then your system has failed, the server will run later and be waiting forever on a client who's already died.

From the article:

> Like before, the order doesn’t matter: the client could begin a connection before the server starts accepting (the OS will buffer the client request in the meantime), or the server could start accepting first and wait for a bit before seeing an incoming connection.

When you create a server socket, you need to call `listen` and after that clients can begin connecting. You don't need to have already called `accept`, as explained in the article.

kristoff_it··on Asynchrony is not concurrency
That eventually the server and the client are able to connect.
kristoff_it··on Asynchrony is not concurrency
> The contrasted example which is still concurrent but not asynchronous is the client and server one

Quote from the post where the opposite is stated:

> With these definitions in hand, here’s a better description of the two code snippets from before: both scripts express asynchrony, but the second one requires concurrency.

You can start executing Server.accept and Client.connect in whichever order, but both must be running "at the same time" (concurrently, to be precise) after that.

kristoff_it··on Asynchrony is not concurrency
>I kind of think the author simply pulled the concept of yielding execution out of the definition of concurrency and into this new "asynchrony" term.

Quote from the article where the exact opposite is stated:

> (and task switching is – by the definition I gave above – a concept specific to concurrency)

kristoff_it··on lsr: ls with io_uring
Allocator is an interface so you write library code only once, and then the caller decides which concrete implementation to use.

There's cases where you do want to change your code based on the expectation that you will be provided a special kind of allocator (e.g. arenas), but that's a more niche thing and in any case it all comes together pretty well in practice.

kristoff_it··on Zig's new I/O: function coloring is inevitable?
If you want to go down that route, any function that has, or doesn't have, any given resource is colored then.

   fn foo(db: *Db) !void { ... }
   fn bar() !void { ... }
Would you consider `foo` a blue function and `bar` a red function? That doesn't seem particularly helpful to me.

The virality of async await is that once you mark a function async, then you can only call it from another async function, which forces you to mark more functions async, which in turn means that if you want to use blocking I/O APIs then you just can't because it's incompatible with your execution model because by daring to express asynchronicity of operations, you were forcefully opted into stackless coroutines.

That's what Zig solves, and that's what is real function coloring. People have written reimplementations of the same libraries multiple times because of it.

https://github.com/redis/redis-py https://github.com/jonathanslenders/asyncio-redis

Just as an example. Note also how, coincidentally, this duplication of effort resulted in asyncio-redis being semi-abandoned and looking for maintainers. And you have to have both libraries because the asyncio one can't do blocking, and vice versa the other one can't do async.

Would you write two instances of essentially the same library just because one is missing an argument that gives it access to an `Io` interface? No, because you would just pass that extra argument around and nothing else would have to change.

kristoff_it··on Zig's New Async I/O
My mistake, I should have said Python then.
kristoff_it··on Zig's New Async I/O
> If this doesn't make the argument that Zig has certainly not defeated function coloring, I don't know what would.

if you're opting into stackless coroutines then yeah you're opting into their viral nature, but the point is that you don't have to. as the application author your dependencies won't opt you forcefully in using stackless coroutines (or any singular execution model), which is currently the case with other languages.

this is what it means to defeat function coloring.

kristoff_it··on Zig breaking change – Initial Writergate
Correct, which is also something that you want to do when creating Reader / Writer chains.
kristoff_it··on Zig's New Async I/O
> but IMHO people who sit down for a bit and think through the issue come to the same conclusion you have - Function coloring isn't a problem in practice.

I dunno man, have you seen people complain about async virality in Rust being annoying? Have you ever tried to read a backtrace from a program that does stackless coroutines (it's not fun)? Have you seen people do basically duplicate work to maintain a blocking and an async version of the same networking library?

kristoff_it··on Zig's New Async I/O
while not really idiomatic, as long as you let the user define the Io instance (eg with some kind of init function), then it doesn't really matter how that value is accessed within the library itself.

that's why this isn't really the same as async "coloring"

kristoff_it··on Zig's New Async I/O
we do build internal consensus before publishing articles like this one, or doing other public communication.
kristoff_it··on Zig's New Async I/O
I should have specified that better, of course async and await can be lowered to different things (that's what Zig does afterall), what I wanted to say is that that's how it works in general. JS is a good counter example, but for all other mainstream languages, async means stackless coroutines (python, ruby, c#, rust, ...).

Which means that if I want to use a dependency that uses async await, it's stackless coroutines for me too whether I like it or not.

kristoff_it··on Zig's New Async I/O
> (And before anyone mentions it, devirtualization is a myth, sorry)

In Zig it's going to be a language feature, thanks to its single unit compilation model.

https://github.com/ziglang/zig/issues/23367

kristoff_it··on Zig's New Async I/O
mlugg is in the Zig core team
kristoff_it··on Zig's New Async I/O
Here's a trick to make every function red (or blue? I'm colorblind, you decide):

    var io: std.Io = undefined;

    pub fn main() !void {
       var impl = ...;
       io = impl.io();
    }
Just put io in a global variable and you won't have to worry about coloring in your application. Are your functions blue, red or green now?

Jokes aside, I agree that there's obviously a non-zero amount of friction to using the `Io` intreface, but it's something qualitatively very different from what causes actual real-world friction around the use of async await.

> but the general problem behind function coloring is that of context

I would disagree, to me the problem seems, from a practical perspective that:

1. Code can't be reused because the async keyword statically colors a function as red (e.g. python's blocking redis client and asyncio-redis). In Zig any function that wants to do Io, be it blue (non-async) or red (async) still has to take in that parameter so from that perspective the Io argument is irrelevant.

2. Using async and await opts you automatically into stackless coroutines with no way of preventing that. With this new I/O system even if you decide to use a library that interally uses async, you can still do blocking I/O, if you want.

To me these seems the real problems of function coloring.

kristoff_it··on A software conference that advocates for quality
That's pretty much what it is, it's a reaction to an implosion that happened last year in the Handmade Network related to the Handmade Seattle conference which caused the conference organizer and the community leads to go separate ways.

https://handmade.network/blog/p/8989-separating_from_handmad...

https://handmadecities.com/news/splitting-from-handmade-netw...

kristoff_it··on Zig breaking change – Initial Writergate
For context this was presented, alongside other things, in the Zig Roadmap 2026 stream.

VOD: https://youtu.be/x3hOiOcbgeA

kristoff_it··on Features of D That I Love
> Zig's handling of unused variables seems like an unforgivably bad design choice to me. Its been raised by the community plenty of times. Why hasn't it been fixed?

Because yours is just an opinion. It's perfectly legitimate to not like unused variable errors, but its factually wrong to say that no one wants it. You're just yucking somebody else's yum.

> But does he seriously not have any smart people around him who he trusts who can talk him out of this design?

He does, most of them also like unused variable errors. For what it's worth, I do too.

kristoff_it··on Why is the Rust compiler so slow?
> As you've just demonstrated, that point can be made without even mentioning Zig, let alone copy/pasting some compile time stuff with no other comment or context. Which is why I thought (well, hoped) there might be something more to it than just a dunk attempt.

Having concrete proof that something can be done more efficiently is extremely important and, no, I haven't "demonstrated" anything, since my earlier comment would have had way less substance to it without the previous context.

The comment from Andrew is not just random compiler stats, but a datapoint showing a comparable example having dramatically different performance characteristics.

You can find in this very HN submission various comments that assume that Rust's compiler performance is impossible to improve because of reasons that actually are mostly (if not entirely) irrelevant. Case in point, see people talking about how Rust compilation must take longer because of the borrow checker (and other safety checks) and Steve pointing out that, no, actually that part of the compilation pipeline is very small.

> Now we get all of this off-topic discussion about Zig.

So no, I would argue the opposite: this discussion is very much on topic.

kristoff_it··on Why is the Rust compiler so slow?
How confident are you that memory safety (or lack thereof) is a significant variable in how fast a compiler is?
kristoff_it··on Why is the Rust compiler so slow?
I think the most relevant thing is that building a simple website can (and should) take milliseconds, not minutes, and that -- quoting from the post:

> A brief note: 50 seconds is fine, actually!

50 seconds should actually not be considered fine.

kristoff_it··on Why is the Rust compiler so slow?
Zig is starting to migrate to custom backends for debug builds (instead of using LLVM) plus incremental compilation.

All Zig code is built in a single compilation unit and everything is compiled from scratch every time you change something, including all dependencies and all the parts of the stdlib that you use in your project.

So you've been comparing Zig rebuilds that do all the work every time with Rust rebuilds that cache all dependencies.

Once incremental is fully released you will see instant rebuilds.

kristoff_it··on Rust compiler performance
> Speaking of DoD, an additional thing to consider is the maintainability of the compiler codebase. Imagine that we swung our magic wand again, and rewrote everything over the night using DoD, SIMD vectorization, hand-rolled assembly, etc. It would (possibly) be way faster, yay! However, we do not only care about immediate performance, but also about our ability to make long-term improvements to it.

This is an unfortunate hyperbole from the author. There's a lot of distance between DoD and "hand-rolled assembly" and thinking that it's fair to put them in the same bucket to justify the argument of maintainability is just going to hurt the Rust project's ability to make a better compiler for its users.

You know what helps a lot making software maintainable? A Faster development loop. Zig has invested years into this and both users and the core team itself have started enjoying the fruits of that labor.

https://ziglang.org/devlog/2025/#2025-06-08

Of course everybody is free to choose their own priorities, but I find the reasoning flawed and I think that it would ultimately be in the Rust project's best interest to prioritize compiler performance more.

kristoff_it··on Jepsen: TigerBeetle 0.16.11
That's a special case for sure, given the new fight for supremacy between the two forks, that said you can see in all those threads antirez bickering with the AWS people over exactly who introduced what.
kristoff_it··on Jepsen: TigerBeetle 0.16.11
> AWS will take your initial and ongoing investment in the implementation but they don't have to share theirs with you. Specifically, they will take your improvements but their own improvements (say some performance optimizations) they can keep to themselves. It's good business sense if it allows them to further differentiate their "improved" offering from your "vanilla" service.

In practice all I've seen from AWS is just to add integrations with their internal orchestrators and not much else. Back when I was at Redis Labs, AWS added TLS support to Redis and was dying to get that upstreamed (so that they wouldn't have to maintain the patch), except that as far as I understood nobody upstream wanted that code. In other words, hypothetical improvements by AWS (and other Clouds) are extremely overrated. When it comes to tigerbeetle, I would put the chance that they introduce bugs and vulnerabilities much higher than the possibility they add any meaningful improvement over what the actual experts (the tigrebeetle team) have already done.

> Do we really want to go through all of this with another vendor just for one extra service.

That's a great point, and in fact I've seen AWS purposefully offer insane (in Europe maybe we would say anti-competitive) discounts precisely to prevent Redis Labs from gaining market share. I'm sure they will try the same with TB once it becomes mainstream enough. What TB has that Redis doesn't have is the fact that it's a database designed for truly mission-critical stuff (i.e. counting the money) and maybe customers will be willing to go through the extra motions to ensure they get the best service they can (assuming TB will be able to provide that).

kristoff_it··on (On | No) Syntactic Support for Error Handling
It works really, really well, in part because it's also capable of tracking where an error is turned into another. And the error return trace ends where the stack trace begins (when an error is turned into a panic) so you don't even have to know what an error trace is, because it just makes sense intuitively.
← PreviousPage 3 of 21Next →