Glue Languages Make You a Better Coder
zachholman.com
zachholman.com
See Scheme and Io for examples of clear, simple syntax.
But, YMMV.
When I ssh into our Solaris server, it drops me into csh by default. That makes me think someone out there believes it's good enough.
Nearly all Solaris systems I've worked on and set up have a sun freeware or CSW system set up on them with all the standard "linuxy" tools installed, so the change isn't that weird.
For example, it is the default user shell on FreeBSD. But the system shell is a Bourne-like shell (ash, I believe?). So for serious usage, even the modern BSDs defer to a Bourne shell.
Most of the outright bugs in the article you reference have been fixed.
But the design problems are still there in both csh and tcsh.
In particular, the problems with manipulating file descriptors to separate stdout from stderr are still there, the signal catching is not as clean as sh/bash, and csh/tcsh quoting is a mess compared to sh/bash. I know of no good reason to prefer csh/tcsh.
Csh may feel more programmery, but if you do actual programming use a Bourne shell (or Plan 9's rc).
Also, bash syntax seems a lot less clumsy once you grok unix stuff like pipes, exit codes, and argument parsing (which you should really do anyway before scripting unix in any language). The fundamental abstraction is the command + argument list, and many quirks clearly derive from the syntax trying to stay out of the way of executing commands and gathering the results.
Indeed. After using it for quite some time without really thinking about it much, I've only relatively recently come to the realization that the shell is, in many ways, simply a thin very UI layer wrapped around the kernel's syscall API, and I think the awesome utility of the shell speaks to the quality of the design of that API.
I use Python for all of my scripts. The moment that I want to automate some system related task that requires any logic, I reach for Python. (I'd still write a bash "script" if the script was just a succession of commands.) I don't think this is a controversial position since Python is considered a cousin of Perl, and Perl was heavily inspired by shell scripts, awk and sed. I think of Perl and TCL as the original glue languages.
If I'm writing a script from scratch, I just don't see any compelling reason to do it in bash. (Or whatever your shell of choice is.) Yes, I recognize that "Python may not be available" is a potential reason, but it's not compelling to me because it's available in the places I'll need to work.
I have taken the policy of moving any SH script I write to Perl (or Python) after it breaks about 45 lines (a page). I get good error checking, type checking, reliable escaping, and the ability to neatly abstract into modules.
So far, it hasn't hit me in the face yet. :-)
But I have to say that I think the 45 lines rule is not the best criterion. Lots of scripts which are of the form "move these files around, run this command on the files, mangle the output, send it to this command to summarize, send to another command to pretty-print" can be long in line count, but are really well-done in shell. Basically, operation sequencing, and/or line-by-line file processing.
Shell makes it easy to ensure tempfiles are deleted, to catch signals, to automatically check error status of each and every command.
As you note, sometimes shell is "contraindicated" (as they say in medicine). Anything needing data structures, or abstraction beyond simple functions, is not so good for shell.
> reliable escaping
One thing that I'm surprised about is that there is a severe lack of easy shell escaping of strings in more modern scripting languages. There should just be a printf symbol/modifier for it. I should be able to: sprintf("command %S %S", "blah blah blah", "blah -blah")
to get command blah\ blah\ blah blah\ \-blah
Also, take a look at: https://github.com/bsandrow/python-shellshockLet me know if you can think of anything that is painful to do in Python, but easy to do on the shell.
The first is when there are key external tools that work better than the python libraries and invoking them with subprocess or os.system is more cumbersome than just using bash.
The second is when the implicit command-oriented nature of bash or syntax shortcuts makes for a much more succinct program. eg. 'do_thing && do_other_thing || fail'
I'll admit though, my threshold for switching to python is not particularly high.
In the web context within HTML it maybe but in terms of mobile development using tools such as titanium/appcelerator or developing things in node.js, this requires javascript not as just a glue language but as the core.
In terms of shell, yeh, I think it still applies cause to this day i havn't seen anyone write a fully blown program completely in shell (thought that could just be me).
What i noticed in all the places i have worked at, when the shell script/program starts to get to large its usually slowly migrated to perl or <insert persons fav scripting language here>.
Sometimes, this forces us to make quick trips into perl or awk (to get yesterday or tomorrow). However, shell scripting has certainly made me more productive over the years. For most of my initial programming life (90's), I've generated boilerplate code using shell (often with awk).
Why? I don't see anything special in JavaScript's syntax that makes it more accessible. Node's asynchronous callback style would be a perfect fit for Ruby's block syntax.
I hope so! :-)