Twitter | Search | |
Andrew Kelley
Friendly challenge for Go programmers: Provide or link to a small (50-200 ish lines) idiomatic Go program demonstrating concurrency. (Elegant use of goroutines, channels, etc) I'll provide the equivalent Zig program using async/await and std.event.Loop for comparison.
Reply Retweet Like More
shivamMg ॐ Oct 30
Replying to @andy_kelley
(not mine) concurrent implementation of sieve of eratosthenes:
Reply Retweet Like
Andrew Kelley Oct 31
Replying to @shivammamgain
thx for the example, here's a writeup for this one
Reply Retweet Like
Luke Champine Oct 31
Replying to @andy_kelley
Downloading a file from many hosts in parallel: I don't know if I would call this "elegant" per se, but it covers a lot of the territory (bounded concurrency, select, graceful shutdown, sending chans over chans) and it's a real problem, not a toy example.
Reply Retweet Like
Andrew Kelley Oct 31
Replying to @lukechampine
This is a great example. I'm going to work towards this one, but it's going to require several weeks of work to implement more networking in the std lib :-)
Reply Retweet Like
Brendan Hansknecht Oct 31
Replying to @andy_kelley
I would be interested to see what this looks like in zig: Specifically the fact.go file. Also, would be cool to see a speed comparison, but I don't know if zig has big int. When I wrote this, I remember the final multiplication being about half the time.
Reply Retweet Like
Andrew Kelley Nov 4
Replying to @bhansconnect
Follow-up for anyone subscribed to this thread:
Reply Retweet Like
Priya Srikumar Oct 31
Replying to @andy_kelley
Section 10.1: Concurrent matrix multiplication in Go. …. The use of runtime.GOMAXPROCS is necessary because Go's scheduler is flawed; curious to see how Zig improves upon this!
Reply Retweet Like
Protty Oct 31
Looks like the link returns a 404 here. On the other note, what makes Go's scheduler flawed?
Reply Retweet Like
gingerBill Oct 31
Replying to @andy_kelley
But it's not really an Apples-to-Apples comparison since they different concurrency models. One being synchronous, and the other asynchronous.
Reply Retweet Like
ʕ◉ᴥ◉ʔ Oct 31
That's an important point. Comparing idioms rarely goes into the apple-apple territory. Like in human languages, idioms in different languages generally mean the same thing, but completely different words and thought models are used.
Reply Retweet Like