Check out Babashka if you enjoy lisps/Clojure. https://github.com/babashka/babashka
Oh my god. I do, and will.
Ask HN: What to use instead of Bash / Sh for scripting?
51–60 of 106 posts
Re: Ask HN: What to use instead of Bash / Sh for scripting?
#52Can 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…
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.
Re: Ask HN: What to use instead of Bash / Sh for scripting?
#53Shell is likely to remain the best way to connect together other pieces of software.
The tipping point, in my experience, is folks trying to use arrays or other buffering of data. At that point they're writing in shell, but wishing for a procedural language.
Whereas, shell works excellently (and incredibly efficiently) if you can compose your task strictly into streams of data (a more 'functional' feel)
So the real answer I think is specific to the types of script you are writing!
But also it could be worth revisiting the style in which you're using shell; especially if you can call upon your own helper programs (eg. in Python) where you require buffering or non-streamed access to data.
Whilst there's a lot of documentation of sh/bash functionality, I don't think there's anything like the same momentum behind 'best practices' as other languages like Python or even C.
Re: Ask HN: What to use instead of Bash / Sh for scripting?
#54It's hard for us to help you with you giving us some context.
150-500 loc of bash are not that much, specially when you combine bash with standard Unix utilities.
These scripts you wrote, for what do you use them? Are they executed by humans or machines? On which platform? Linux, Mac, Windows or all?
You mentioned jq. Are you parsing json from HTTP requests or files? And why are you parsing json with bash?
Without a better context, A lot of people will say to use Python and Python is a good choice with you are running you scripts on Linux because you probably already have Python 3 installed and whatever you are writing with 500 loc of bash can be accomplished with zero dependencies with Python standard library.
If relying on the Python runtime is really a problem for you, your next best option is Go. Go is easy to learn and easy to use for building small cli apps with only the standard library, but even if you need some dependency, you will ship a single binary, so no problems with runtime compatibility or dependencies.
Re: Ask HN: What to use instead of Bash / Sh for scripting?
#55Earlier 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)
How easy is it to cross-compile with Rust?
Still, when we're talking about casual "scripts" even this extra step seems a little bit burdensome
Re: Ask HN: What to use instead of Bash / Sh for scripting?
#56Re: Ask HN: What to use instead of Bash / Sh for scripting?
#57With nix you can make anything into a script, there's some people using haskell for example. I tend to use common lisp but I'm learning guile scheme and will probably move to that instead.
I don't understand (even though Nixos was my only OS for a couple of months). How would Nix help me make Haskell into a script?
Re: Ask HN: What to use instead of Bash / Sh for scripting?
#58Consider docker for some situations. Consider kubernetes if the need is more devops/ running a production system.
Consider powershell if on windows.
Travis ci / Jenkins / appveyor etc. for CI
Be lazy - can I get out of writing this code should be in the forefront of your mind (for any code!). The answer might be no but consider it.
No code tools can be considered - Google sheets, Wordpress, plethora of saas to do this. Paas eg aws lambda etc.
So many options. Solve the problem, rather than transliterate bash.
Re: Ask HN: What to use instead of Bash / Sh for scripting?
#59Re: Ask HN: What to use instead of Bash / Sh for scripting?
#60With nix you can make anything into a script, there's some people using haskell for example. I tend to use common lisp but I'm learning guile scheme and will probably move to that instead.
I don't understand (even though Nixos was my only OS for a couple of months). How would Nix help me make Haskell into a script?
This was on HN the other day. Nix allows you to crunchbang a `nix-shell -p` kind of expression.