4 ms·
> So Go and JS are similar in that they are designed for heavily asynchronous tasks. But they do it very differently: Go has hordes of green threads "goroutines
by aikah 10y ago
> So Go and JS are similar in that they are designed for heavily asynchronous tasks. But they do it very differently: Go has hordes of green threads "goroutines", JS has callbacks all the way down.
concurrent tasks =/= asynchronous tasks.
A big difference is that Go doesn't force you to write asynchronous code for I/O operations, JS engines like nodejs do and it's a pain in the ass. Go only says : "If you want to write concurrent code you can do that", while NodeJS or browsers say :"Any I/O operation needs to be asynchronous and explicit".
If I call an API in Go, I don't have to care whether the computation will be executed in the same thread or not, or in 10 different threads, provided concurrency is encapsulated the right way. There is no amount of async/yield/promise that can mask any I/O operation with Nodejs on the other hand.
> As annoying as callbacks can be, they do fit the model basic GUI model very well:
This is a design decision. Gallium could have used channels instead of callbacks.
- sime2009 10y ago> A big difference is that Go doesn't force you to write asynchronous code for I/O operations, JS engines like nodejs do and it's a pain in the ass. Node also has a full set of 'normal' synchronous I/O operations (although they were added later after the async stuff).
- Klathmon 10y agoA bit of a nitpick, technically you can hide if a function call is async or not by `await`ing it. It will act the same when it's sync vs async. It would be a horrible idea to await everything, but it would work.