3 ms·
Main differences from zx: - YavaScript is waaaay smaller. zx and its dependencies are 16.3MB, and they depend on Node.js, which is 156MB. zx also requires a lo
by suchipi 3y ago
Main differences from zx:
- YavaScript is waaaay smaller. zx and its dependencies are 16.3MB, and they depend on Node.js, which is 156MB. zx also requires a local node_modules folder which can be inconvenient in some cases. YavaScript is a single ~3MB file with no external dependencies.
- YavaScript isn't based on Node.js; it uses a custom QuickJS-based engine for code execution. This allows it to hook deeper into the engine for additional features (like builtin support for TypeScript), and also means it is wayyy smaller.
- YavaScript's APIs are generally synchronous, whereas zx's APIs are generally asynchronous. I did this because I believe synchronous APIs are more similar to normal shell scripting, and because peppering `await` everywhere feels silly when the script is going to execute things serially 95% of the time. There are still asynchronous APIs available in YavaScript, though, including Web Workers.
- jauntywundrkind 3y agoThe size equation is definitely different if you do/don't have nose.js installed & in your package cache. But for many devs that use this stuff anyhow, with some of the modern package manager techniques especially (as pioneered by yarn), the size isn't really a big penalty. Zx also does not require a node_modules folder at time of use. There is an --install option to avoid having to pre-install dependencies. https://google.github.io/zx/cli#install https://google.github.io/zx/cli#install There's the old shell.js, from Mozilla originally, which too was mostly synchronous. It has a bit of an impact for a while, but the lack of async support was, over the long term, imo, it's doom.