I had very strong anti-javascript opinions for the longest of times, and still feel that writing any non-weekend-project in JS is a mistake.
That being said, I have grown very fond of writing "plumbing"-scripts in nodeJS.
The syntax is so much more sane than bash, the documentation of nodeJS is actually pretty good in my opinion, and once nodeJS is installed and available, its super easy to mash something together to get working. For small scripts, the uglier parts of JS do not really matter, and while nodeJS does have some APIs that feel a bit odd to use at times, it's at least well-documented with examples/guides all over the web.
Some folks use python for that exact purpose, but I always felt that getting something going takes me more effort than nodeJS (the fact that I'm just not fond of Python as a language might also have something to do with this).
All in all... for folks still using bash, I really recommend to give JS a try.
I prefer Python for this because more OSes ship with it, it has a fairly rich standard library, and SREs are more comfortable with it, so you're more likely to find others using it as glue.
Agree, but it would be nice to have access to the entire composer community without setting up a composer environment, so not to toot my own horn, but I wrote proof of concept script to download PHP composer dependencies by parsing comments from the PHP script itself.
> I prefer Python for this because more OSes ship with it, it has a fairly rich standard library,
I mean nodejs =/= javascript, the problem is nodejs and some of the people who designed it who basically made it so that it would rely heavily on NPM, a commercial solution, thanks to the virtually non existing standard library. Now Microsoft virtually owns Nodejs since it owns NPM. Nodejs creator himself regretted this decision, publicly.
For what I called "plumbing"-scripts above, I rarely ever need any dependencies via npm. What nodeJS delivers out of the box suffices completely.
Sure, doing things like http directly with node is a bit cumbersome and having a library that does some abstraction comes in handy if you're working on something that goes way beyond what you'd ever consider doing in bash. But especially for that very purpose of things where I used nodeJS instead of using bash, nodeJS always had everything I needed out-of-the-box, almost never required any dependencies.
That being said, if you re-use code, plan to share scripts etc. with other people and all these things - using something like typescript (and possibly some testing-libraries) comes in very handy for maintainability, and there you can't get around npm.
But for one-off-"plubming-scripts", nodeJS had all I ever needed.
TS is probably my favorite language out there, so yes, I definitely did :)
But just for "one-off"-scripts, JS usually does the job pretty well. For bigger scripts or scripts where I want to reuse/share parts, typescript is an option - but it comes with a few hurdles: Most of the scripts I'm talking about work with zero npm-dependencies, while typescript adds at least one.
Furthermore, I either have to take care of compiling it, or use ts-node - one more dependency; and in both cases, I can't avoid the usual es6 vs. commonJS shenanigans.
It's a bit of overhead to get going; always worth it if I spend more than a few hours on a script, but I can do without if it's just a few lines that I will hardly ever see again.
I think Deno may be a good choice in this use case: single binary that has a good standard-lib makes it seem like a good candidate for simple shell and pipeline scripting.
> Why is Javascript a « perfect choose » for shell scripts?
It isn't, that project looks like perl re-invented but worse, since it mixes Javascript via nodejs and shell script syntax.
Shell scripts already support loops, functions, conditions, variables, ... it makes more sense to write a nodejs script that works as a regular shell process and include it in a shell script than the other way around...
JS is the most used language for web development both client and server side.
It's easy to find fullstack repos with only JS code and a bunch of shell scripts to launch the tooling like webpack bundler and cypress e2e tester.
By wrapping the tooling also in JS it's possible to take advantage of shared configuration written in JS and write reusable functions to share across scripts.
Currently I have all my tooling scripts in bash (not yet in JS) and it's becoming hard to manage. Sharing functions and constant values across folders in shell bash script is very cumbersome.