Tuesday, August 24, 2010

Greenspun's Tenth Rule adapted to Unix

Greenspun's Tenth Rule: Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.
can be adapted to Unix:
Any sufficiently complicated Perl, Python, Ruby, Lua, etc  script contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Unix.


And I don't mean the all of the "system" calls. I mean: concurrency, fault tolerance, data persistence, configuration and scalability. 


It may be ugly, but combine ksh93/bash, awk, bc, etc (whatever you find on a standard Unix/Linux distro) and you'll find an analog to the features offered by the above mentioned languages. This does not include "abstractions" such as fancy data structures and other syntactical sugar.   And, of course, fork/exec isn't going to beat a function call. 


However, (and this will be the subject of the next post), Unix under control of advanced shell (such as ksh93 or bash) can have the following capabilities (at least!):
  1. Coroutines (Co-processes in ksh93 or recent Bash)
  2. Communicating Sequential Processes (CSP) via named pipes and co-processes
  3. Dataflow processing (pipes)
  4. Arbitrary precision math (bc or other calculator)
  5. Reuse (command line apps)
  6. File (database) support (ls, awk, find, grep, sqlite command line, etc)
  7. List processing (command line args + ksh93/bash)
  8. Functions/apps as first class objects
And more...

No comments:

Post a Comment