Comment

Comment by spinningslate

> The difference is that in Go you are expected to explicitly send the result via a channel or some other data structure and then synchronize the completion of the execution, where-as with tasks you simply await that.

That may be be the case in Go but it's not an inherent property of green threads. See, for example, Gleam Tasks [0] which are based on green threads and provide the syntatic convenience of being able to await the result rather than receiving a message:

    let task = task.async(fn() { do_some_work() })
    let value = do_some_other_work()
    value + task.await(task, 100)
They do so without the disadvantage of bifurcating the code base into sync and async functions.

[0] https://hexdocs.pm/gleam_otp/gleam/otp/task.html

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton