3 ms·
much respect to ryan for coming out like this. i used to think that he might have thought node was the bee’s knees and that callbacks and promises were sent fro
by jaequery 8y ago
much respect to ryan for coming out like this. i used to think that he might have thought node was the bee’s knees and that callbacks and promises were sent from the gods. glad to hear him confirm what a lot of js devs are feeling right now with the wretchedness of the js callbacks, promises, and generators. there is a better way and im glad he is trying to do something about it.
- tlrobinson 8y agoPromises (with async/await) aren't so bad. He explicitly says he regrets taking promises out of early versions of Node.js.
- Guillaume86 8y agoHe looked pretty ok with async/await (which uses Promises under the hood), one of the advertised features of his new project is top level await.
- spankalee 8y agoWhich is unfortunate. Top-level await is a very bad footgun and should almost never be used.
- tlrobinson 8y agoCan you elaborate? It seems useful for simple scripts and REPLs, at least.
- lostctown 8y agoIt is useful for those things. I implemented a fairly involved scripting system that we now use inside all of our server instances. Each script in the system is an entry file mapping to an alias command and the entry file is invoked from the top level. To get the benefits of async/await, we write the logic of each entry script under main = async () => do_logic(), and call it at the end of the file as main(). I just don't see how this workaround is the correct solution. Just saying that's it's generally a bad idea is not enough for me. At some point there will come a time when you want to treat a file as a function, and when that day comes you will want async/await at the top level.