Hacker News new | ask | show | jobs
by kens 1269 days ago
The article mentions using JavaScript in place of Python. I use JavaScript a lot for browser stuff but can JavaScript be used for the random command-line scripts that I implement in Python? (Genuine question, not rhetorical.)
4 comments

Node is an interpreter just like Python, gives access to OS features like sockets, file systems and processes, so yes, you can.

However I’d rather not if you value your sanity and want to use typescript, because then you introduce packages and compilers and the whole npm ecosystem which makes building C++ look easy and sane.

It is the first time I see gyp being called easy and sane.
To build what I’m currently working on it is required to use docker, pnpm, npm, nx, tsc, corepack and nvm. I think. Not sure at all. I haven’t built some parts of the project. There’s more involved to run most tests.

Something went off the rails at some point.

I use Node.js/TypeScript for all my scripting needs. Together with pm2 which can auto-generate a systemd service if it needs to run as a service on boot. Coming back to a strongly typed project / script is actually really beneficial to refactor or extend.
Node.js can be used for command line scripts. Its chromes v8 JavaScript engine strapped to an API for interacting at the system level.
Yep.