2 ms·
The function coloring is a non starter for me. I would just rather write JS where everything is async by default.
by throwawayffffas 1y ago
The function coloring is a non starter for me.
I would just rather write JS where everything is async by default.
- IshKebab 1y agoEverything is not async by default in JS.
- throwawayffffas 1y agoI mean everything is running on the runloop, async/await, promises, and callbacks are different flavors of syntactic sugar for the same underlying thing. In JS you can do: async function foo(){...} function bar(){foo().then(...);} In python though async and sync code runs in a fundamentally different way as far as I understand it.
- IshKebab 1y agoI'm not too familiar with Python async. The only time I used it was to get stderr and stdout out of a subprocess.run() separately. I think anyone using it for performance reasons is insane and should just switch to a more performant language. Anyway I think the main difference is that in Python you control the event loop whereas in JS there's one fixed event loop and you have no choice about it.
- fzzzy 1y agoI think what they mean is that there are no blocking functions in the standard library except alert, prompt, and confirm. ( are there any others?)
- steve_adams_86 1y agoYeah, you can call async functions without specifying it as such and the script will just carry on regardless of how you're handling it. Totally weird, but also pretty cool. When I first started some 20 years ago that was a major foot gun for me, coming from PHP where functions always returned before the next one was called.