|
|
|
|
|
by bluepnume
859 days ago
|
|
This might be a silly question, but what would be the downside of a single threaded language similar to javascript, but where every function is just 'async capable' and can always be non-blocking, with no special syntax like async/await? So every time you call foo(); you anticipate that it might resolve immediately, or it might take some time, but it won't block any other function (unless it actually does some cpu bound operation) And any time foo(); does something asynchronous, all of its callers, and its callers callers, become implicitly asynchronous too. Of course you would have to have some primitive for when you actually want to do several things concurrently within the scope of a single function rather than blocking that function, but that doesn't sound too bad and in JavaScript you effectively need to use Promise.all most of the time anyway. I'm sure there's some major downside I'm missing -- but what is it? |
|
Where this breaks is with FFI: if you cannot intercept blocking calls in foreign functions, you block useful threads or even deadlock. This is what the quote in the article is about:
> The cost for the native compatibility with the C/system runtime is the “function coloring” problem.