Hacker News new | ask | show | jobs
by rauschma 684 days ago
I have used many languages in my nearly 40 years as a programmer (Scheme, C++, Java, Python, Haskell, OCaml, Rust, etc.) and still enjoy JavaScript: It’s decent as a language and there is so much you can do with it.

Tips:

• If you like static typing, you’ll want to use TypeScript. It’s more work to set up, but it catches many bugs, especially subtle ones where JavaScript’s semantics are not intuitive.

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

My books on JavaScript, TypeScript and Node.js shell scripting are free to read online and target people who already know how to program: https://exploringjs.com

3 comments

> If you like static typing, you’ll want to use TypeScript. It’s more work to set up, but it catches many bugs, especially subtle ones where JavaScript’s semantics are not intuitive.

It’s worth looking at JSDoc as an alternative to regular TypeScript. No compiler to set up, and you’re restricted in a good way - less likely to get over-engineered types.

I find writing it too hard compared to TS, but in terms of functionality it's pretty good.
How does your book Deep Javascript compared to You Don't Know Javascript? I just finished a Eloquent Javascript and looking for something advanced.
> 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`