Live data from Hacker News

ZX – A tool for writing better scripts

github.com

91–100 of 143 posts

Re: ZX – A tool for writing better scripts

#91
post #35
post #31

Earlier quoted context omitted.

One (admittedly obvious) difference is that it runs on Node/V8 instead of Bun/JSC.

can you elaborate the difference, besides the different names of the runtime?

I think you’ll find far better answers than I can provide with a web search.

Re: ZX – A tool for writing better scripts

#92
post #77

It looks like people don’t get it. This isn’t “better” than your tool of choice. This is a tool for JavaScript developers to write non-trivial scripts in a portable way without getting lost in POSIX hell. Who came up with this stuff? https://stackoverflow.com/a/13373256 If you can write shell code, Perl, Python, COBOL, suit yourself. This is for JavaScript developers in JavaScript projects.

Here's an example: https://gitlab.com/vincenttunru/penny/-/blob/main/scripts/bu... That used to be a shell script. But this I can way more easily read (even after not touching it for a long time), I get autocompletion, and I can use the APIs I'm already familiar with. It's a pretty neat QoL improvement for me specifically.

What’s with all the await-stuff? Couldn’t it be written just straight forward?

Re: ZX – A tool for writing better scripts

#93

It looks like people don’t get it. This isn’t “better” than your tool of choice. This is a tool for JavaScript developers to write non-trivial scripts in a portable way without getting lost in POSIX hell. Who came up with this stuff? https://stackoverflow.com/a/13373256 If you can write shell code, Perl, Python, COBOL, suit yourself. This is for JavaScript developers in JavaScript projects.

Maybe it should say that somewhere.

Re: ZX – A tool for writing better scripts

#94
post #50

Well this doesn't make much sense. If you rightfully find bash inadequate at some point, just switch to the next most natural tool - Python. Nobody's going to be surprised when they see a Python script. If you start feeling Python is inadequate too, then: 1) You're wrong, just stick to Python 2) If you're so bent on doing away with familiarity, at least get as much leverage as you can in return and use a "proper" lan…

Yes, but this isn't made for general scripting. This project seems to be aimed at JavaScript projects, for example calling zx from package.json/scripts/start

If I had a JavaScript project, and I wanted to migrate my scripts away from Bash, I wouldn't pick Python. Not only would it be another language, I would also have to configure Python to run correctly, ie add it to my Docker image.

Simply installing another NPM package, rather than include an entire other language is a much better and simpler solution.

Re: ZX – A tool for writing better scripts

#95
post #52

Very nice. You need three clicks to get tho the documentation, yet they don't explain anything. What does the const line do ? The best thing however is that it is not supported by Google.

> What does the const line do ?

To declare variables?

> The best thing however is that it's not suppported by Google

That's the case with many things like zx.

Re: ZX – A tool for writing better scripts

#96
post #92
post #77

Earlier quoted context omitted.

Here's an example: https://gitlab.com/vincenttunru/penny/-/blob/main/scripts/bu... That used to be a shell script. But this I can way more easily read (even after not touching it for a long time), I get autocompletion, and I can use the APIs I'm already familiar with. It's a pretty neat QoL improvement for me specifically.

What’s with all the await-stuff? Couldn’t it be written just straight forward?

That allows other code to run while e.g. files are being moved. It indeed can be somewhat painful ([1] is the classic criticism) and in shell scripts is not as beneficial. I think there are even sync alternatives (i.e. equivalent functions that don't need `await`) for most of them, but again: these are the APIs I'm already familiar with, which is the entire point - and thus the await-stuff comes naturally for me, because I intuitively know those APIs are async.

[1] https://journal.stuffwithstuff.com/2015/02/01/what-color-is-...

Re: ZX – A tool for writing better scripts

#97
post #68

Earlier quoted context omitted.

Likewise! I use TypeScript everywhere possible, and zx is a godsend. Unfortunately, I've recently dealt with gobs of Python for ML software. After years of writing TypeScript, it's been a...sobering reminder of many painful coding issues that I'd forgotten even existed. Made me deeply appreciate what TS gives us haha.

Would a python developer feel the same in reverse?

If they'd go to JavaScript, they'd feel a sense of unfamiliarity similar to what JS developers going to Python would feel.

But the Python equivalent of TypeScript is mypy, and I don't think it's controversial to say (even among Python developers) that it's way behind TypeScript, generally.

Re: ZX – A tool for writing better scripts

#98
post #75

"[For writing complex scripts] JavaScript is a perfect choice". Not sold on that. Why should I choose it over Python, PHP or others?

Because you (i.e. I) already use it and have the full toolchain set up for your project?

100%

Use whatever you're proficient in. For A LOT of devs that means js.

Why spendtime pulling python into my js project?

Re: ZX – A tool for writing better scripts

#99

"[For writing complex scripts] JavaScript is a perfect choice". Not sold on that. Why should I choose it over Python, PHP or others?

Modern js is not what it was. Ergonomics of nodejs v20 are not in the same ballpark as node v6. A lot has happened since v12 even.

Js definitely has become a pleasant language to script in. And it's sooooo much faster that python and Ruby.

Post reply on HN