5 ms·
Ugh, typing `await` for every command is terrible. JavaScript's async-by-default model is clearly not a good fit for this use case.
by mikevm 5y ago
Ugh, typing `await` for every command is terrible. JavaScript's async-by-default model is clearly not a good fit for this use case.
- lucideer 5y agoNot sure what this comment means. Javascript has no "async-by-default" model. The author of this library has chosen to make the "$" function they provide async; this isn't a JS design feature or limitation, it's just the lib author's choice.
- lhnz 5y agoI wonder if they could use some kind of magic to create synchronous versions of all async APIs (e.g. https://giuseppegurgone.com/synchronizing-async-functions/ https://giuseppegurgone.com/synchronizing-async-functions/) Although this would be fighting the language...
- tgsovlerkhgsel 5y agoRequiring it for every command by default sucks, but on the other hand, the ability to easily make scripts async is a huge benefit. I've seen so many cases of processes being synchronous simply because doing it differently would require an unrealistic amount of custom parallelism code.
- Too 5y agoI think the idea is that the majority of the script will be written in pure JS, with only occasional calls out to subprocesses, so “every command” is far from every line. You frequently see the same mental mismatch when shell-scripters try to use Python, and complain how hard it is to pipe with POpen, instead of using the built in string processing features.