Hacker News new | ask | show | jobs
by bmn__ 1978 days ago
It is not okay to continue to sow doubt. I require you taking eight minutes to download the language and validating/disproving the claims.
1 comments

That is your opinion. Mine is that it is okay to "sow doubt", similar to that it is okay to "sow doubt" when someone claims they built a perpetuum mobile.

But since you are asking me to download the language so politely: I think this is not necessary. A look in the documentation (https://docs.raku.org/language/concurrency) seems to be enough:

> The subroutine await is almost equivalent to calling result on the promise object returned by start but it will also take a list of promises and return the result of each

So "await" is equivalent to calling "result". What does calling "result" do?

> result blocks the current thread of execution until the promise is kept or broken

This stands in direct contradiction to what was said in the thread here:

> so while the code containing the `await` blocks and waits, the underlying thread/core is released

Unless the OP referred to a _different_ await, I would say: case closed.

(Edited to fix footnotes)

> blocks the current thread of execution

That's a green thread.[1]

To quote Wikipedia[2]:

> a thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler

This is the definition the doc is using.

The thread of execution that is blocked is a green thread -- the sequence of instructions containing the `await` that is managed by a scheduler managed by Raku.

> This stands in direct contradiction to what was said in the thread here:

>> so while the code containing the `await` blocks and waits, the underlying thread/core is released

> Unless the OP referred to a _different_ await

No, what I meant by "underlying thread/core" is an OS thread as against a green thread, and what I meant by "released" wasn't that it was released back to the OS but instead that Raku's scheduling sees the `await`, blocks the enclosing green thread, and immediately unblocks some other green thread by "stealing"[3] the OS thread to run that other green thread instead.

I hope I've now reassured you that Raku(do) both eliminates the red/blue distinction and doesn't block OS threads.

Yes, it's unusual among PLs. No, it's not easy to design a PL to do this at a language level. Nor is it easy to implement. (For example, the Rakudo implementation involves taking a continuation[4].)

But it is possible, and Raku has never had the red/blue distinction, and has had work stealing semantics for `await` since 2018.

[1] https://en.wikipedia.org/wiki/Green_threads

[2] https://en.wikipedia.org/wiki/Thread_(computing)

[3] https://en.wikipedia.org/wiki/Work_stealing

[4] http://jnthn.net/papers/2018-concurrency-guts.pdf#page=67