Live data from Hacker News

Ask HN: What to use instead of Bash / Sh for scripting?

news.ycombinator.com

71–80 of 106 posts

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#71
Is there a language with sane syntax (if, for, comparisons being a syntactic feature not commands requiring ; in weird places) that would still execute every line by default and support pipelines and && and || natively? Sort of bash that looks like a normal language.

Maybe even some library with stuff for parsing outputs of common commands?

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#73
As a devops engineer who also writes a lot of code, I started using Deno (https://deno.land) since I can write my code in JavaScript and TypeScript. I can also natively use wasm, and have an internal repo for hosting commonly used functions since Deno loads files using url imports.

Can recommend!

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#74

Perl (5). It's an incredibly capable scripting language, many things essential for Shell programming are much better integrated than in Python (e.g. regular expressions). It gets a lot of hate these days but it's still a damn fine language and perfectly suited to shell programming (and larger projects).

One of the things about Perl is that I can't quite believe myself how far it has fallen. I was never a Perl monk by any means but I knew enough to get by. And why did I not even think about it? I haven't coded Perl in years, but if my memory serves me correctly, bundling extra dependencies in Perl was a heck of a lot less painful than Python too.

Yes, Perl's package ecosystem CPAN (the "Comprehensive Perl Archive Network") was lightyears ahead of other systems at the time (late 90s / early 2000s), it provided modules for everything, which made you so incredibly productive. You need a DNS library? Just go to CPAN. CGI functionality? CPAN. Parsing some obscure file format? CPAN.

Really sad it lost so much traction in the last decade, I partially blame it on the failed Perl6 endeavour. I also mostly use Python these days but looking at my old Perl scripts Python really doesn't come close in terms of succintness.

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#75
post #48

Can you be more specific than "fatigue"? That sounds like ennui, in which case maybe consider a job switch instead of a language switch (not being sarcastic or intentionally mean). Bash plus all the Unix tools (awk, grep, sed, tsort, comm, the ones I don't know, etc.) have pretty long legs, in terms of functionality and the syntax is pretty understandable. They provide most of what Perl offers, apart from OO (-ish) a…

> If you want strong typing (are you scripting in the large?), then, almost by definition, no scripting language provides that. Powershell is basically strongly typed. > Can you be more specific than "fatigue"? That sounds like ennui I love my job, but bash makes me wanna hang myself. I can say the same about stored procedures. Its like going back to cobol days. Some people have strong tastes I guess.

I used “true” instead of “$True” in a power shell script. It didn’t error. It didn’t warn. It just evaluated to false.

So doesn’t behave like a strongly typed language to me.

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#76
post #71

Is there a language with sane syntax (if, for, comparisons being a syntactic feature not commands requiring ; in weird places) that would still execute every line by default and support pipelines and && and || natively? Sort of bash that looks like a normal language. Maybe even some library with stuff for parsing outputs of common commands?

Xonsh is a Python superset with shell-like operations. Also there's PowerShell which is arguably a better designed language than bash.

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#77
For a quasi embedded project I picked lua. my requirements were small runtime size + fast startup time. I would say that the library availability is tremendously lower than perl,python,node but ample enough for most tasks (openwrt is almost completely built in it, including web views)

However I agree that nim / zig could also be good directions

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#78
post #42

Earlier quoted context omitted.

Which is why I'm writing most of my tooling in Rust . Deployment or installation is just one scp away. not rewriting, just when It needs large refactoring, or is currently a mess, or brand new.

Assuming you're deploying to the same OS/architecture that you're working from, otherwise you'd have to rebuild (which Rust makes easy to do, but still)

True.

Though in all those cases, for me, all alternatives are just as bad or worse.

Getting ansible running on a windows server is... unfortunate. Ensuring that your bash script runs on OSX is easier, but I've had lots of unexpected issues with tools like grep or find working just a tiny bit different. And so on.

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#79
>I don't know what version of Python I'm going to have on the system, installing dependencies is not fun

If your colleagues can be expected to have Docker, you can wrap your Python script in an image that contains specific versions of Python and the dependencies.

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#80
post #78

Earlier quoted context omitted.

Assuming you're deploying to the same OS/architecture that you're working from, otherwise you'd have to rebuild (which Rust makes easy to do, but still)

True. Though in all those cases, for me, all alternatives are just as bad or worse. Getting ansible running on a windows server is... unfortunate. Ensuring that your bash script runs on OSX is easier, but I've had lots of unexpected issues with tools like grep or find working just a tiny bit different. And so on.

Node scripts, even with dependencies, are pretty much 100% equivalent across all platforms :)
Post reply on HN