5 ms·
A Second Search for Bash Scripting Alternatives
- ghjfrdghibt 2y agoUnpopular opinion but powershell, available on Linux, supports all of the things this article wanted to do out the box.
- actionfromafar 2y agoIt does, but it's so darn weird. Can we have another flavour of Powershell but with some other language hooked up to its dotnet underpinnings? Like I dunno, I would even take Lua over the weird syntax of PS.
- PinkMilkshake 2y agoPowerShell is sort of two languages, and it looks weird because they are often used together. But if you see them separate first, there isn't much there that is surprising. I do somewhat share your concern about it being built on dotnet, but one advantage is you have access to everything in dotnet, including building GUI apps (Windows only). Though, at that point the syntax does get kinda weird.
- actionfromafar 2y agoOh, the dotnet integration is what I actually like about Powershell. It's very useful even on Linux.
- xanth 2y agoLikewise, its a superpower to be able to integrate with a dll that wasn't developed with PS1 in mind
- sakesun 2y agoIndeed, it's very weird. It really took much more time than I expect to learn Powershell, even with many years of coding experience. But I'm totally happy now.
- pockybum522 2y agoOne of the requirements of the author was something that could work on embedded-sized resources.
- more_corn 2y agoNever have I wanted to stab out my eyes as much as when wrestling with powershell.
- ChoHag 2y ago[dead]
- tyingq 2y agoPerl excels at most of their list, though I understand why they aren't considering it. Just funny that you look at the list and one language in particular pops to mind.
- burnt-resistor 2y agoRuby is Perl 2.0. ;P Python is the never, ever Perl and you must do everything exactly this one way. I guess most people prefer dictators. ;)
- fracus 2y agoI'm fluent in bash but I have to say it is the jankiest, messiest language I've ever used. I can't believe another default hasn't totally obliterated it into obsolescence. Maybe because it is so ubiquitous people are afraid of all the work required to move. Wait, that's me.
- BirAdam 2y agoSame. I have started to rewrite my largest scripts in Ruby tho. These are the kind of scripts where performance began to be too rough and issues to ignore.
- cerved 2y agoPeople are always shitting on bash but I like it.
- fracus 2y agoThere is a perverse pride in knowing you tamed that unwieldy beast.
- burnt-resistor 2y agoIt's not hard once you know the rules. shellcheck helps, but it's usually whiny about escaping variable substitution that are intended for outside of the current script such as for editing other files. Its biggest flawed design decision is word splitting by default and Bash's lack of a standard library helper functions for arrays and associative arrays. These could also be implemented as bash native extensions without build-time modification with a user-provided programmatic builtin. I could be wrong, but zsh may be able to add compiled functionality at runtime dynamically as well.
- skydhash 2y agoIt’s a scripting language, not a general purpose one and as such had different design decisions. Next, you’d want a type system and a package manager.
- rcarr 2y agoUsing JavaScript via zx is nice.
- netvarun 2y agoAgree - that’s what we use too.
- Arcuru 2y agoI hate bash, but it's always the first thing I start scripting in when I need to glue some things together. I tend to go in the following order as complexity and a need for robustness increases. 1. Bash (or ysh, which I do prefer but isn't as available) 2. Python, using the `sh` package as needed. It's been great for upgrading shell scripts, and `sh` is really nice to use. 3. Rust, usually. That's my personal language of choice for "real" projects. I have a number of projects at each stage actually, though most of the things I'd call a real "project" with it's own repo end up as Rust projects.
- mrbluecoat 2y ago> bash: 3/5 stars (no one really knows bash) LOL, so true
- sshine 2y agoI try to at least know when something is bash and when something is POSIX sh. There is no reason to infest your system scripts with bashisms.
- from-nibly 2y agoBeen using nushell for the past couple years as my main shell environment and for any random scripts I need to use. It's everything I want out of a shell scripting language. It has even replaced "upgrading" to python in a lot of instances.
- ryandv 2y agoIn defense of bash, in spite of its many footguns... you do yourself a disservice if you refuse to learn bash, which is rock-solid stable and has basically ubiquitous deployment. SSH into any server or use any UNIX-like environment and you are instantly at home. While JS and Ruby ecosystems churn every year and mandate yet another round of dependency hell and keeping up with the latest and greatest in rubocop bikeshedding, bash just keeps on ticking throughout the years with little to no recurring maintenance burden. That being said, if you are doing something other than just piping together processes and managing unstructured streams of flat plaintext, bash is the wrong tool for the job. bash is best used interactively, in the REPL, for having a back-and-forth conversation with the machine and interrogating its current state (filesystem, resource usage...), or that of other machines over the network (that is, using dig, curl, openssl, ping, mtr, etc), and processing streams of text. Even for lightly structured data, like if I am doing boring, garbage CRUDdy tedium on the web and need to figure out how to do some rudimentary transform of a JSON document, figure out which headers to send and which endpoints to hit, curl and jq it is - and there I am, reshaping the data in as interactive of an environment it gets. The minute I need to write something for a non-interactive, end-user use case, with requirements for better domain modelling / structuring of data, testing, deployment, readability, maintainability, extensibility, etc. it is time to reach for a more modern language. But if you want to talk to the machine, virtually any (non-Windows) machine, interactively, bash is your lingua franca, or perhaps your Latin/Ancient Greek/Aramaic, esoteric and outdated as it is. I also get the feeling that people just recoil at any level of complexity and need to hide behind their clean, simple abstractions these days. As a Haskell enthusiast, I am also susceptible to this tendency, but one needs to be at least capable of diving into the historical, messy work underneath the hood.
- chasil 2y agoThe lingua franca is actually the POSIX shell: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V... There is a bunch of bash that you should not learn. The differing coprocess syntax from korn is one particular bugbear. Still, if you are hacking on ReaR or other critical tools that sink deep into bash's slang, you don't have much choice.
- 0xbadcafebee 2y agoWhenever people look for "better shell scripting", they always run into the second-system effect. Trying to shove everything that wasn't in the first system, into the second system. Bash shell scripting is already close to perfect for what it is intended. Where people always complain is one of three areas: 1) "footguns", 2) "not enough features", 3) "not a programming language", 4) inexperience. 1) is almost entirely due to it being a programming-like language bolted onto an interactive console terminal. Bash has a lot of changes over vanilla Bourne/Posix that make it less console-y and more programming-y. But if you take away the interactive-terminal-ness itself, then you don't need most of the Bashisms. 2) is almost always a mistake. Bash has pretty much all the features you need. But again, it's hampered by the interactive-terminal-ness; take that away, and you can do pretty much anything, with ease. 3) is because programmers don't understand what scripts are for. They are not for writing robust programs. They are for solving a small problem, in a specific, tailored way, with the least amount of effort and time. This means that you should be abandoning all of the programmer's best practices and rules. Throw out safety, reliability, consistency, verifiability, etc. What you end up with is a solution that works, with nothing extra. 4) comes when people simply don't know how to use Bash very well, which is 90% of the time. Ever since I became a programmer two decades ago, the great unwashed masses of techno-dweebs who call themselves "programmers" have been picking up complex and nuanced technology that they have never bother to formally learn, and then complain that it sucks and they need an alternative. When in reality, the problem is almost always either a) they didn't read the manual, b) they haven't practiced using it, or c) they're using the wrong tool anyway. Doesn't matter if you disagree with me. We will be using the same shell scripts in 20 years. Know why? Because you can't make it any simpler, and it just works. Complain all you want about it not being perfect. You simply will not be able to make something better without simultaneously making it worse. Its killer feature is its lack of features and design. It is the anti-programming language. And boy do I love it.
- shlomo_z 2y agowell said!
- ryandv 2y ago> Ever since I became a programmer two decades ago, the great unwashed masses of techno-dweebs who call themselves "programmers" have been picking up complex and nuanced technology that they have never bother to formally learn, and then complain that it sucks and they need an alternative. When in reality, the problem is almost always either a) they didn't read the manual, b) they haven't practiced using it This kind of Dunning-Kruger-esque arrogance in software is intensely aggravating to me. Nobody presumes that you can master, say, a musical instrument, without intensive practice over a timespan of years; yet for some reason people can get plopped out the other end of a bootcamp and suddenly identify as world class programmers in 16 weeks without the requisite thousands of hours of practice with hands on keyboard, reading the manual, studying how the computer works, and actually solving technical problems.
- deleted 2y ago[deleted]
- krembo 2y agoChatGPT is quite good at bash and improves the learning curve/time to market by a lot
- kamaal 2y agoIts strange people of every generation, almost everyday keeps discovering the need for Perl. Perl was made to solve precisely these kind of problems. Just use Perl. Its fast, matured, has CPAN and is dedicated to maintaining backwards compatibility for years to come. Using anything else will not make all that much sense. You will be reinventing a whole universe(and badly from scratch). And achieve nothing at the end.
- Izkata 2y agoMakefiles too. Seems like they got a resurgence in the past ~10 years after falling out of favor for a while.
- actionfromafar 2y agoIf LLMs know Perl well, that might make me agree with you more actually. Then the LLM can be the ersatz greybeard refreshing you with what the script actually does.
- kamaal 2y agoI wrote 50K lines of Perl last month using co-pilot+vscode in a single day. Perl+LLM is a match made in heaven.
- omani 2y ago#!/usr/bin/env cargo Im exicted about cargo-script (rust). hopefully soon. https://rust-lang.github.io/rfcs/3424-cargo-script.html https://rust-lang.github.io/rfcs/3424-cargo-script.html
- odino 2y agoABS creator here. Thanks for the kind words :) Long way to go but was very happy to see someone wanting a better alternative to bash and trying ABS out!
- BeetleB 2y agoNo xonsh? (https://xon.sh/ https://xon.sh/) Seems to hit most of the requirements. Been happily using it since 2018. It's great not to have to learn a whole other language just to do scripting.
- zenlot 2y agoThe answer is PowerShell. Works great in Linux.