4 ms·
My favourite scripting language is POSIX shell. It is also my most used language in terms of different "projects" I write with it; most of these projects are ve
by roryrjb 7y ago
My favourite scripting language is POSIX shell. It is also my most used language in terms of different "projects" I write with it; most of these projects are very small and focused. I feel that shell programming is very misunderstood, this is conjectural of course, but people dismiss it out of hand and move on up to something like Python usually. I have some rules of thumb: if you need to use a hash data type then move on to something else; if your LOC starts getting big then probably move on; always use ShellCheck.
Just like every language ever, it has some warts, and it has some features that make it less readable and maintainable, but POSIX shell above all others (to me) having less features actually makes it easy to avoid the pitfalls.
Of course in general I don't write massively complicated programs in POSIX shell but that's not the point, but it can take you very far, you just have to wrap your mind around how to implement certain things compared to other languages. I think the time taken to do that, in the long run will pay off. Of course if figuring it out takes too long, then move on to something else.
As for the something else Perl is a very good candidate and is influenced in certain ways by shell programming. It just makes things easier. To me Perl is as readable as Python. I say this as someone who uses Python and Node.js in the day job, so in terms of LOC they are my main used languages, it's just that POSIX shell and Perl are better suited to the tasks as stated by the question. Also they are more portable, as in, both seem to be already present on a lot of Unices (I have no idea about macOS which I never have to touch or really care about).