By CPS do you mean lightweight threads + meeting point channels? (i.e. both the reader and writer get blocked until they meet at the read/write call) Or something else?
Why is CPS better and lower level than async/await?
Why is CPS better and lower level than async/await?
I guess its pure luck if the io implementation can handle both, but who knows?
I think it's common sense to not interweave IO with long-running CPU, hence sans IO.
If you want to go that route, we already have solutions: goroutines and beam processes.
With CPS you may send and receive many times over to whomever and from whomever you like.
In JavaScript you may write..
const fetchData = async () => {
// snip
return data;
}
const data = await fetchData();
And in Go you might express the same like.. channel := make(chan int);
go func() {
// snip
channel <- data;
}()
data := <-channel
But you could also, for example, keep sending data and send it to as many consumers as you like.. go func() {
for { // Infinite loop:
// snip
channel1 <- data;
channel2 <- data;
channel3 <- data;
}
}()