Skip to content

Comment on Ask HN: Changing my mind about JavaScriptparent

Comments

I learned a lot about JavaScript (and Node.js) by writing shell scripts in Node.js.

Totally! This will give you lot of insights into low-level working of JS. Of course, some Node.js specifics too. Reading from STDIN, parsing strings into structured data etc.

For writing shell scripts in Node, there’s a helper library called zx created by Google.

I find it a lifesaver for the common occasion when I’m tempted to write a bash script but also know it’s going to need some slightly more advanced features (as in parsing a JSON, or just arrays that are not totally bonkers in syntax).

Yes, I was about to propose this. But then again, the author wants to learn the basics without grappling with abstractions. I think zx can be a bit quirky.

For sure there's an element of magic to zx. The use of tagged template literals doesn't look like plain JavaScript even though it's standard.

You need to understand async/wait, promises and tag functions to make sense of this basic zx example:

  await $`ls -la`
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.