News for hackers. Stuff that matters.
Re:Zig's new plan for asynchronous programs by debugnik on Tuesday December 02, 2025 @10:33AM (#46122229)
> Languages that don't make a syntactical distinction (such as Haskell) essentially solve the problem by making everything asynchronous

What the heck did I just read. I can only guess they confused Haskell for OCaml or something; the former is notorious for requiring that all I/O is represented as values of some type encoding the full I/O computation. There's still coloring, just generalized, and so is there in Zig's new solution.

Plus, isn't Go the go-to example of this model nowadays?

Re:Zig's new plan for asynchronous programs by gf000 on Tuesday December 02, 2025 @10:49AM (#46122424)
Haskell has green threads. Plus nowadays Java also has virtual threads.
Re:Zig's new plan for asynchronous programs by debugnik on Tuesday December 02, 2025 @10:51AM (#46122449)
And I bet those green threads still need an IO type of some sort to encode anything non-pure, plus usually do-syntax. Comparing merely concurrent computations to I/O-async is just weird. In fact, I suspect that even those green threads already have a "coloring" type, although I can't check right now.
Re:Zig's new plan for asynchronous programs by iviv on Tuesday December 02, 2025 @02:28PM (#46125530)
Pure actions can be run in parallel with https://hackage-content.haskell.org/package/parallel/docs/Co...

Impure actions use the IO monad like always in Haskell: https://hackage.haskell.org/package/base-4.21.0.0/docs/Contr... (or the higher-level async library)

I suppose an extreme version of the function coloring argument could be that all types are colors.

Re:Zig's new plan for asynchronous programs by debugnik on Tuesday December 02, 2025 @05:32PM (#46127859)
In a sense, kinda? The function colour problem is that you can't call an async API from a non-async caller without modifying the entire call chain (or blocking the full thread). In async/await languages the conflict comes from changing the return types; the syntax is orthogonal.

Maybe in practice some properties of code are better off being whole-program than represented as types, even if they're less modular or harder to check.

Also thanks for the reference, I haven't touched Haskell in ages; I'm more of an F# and OCaml guy.

Re:Zig's new plan for asynchronous programs by iviv on Wednesday December 03, 2025 @02:49PM (#46139109)
Right. In Haskell we want to maintain the pure/impure distinction so… it’s not a problem I guess?
Re:Zig's new plan for asynchronous programs by instig007 on Wednesday December 03, 2025 @07:21AM (#46133681)
> And I bet those green threads still need an IO type of some sort to encode anything non-pure, plus usually do-syntax.

There's no need for the do-syntax at all. The (IO a) is no different to other generic types that can be fmap-ed, pointfree-composed with other expressions, and joined/folded when required. The only difference is the fact that they represent actions that affect the real world, so that ordering of things suddenly becomes important.

Re:Zig's new plan for asynchronous programs by debugnik on Wednesday December 03, 2025 @12:17PM (#46137145)
Right, and there's also no need for await syntax at all, they can be then-ed, ContinueWith-ed or whatever the language calls them, but people keep bringing syntax into a semantics battle, so I had to mention it.