3 ms·
Promises aren't inherently an "inner platform". You can certainly make them part of the "base language", like Rust. JavaScript didn't have async functions and p
by xiaq 5y ago
Promises aren't inherently an "inner platform". You can certainly make them part of the "base language", like Rust. JavaScript didn't have async functions and promises in the beginning, but it integrates with the rest of the language and runtime well enough to not feel like something tacked on (well, at least by the standard of JavaScript language design :). Whether async function + promises is a better model than goroutine + channels is another issue.
What you said is accurate in the context of Go though. Having promises in Go will create an "inner platform". If one wants to nitpick, there may be certain workloads that would perform better with async functions and promises, but the design philosophy of Go would happily trade a small amount of performance for simplicity.
- jerf 5y ago"Promises aren't inherently an "inner platform". You can certainly make them part of the "base language", like Rust." That's fair, and I will try to update my internal mental model and stop unconditionally referring to them as such. Thank you. (My primary objection to them is the way they throw away the stack and throw away structured programming as a result, but they're at least less bad if they aren't also an inner platform. :) )
- Nullabillity 5y ago> My primary objection to them is the way they throw away the stack and throw away structured programming as a result, Structured concurrency is orthogonal to whether you're using a thread-based or monadic API. Goroutines, for example, are both thread-based and unstructured. On the other hand, you can have concurrency that is structured but still thread-based (like Trio), unstructured but monadic (like Scala's built-in Future type), or both structured and monadic (like Rust's Future type).
- Zababa 5y agoI think promises are a inner platform in Rust and JS, due to the function coloring problem. They are a different world that you can't escape from. In the async book from Rust [1]: > Asynchronous and synchronous code cannot always be combined freely. For instance, you can't directly call an async function from a sync function. Same with JavaScript from [2]: > The await operator is used to wait for a Promise. It can only be used inside an async function within regular JavaScript code; however it can be used on its own with JavaScript modules. In JS, the promise world is a different world. Exceptions won't work like they usually do for example. [1]: https://rust-lang.github.io/async-book/01_getting_started/03_state_of_async_rust.html https://rust-lang.github.io/async-book/01_getting_started/03... [2]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...