News for hackers. Stuff that matters.
Re:The Zig and Go Programming Showdown by username-404 on Friday October 28, 2022 @03:57AM (#33368785)
Go handles concurrency via goroutines whereas in Zig... I couldn't find any available information. All it says in their docs "it's an area of active research".
Re:The Zig and Go Programming Showdown by kristoff_it on Friday October 28, 2022 @05:32AM (#33369362)
Thank you for asking!

Zig has stackless coroutines, I wrote a blog post that explains how it all works at a high level:

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

Re:The Zig and Go Programming Showdown by armitron on Friday October 28, 2022 @08:57AM (#33370799)
"I think goroutines are preferable in that context because async/await is a much lower level tool that is easy to misuse, but when it comes to writing code with critical requirements of correctness and efficiency, you need async/await and you need Zig’s philosophy that we all should strive to write robust, optimal, and reusable software."

I don't see how this follows. Async/await is a disaster in every way, M:N threading (which Goroutines are an implementation of) is the way to go. Not only does one get sane concurrency but also parallelism. Look at Ada tasks and Erlang processes for writing parallel code with critical requirements of correctness and efficiency.

Re:The Zig and Go Programming Showdown by kristoff_it on Friday October 28, 2022 @09:17AM (#33370992)
Goroutines (and stackful coroutines in general) require a runtime. Go has to sprinkle suspension points everywhere in the machine code (to prevent starvation) and when it needs to grow a goroutine stack, it also needs to know how to adjust every single relevant pointer in the entire program's memory to point to the new stack location.

This is not something that a systems programming language would want to do. I agree with your point that structured concurrency is good and preferable for high-level languages, but it's not an absolute better choice when you start thinking about the details, like you have to do in a systems programming language.

Re:The Zig and Go Programming Showdown by socialdemocrat on Friday October 28, 2022 @01:16PM (#33374342)
Agree, while I prefer the Go model from a usability perspective, I don't think that is the way to go for a language such as Zig. Zig seems to have done a really good job within the boundaries set by a language which aims for minimal level of abstraction.