3 ms·
Over the past decade I've been drifting towards doing more and more in bash that I'd've normally done one one language or another just because of this stability
by Izkata 5y ago
Over the past decade I've been drifting towards doing more and more in bash that I'd've normally done one one language or another just because of this stability. Perl is another candidate if I need something more complicated, but I'm not as familiar with it so I don't really reach for it often.
Are there any other languages with the same stability that would also fill this niche?
- HeckFeck 5y agoI've learnt Perl for this very reason. It is extremely capable, extensible and still very backwards-compatible. It feels like an evolution of bash but much more performant. A bit of a shame that it's seen as an anachronism to many. Perl soon rubs off on you and becomes a delight.
- fiddlerwoaroof 5y agoFor shell-scripting sorts of tasks, there’s also awk which I find a nice sort of halfway between bash and Perl. Also, I’ve been using various lisps (elisp in emacs org-mode and Common Lisp) and they both can be written in ways that will probably last a long time.
- Brian_K_White 5y agoAwk is a strange seeming suggestion, but I agree it's probably the next most universal, installed, stable over time option, and more readable than sh. Using awk as a general purpose language means slightly bending it out of shape, by mostly ignoring the main section (which runs once per selected record of input) and writing your entire program in a big END{} section. BUT * It's installed everywhere and has been forever just like sh * A 20 year old awk script from hpux or something, works in todays gawk, just like sh. * Unlike sh, the language is more like a normal generic language than, making it more readable and less arcane for non-trivial jobs. For example, bash has a handy substitute feature, in the form of a brace expansion. ${FOO//a/b} Awk has an actual sub() or gsub() function. A lot of things in bash require tricks essentially abusing various fancy brace expansions and messing with IFS to hijack the line parser into doing things there is no explicit command for, especially if you're avoiding external commands. IE you're not simply writing code that does what it says, you're running a bash interpreter in your head and manipulating strings so that when they are expanded and resolved, they mean something to the the parser and results in the parser doing something more useful. It's like your always writing code that writes code, instead of just writing code. External dependencies is another whole point too. Shells main explicit job is to run other programs. You actually have to work pretty hard not to run an external binary by accident, ie you have know which commands are built in and which are executables. In awk or anything else, you have to go out of your way to exec() or system().