What is a script language on Unix

December 17, 2007

There's a lot of argument in general about what is (merely) a 'scripting language' and what is a fully fledged programming language, deserving to hold its head up high besides grown up languages like C, Java, and Pascal.

Unix is a simpler place, because it has a simple and very clear definition of what is a script versus what is a program. To wit: if the kernel can directly exec() you in place as is, you are a program. If not, you are a script (sometimes called an 'interpreter script') and actually get processed by your interpreter, not the kernel.

(Note that in-place execution doesn't preclude the use of a helper; almost every program you run on a modern Unix requires the help of the dynamic loader, which is not part of each executable.)

While technical and somewhat picky, this distinction is important. Among other issues, there are a number of places where a program can be used that a script cannot be.

As an immediate corollary, on Unix a language that cannot be used to make programs is a script language, and there are some things that programs written in that language will never be able to do directly. Note that this says nothing about their suitability for serious jobs.

(While scripts usually start with '#! <interpreter>', some Unixes have ways to run scripts without that; Linux has binfmt_misc, for example.)


Comments on this page:

From 74.195.239.157 at 2007-12-18 00:56:23:

But but but...

You used Java as an example of a grown up language. But Java can't run natively. Well, not Sun's way, anyway. gcj is another matter entirely, which turns into a discussion of what's a facet of the language and what's not...

From 194.8.197.205 at 2007-12-18 06:17:03:

Hmm… perl has an -x switch which tells it to scan the source file for the shebang line and ignore anything before that. So you can prepend a short binary to Perl scripts that invokes perl -x on itself… and thereby turn a script into a program.

(I’m not sure what my point is or if I have one.)

Aristotle Pagaltzis

By cks at 2007-12-18 08:59:11:

Java makes a great example for how languages that no one looks down on as 'scripting languages' may still be script languages on Unix. (Or not, depending on what compiler technology you have available and what your compiler generates.)

Written on 17 December 2007.
« A thought on reading multiline records
How x86 Linux executes ELF programs »

Page tools: View Source, View Normal, Add Comment.
Search:
Login: Password:
Atom Syndication: Recent Comments.

Last modified: Mon Dec 17 23:48:37 2007
This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.