jdimpson (jdimpson) wrote,

Philosophy: What is a script?

To me, scripting is a verb, and I define it as programming with the intention of automating a task that can be done manually, rather than with the intention of developing either a new unit of functionality or a new monolithic application.  These ideas come from the Unix Toolbox Approach, the subject of another article (hopefully).

So a script is the result of scripting as defined above, rather than the more common definition of  some code written in a scripting language.  Languages like Perl, Python, and Visual Basic are often thought of as scripting languages, and are sometimes looked down upon because of this.  These languages certainly are very conducive to scripting, because they excel at gluing other applications together, are loosely typed, and in general have a low barrier to entry.  These qualities are essential to scripting, but one can (and many do) make first class applications written in these languages.   Whether you have a script or an application depends on the intent and discipline of the programmer; the language selection itself is a result of the programmer's intent and discipline.  That's why there's a correlation between scripting tasks and specific languages.

Often, the word Interpreted gets used as part of the scripting definition, with similar scorn.  I get really annoyed by this because, at some level, all computer instructions are interpreted by something.  Whether that something is hardware or software seems irrelevant and increasingly uncertain.  With modern CPUs doing so much emulation these days, even traditional binary opcodes are being interpreted as a matter of course.  Interpreted vs Executed is no longer a significant distinction.   Java is a good example of something that is interpretted (by it's Virtual Machine).  But at one time Sun tried to sell hardware that interpretted the java bytecode as the native instruction set of the hardware.  (There still needs to be a VM to handle things like Garbage Collection.)  That ship seems to have passed due to the realities of the current CPU market, but technically it worked.  Digital Equipment Corp (bought by Compaq, bought by HP, with some intellectual property sold to Intel somewhere along the line) got its start selling Lisp machines, which were capable of executing Lisp on their processors. 

Perl and Python, traditionally thought of as interpreted, are first compiled to a parse tree, not unlike Java compiled to bytecode, before being interpretted.  In the case of Perl, all the shenanigans going on with Perl 6 and Parrot capitalizes on the VM approach, to the point where they seem to be bootstrapping an implementation of every historical version of Perl, plus Java, plus who knows what else, on several independent implementations of their Parrot VM.

My point, and I do have one, is that a script is a script because it is meant to automate something done by hand. This isn't a sharp distinction, but it is a useful one.  Good scripts are usually generalized, which helps blur the distinction.   The are similar to Orchestrations, Choreography, and Workflow/BPEL languages (as far as I understand them, at least). 
Tags: compile, execute, interpret, languages, philosophy, scripts, unix toolbox approach

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your IP address will be recorded