Live data from Hacker News

Zig: Upcoming release postponed two more weeks and lacks async functions

ziglang.org

31–40 of 62 posts

Re: Zig: Upcoming release postponed two more weeks and lacks async functions

#31
post #28

Earlier quoted context omitted.

https://kristoff.it/blog/zig-colorblind-async-await/

I can't tell from the examples. Does Zig's async support closures or is it strictly out of order execution?

It's similar to manual control over the current stack. You pause execution, you dump your current stack onto the heap, and restore it later. Control over concurrency, similar to out of order execution. I'm describing it conceptually but I assume the implementation can be/was smarter/faster.

I don't think closures have anything to do with it.

There was also some debate about how cancelation of an awaitable function built with those primitives would work. I don't think there was a great answer for that yet.

Re: Zig: Upcoming release postponed two more weeks and lacks async functions

#32
post #25

Earlier quoted context omitted.

Waiting for IO is never cool. Also, zig's version of async is pretty low level and still obeys the no hidden control flow mantra (at least how it was implemented until 0.9.0).

How the heck would that even work... In C#, they implement Await/Async by converting the function into a Class, just like when you use 'yield return'. Control flow is all over the place. Zig is so strict about "no hidden control flow" that you can't even have destructors (code which runs when a variable goes out of scope)

Yup. The lack of destructors means that at the time there wasn't an agreed upon way to cancel an awaitable function. Async/await in zig was cool, but there's a reason why it's described as an experimental feature in the article.

Re: Zig: Upcoming release postponed two more weeks and lacks async functions

#33
post #6

Earlier quoted context omitted.

> At least until LLMs bury your platform in noise. Curious, but how exactly would they do that? Are you talking about scraping your website and adding garbage filler content from LLMs and republishing to divert traffic?

Oh, I just mean like filling the web with so much garbage that nobody can find your website.

It’s gotten really bad over the past few months, but even before GPT was a thing scummy operators just used Mechanical Turk or Fiverr.

I don’t understand why Google is doing so poorly at filtering it out: for a concrete example, searching for terms relating to common semi-trivial problems when programming mainstream platforms like the web, Java, or C# will now result in low-quality, non-authoritative sites like GeeksForGeeks - or even W3Schools always coming up first, with authoritative sources like MDN, the W3/WHATWG, even StackOverflow sometimes being below-the-fold.

Re: Zig: Upcoming release postponed two more weeks and lacks async functions

#34
post #29
post #25

Earlier quoted context omitted.

How the heck would that even work... In C#, they implement Await/Async by converting the function into a Class, just like when you use 'yield return'. Control flow is all over the place. Zig is so strict about "no hidden control flow" that you can't even have destructors (code which runs when a variable goes out of scope)

Huh? Lots of language do not have guaranteed to be called at a specific time “destructors”. Additionally, zig provides this functionality with defer and errdefer, giving you the ability to explicitly call a function at the end of scope.

> Lots of language do not have guaranteed to be called at a specific time “destructors”.

Those tend to be GC languages though, where deterministic execution is not a hard requirement.

Re: Zig: Upcoming release postponed two more weeks and lacks async functions

#35

Earlier quoted context omitted.

Zig's async, like Lua's, lets people write libraries that are generic over async-ness by default. "dump my registers and jump to another stack" is also a legitimate move in assembly (though that's not how this implementation actually works).

I understand the technical reasons (caused by cultural reasons) why Python ended up with colored async but man oh man was it a bad choice for a high-overhead language to do that…

(you’re referring to this article [1], right?)

What alternative approach would you have preferred Python do? While I’m not a fan of the coloured-function approach either, I can’t think of a better alternative that checks-off the most boxes (Java’s Loom looks interesting but in-a-way it seems too-good-to-be-true to me, while low-cost approaches like Zig’s would introduce too much complexity for novice users and people wanting something that just-works)

[1]: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...

Re: Zig: Upcoming release postponed two more weeks and lacks async functions

#38

Earlier quoted context omitted.

I understand the technical reasons (caused by cultural reasons) why Python ended up with colored async but man oh man was it a bad choice for a high-overhead language to do that…

(you’re referring to this article [1], right?) What alternative approach would you have preferred Python do? While I’m not a fan of the coloured-function approach either, I can’t think of a better alternative that checks-off the most boxes (Java’s Loom looks interesting but in-a-way it seems too-good-to-be-true to me, while low-cost approaches like Zig’s would introduce too much complexity for novice users and people…

gevent?

Re: Zig: Upcoming release postponed two more weeks and lacks async functions

#40
post #29

Earlier quoted context omitted.

Huh? Lots of language do not have guaranteed to be called at a specific time “destructors”. Additionally, zig provides this functionality with defer and errdefer, giving you the ability to explicitly call a function at the end of scope.

> Lots of language do not have guaranteed to be called at a specific time “destructors”. Those tend to be GC languages though, where deterministic execution is not a hard requirement.

Sure, but this is also what defer is for.

There isn’t implicitly called destructors because the languages mantra is “no hidden control flow”. RAII et semantics is almost entirely hidden control flow that you just have to “know”.

Lots of people hate when they need to “just know” things to fully parse the code they’re reading.

You’re free to dislike those decisions, of course. Personally, I like the target of no hidden flow.

Post reply on HN