Hacker News new | past | comments | ask | show | jobs | submit login

ShellJS was a delight to use when we had to build a cross platform Electron-based (sorry) desktop application for Mac and Windows. It replaced batch and shell scripts, async operations were easy thanks to NodeJS, and the scripts were maintainable. 8/10, would use again.

I feel like Node being "async-first" is such an underrated feature, compared to its big competitors (Python, Ruby, Perl). I really don't some of the Javascript quirks, but Node is a great general-purpose scripting tool as a change of pace from Python.

Edit: I know we're not supposed to talk about voting on HN, but really? -2 for saying "hey maybe NodeJS is actually kind of OK for some stuff" is wild.

Except the first two commands I looked at the implementation for were implemented as sync IO calls (and one of them was “cat” which is implemented as a sync read of the entire file).

I don't think "async-first" is really all it's cracked up to be. It's great for concurrent I/O (webservers). Not great for writing run-of-the-mill sysadmin scripts like rotating log files, doing file backups, etc. Now instead of just knowing that your cron job is doing something one at a time, suddenly you have all these async things happening and you look at your process table and there's 40 node.js processes trying to compress every log file in the system all at once.

And if you don't want it to do that then you have to start managing the concurrency yourself. I've never had to manage concurrency in a shell script beyond just making sure my crons don't run over each other if they take too long.

You’re conflating concurrency and parallelism. Unless you’re explicitly forking the process, the async all happens in one process.

Async is incredibly easy to manage in node, even the simplest linter handles telling you you’re forgetting to await if you are.

GP does have a good point though, single-threaded concurrency is still concurrency.

> you look at your process table and there's 40 node.js processes trying to compress every log file in the system all at once

This is what GP said, which is incorrect.

You can do it all synchronously in node if you wish. The async gives another dimension to work with.

One thing I wish Windows developers did more was bundle Busybox, a 1.6mb binary, to run shell scripts with bashisms, rather than use batch files, powershell or other alternatives.

If Microsoft had only put all the PowerShell for Linux resources into Busybox.

MSYS2 is also pretty comfy. But that audience is probably better served by running WSL2.

> bundle Busybox, a 1.6mb binary, to run shell scripts with bashisms

What do you mean? Busybox doesn't come with bash so it wouldn't work with bashisms.

Busybox works with some bashisms.

This reminds me of a web hosting/managed colocation company I worked for back in the early 2000s. They pretty much only had unix sysadmins so basically every windows box got cygwin and activestate perl because it was really the only thing these guys knew how to use. Nobody ever bothered to learn how to script a windows machine. PowerShell was still in its infancy. But nowadays I don't think it's really appropriate to not use the platform-native tools to administer the machine.

Imagine installing windows powershell on debian because you don't know how to write unix shell scripts.

Cygwin is still utterly amazing fwiw. It's the only thing that keeps me sane in windows when WSL2 isn't able to do what I need it to do.

PowerShell is so bad though, absolutely zero people do that. PowerShell for Linux is a straight up butt of jokes at Microsoft for having zero DAU.

Why? While it’s not as good as bash or zsh as an interactive shell, for scripting it has a saner syntax, without all the weirdness that bash has. Also powershell can access basically any .net api, and thus can do things like serialise json objects built in, without learning external tools like jq.

> While it’s not as good as bash or zsh as an interactive shell

That's the problem though. For me it totally sucks as an interactive shell because it's far too verbose. And if I needed to write scripts on Linux then I'm already spoilt for choice: Perl, Python, Tcl, Awk, etc are all usually pre-installed with my Linux distros. Then you can add Ruby, Go, Javascript (via Node), PHP, Rust, C++ and any .NET languages like C# into the mix too....plus many many many more.

While byte streams are largely seen as a joke compared to typed pipes like in Powershell and Murex, you do have far greater compatibility with byte streams since all you're sending is bytes -- which means you can write scripts in whatever the hell you want and still use them in Bash / Zsh just fine.

Then you have the 40 years of coreutils. People talk about legacy as being cruft and while there is some truth in that, there's also truth in the fact that if you need to do something in the command line, there's probably already a tool written which does it. That comes from maturity.

Don't get me wrong. There is a lot I'd like to change with regards to command line usage and shell scripting (and I'm working on that ;)) but Powershell throws the baby out with the bath water. Though in fairness to Microsoft, they never quite had a mature command line prior to Powershell so there was no baby to throw out. But for Linux usage....no thanks.

> PowerShell is so bad though

Care to elaborate?

I’m stuck with Windows for bean counting reasons, and though I resent it I feel I would benefit from actually learning to make full use of it. But maybe it’s not worth the trouble?

It is absolutely worth the trouble, at least for bean-counting reasons if that's how you get paid.

If you’re working on windows, powershell is absolutely worth your time.

PowerShell is great. Just objectively better than Bash for scripting.

I think the lack of adoption in the Linux world is a mix of:

* Cultural (i.e. it's Microsoft) * Not included out of the box * Existing tools being 'good enough'

> objectively better than Bash for scripting

This is a wild statement

Objectively is the new literally.

Just read “in my opinion”.

Bash scripting is so bad that being better than it is actually setting the bar rather low.

The only thing more remarkable than bash's cruftyness is the number of people who have developed Stockholm syndrome towards it.

I'm baffled sometimes that basically all of Nix is built on top of it

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact