Live data from Hacker News

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

news.ycombinator.com

61–70 of 106 posts

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

#61

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.

What dependencies? OP wants to replace a bash/sh script, not left pad a string.

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

#64
For me: I use groovy. Reasoning behind it is that I am a software engineer specializing in JVM. On all the machines I work there is a JVM installed. Plus groovy is Java with extra stuff so it is a flavor of Java nothing new. And it does not require a compiler.

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

#65

Earlier quoted context omitted.

I just checked, if you already have .NET installed, the powershell package is about 20 MBs, which is… tolerable. However, I see that the latest version still starts very slowly compared to *nix shells (and also Python). The shell was running from tmpfs (so basically a RAM disk). I have a decent processor and an NVMe SSD, and this is what I see (it was tested 10 times in a row to pull everything into the page cache pr…

How about pwsh -NoLogo -NoProfile ? > Measure-Command { pwsh -NoProfile -NoLogo exit } Days : 0 Hours : 0 Minutes : 0 Seconds : 0 Milliseconds : 254 BTW, Windows OS is often subject of Windows Defender and other AVs which are not present on Linux machines and their slowdown of the system is phenomenal.

Thanks for the suggestion. Adding these flags halves the startup time:

  $ time ./pwsh -NoProfile -NoLogo /dev/null

  real 0m0.456s
  user 0m0.388s
  sys 0m0.040s
Much better, but I still wouldn't use this even as an interactive shell, as I open a few hundred terminal windows each day.

There's no defender (or anything similar) on that other machine. It also has an SSD. With an older HDD powershell started in about 10-15 seconds there (while cold startup time for bash was something like a second, and instantly afterwards).

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

#67
I like to use Python with PyInstaller[1], but it results in fairly large binaries with a relatively slow startup time.

When binary size and startup speed matters, then I use Go instead.

Finally, sometimes I just write in Bash anyway, even though it is such a difficult language to write in.

[1]: https://pyinstaller.readthedocs.io/en/stable/

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

#68
Without knowing what you're trying, I'm often using nim (https://nim-lang.org/) when I want more complexity than a basic bash script, cross-compiled binaries _and_ way smaller binaries than go. It's much like python, easy to pick up, and promising. But not as mature as python, obviously. Go is great, but the binaries are big... not a problem if you've got great bandwidth...

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

#70

Earlier quoted context omitted.

Powershell is a horror you mean, it's got the verbosity of objective c with the consistency that comes with all Microsoft designed products. Just use a proper scripting language.

No, I said what I mean. Bash and its disasters like [ as executable and mega error prone and awkward language designed 50 years ago IS horror. Verbosity of powershell is optional, I don't use it. > consistency that comes with all Microsoft designed products. Oh, lets not troll here.

Disasters like powershell returning a 0 exit code even if there is an error? Its a pile of trash that doesn't add anything new other than a big shiny MS logo.
Post reply on HN