Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

At Last, a Useful Definition of "Scripting Language"

by hardburn (Abbot)
on Oct 25, 2004 at 20:58 UTC ( #402316=perlmeditation: print w/ replies, xml ) Need Help??

Some time ago, I wondered about coming up with a useful definition of "scripting language". I concluded back then that there isn't one. Any definition either ends up being so broad that you start including things you probably shouldn't (like ASM), or so narrow that it almost produces an empty set. Classical definitions, such as making scripting a synonym for interpreted, falls down as "modern" techniques like virtual machines and bytecode tend to blur the line between compilers and interpreters.

While browsing some of Paul Graham's essays, I started reading Being Popular, which discusses how programming languages get to be popular. One of the ways he suggests is:

To become popular, a programming language has to be the scripting language of a popular system. Fortran and Cobol were the scripting languages of early IBM mainframes. C was the scripting language of Unix, and so, later, was Perl. Tcl is the scripting language of Tk. Java and Javascript are intended to be the scripting languages of web browsers.

Here, in my interpretation, Paul is putting forth a totally different defintion of "scripting language": It's whatever language you use to get stuff done under a given system.

Note that this definition cannot be used in a derogatory way. It makes no sense to lambast a system just because it's the one you use to get work done. It's entirely possible that the language is not the best for your work, but if you were to replace it with another language, then the new language would become your scripting language.

Paul also laments that LISP is not the scripting language for any existing system, save Emacs. The one system where it was, the LISP Machine, died out long ago. He also readily admits that LISP makes a poor scripting language in a Unix environment.

As it happens, I do know of a reasonably popular program that uses LISP as a scripting language: Zillions of Games, a generic AI engine that can learn to play many different kinds of games. A LISP-like language is available for users to define their own games. (And no, I don't work for them :)

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Comment on At Last, a Useful Definition of "Scripting Language"
Re: At Last, a Useful Definition of "Scripting Language"
by belg4mit (Prior) on Oct 25, 2004 at 21:53 UTC
    Zillions is nifty, you can play everything from Nine Men's Morris to Arimaa on it.

    As for the OP I think the idea is close. To me scripting languages tend to be either bundled (JavaScript, as Tcl was intended) or interpreted. I'd also point out that batch languages (those that necessitate calls to many external programs) are often conflated with scripting languages.

    --
    I'm not belgian but I play one on TV.

Re: At Last, a Useful Definition of "Scripting Language"
by pg (Canon) on Oct 25, 2004 at 22:36 UTC

    If you google "define:scripting language", it will give you a list of different definitions.

    • Some of those make sense:
      • A scripting language differentiates itself from other typical languages in that they are usually simpler to learn and use as well as not needing to be compiled. The language is interpreted at run-time so you can execuate instructions immediately.
      • A (relatively) simple programming language eg JavaScript and Visual Basic which can be used to create a script, which is a set of instructions for a computer. VBS is much favoured by virus writers seeking to exploit certain vulnerabilities in some Microsoft programs.
      • A simple programming language designed to perform special or limited tasks, sometimes associated with a particular application or function.
      • A programming language, usually suited to a particular purpose, that is easy to use and easy to learn. Scripting languages are usually designed for writing small programs like batch files. They are often loosely typed and have simple syntax to make them easy to use.
      • is an interpreted programming language that works within another application to perform tasks.
    • Several of them put a narrowed focus on web:
      • A programming language designed specifically for Web site programming. Examples include JavaScript and VBScript.
      • A specialized language used to create scripts that, when inserted into a Web page, control various elements of the page, such as the user interface, styles, and HTML markup.
    • Some are way too general :-)
      • The programming language in which a script is written.

    Any way, as I always believed, Perl is not the kind of traditional scripting language.

      Rather than requiring a language to be "interpreted" to call it a scripting language, I think it would be more accurate to say that scripting languages are not precompiled. That allows both interpreted and compile-at-runtime languages to qualify.

      The difference, for purposes of defining it as a "scripting language" (or not), would be in whether or not it is still in a source-code format right up to the point where you run the script (and whether or not it is still source code when it's done running). This in turn creates a set of characteristics for usability that are attached to scripting languages and not precompiled languages. It is in truth these usability characteristics that makes the difference, but those characteristics depend on whether or not your code is precompiled.

      From within the limited environment of an IDE like Microsoft's Visual C++, C code is actually sort of a "scripting" language, in that it is source code right up to the moment you run it, and still source code when you're done. Only when you compile the binary and exit Visual C++ does it become a non-scripting programming language.

      This does tend to fit with the idea that a scripting language is what you use to "get things done", of course: scripting languages, because they can be created and/or modified very easily on the fly, are used to do things, and non-scripting programming languages are used to make things.

      I see nothing to deride in either term. Each has its uses. Neither of them is necessarily limited within its range, and both are quite limited outside of their respective ranges. The only derogatory thing worth saying in regards to either might appropriately be applied to the programmer if he or she uses the wrong tool for the job. If you know both PHP and C++, for instance, and try to use PHP to write applications and C++ to write includes for a web page, you're probably doing something drastically wrong.

      - apotheon
      CopyWrite Chad Perrin
        "From within the limited environment of an IDE like Microsoft's Visual C++, C code is actually sort of a "scripting" language,"

        I really like this point you made. Once you pointed it out, it makes great sense to me.

        In this sense, pre-c is also kind of mixture of real c code and mini-scripting language. In pre-c source code, you can directly embed SQL statement, but before it goes through the c compiler, it will first go through a pre-c "compiler", which will convert SQL statements to c code.

        By the way, I like what pre-c allows me to do, as I don't need to concate a series of ugly string into a SQL statement, which is not visually clear and pleasant to me.

        scripting languages, because they can be created and/or modified very easily on the fly, are used to do things, and non-scripting programming languages are used to make things.

        This seems to get to the heart of it. But, does this mean you are unable to identify a scripting language without examining how its used?

        This also implies a different development methodology for scripting than for making things.

Re: At Last, a Useful Definition of "Scripting Language"
by revdiablo (Prior) on Oct 26, 2004 at 16:12 UTC

    I'm of the persuasion that thinks there is no useful, universally accepted definition of "scripting language." Even if we did pick one of the various common definitions and stick with it, I don't see the point. I think it's far better just to talk about languages in terms of their concrete properties, rather than trying to come up with strange, arbitrary categories to fit them into.

    That said, your post does indeed talk about some concrete properties of various languages. Because of this, I think it's a pretty interesting discussion, but the overall purpose -- to find a "good" definition of "scripting language" -- strikes me as odd. Hopefully you'll see my post not as poo-pooing further discussion, but rather encouraging the kind I think is more useful. :-)

Re: At Last, a Useful Definition of "Scripting Language"
by TomDLux (Vicar) on Oct 26, 2004 at 17:57 UTC

    Look at scripts from a viewpoint of purpose instead of method.

    Programs are general solutions to significant tasks; scripts are more localized, more personal, more transient.

    Of course, that doesn't last long, either. The scripts used by the system administrators of an enterprise involving tens of thousands of machines and hundreds of thousands of user accounts may be more involved than other peope's operating systems.

    But Perl did set out to solve those transient requirements: Extracting, and Reporting. As time passed, it took on more and more important and long-term tasks.

    Being the duct tape that holds together the Internet is a mighty important task .... but Perl would not be good at that if it weren't for the scripting aspects of its heritage. Consider other languages which have attempted to take over the role of holding together the internet, which made a point of being a real&tm; programming language ...

    --
    TTTATCGGTCGTTATATAGATGTTTGCA

Re: At Last, a Useful Definition of "Scripting Language"
by jdporter (Canon) on Oct 26, 2004 at 23:04 UTC
Re: At Last, a Useful Definition of "Scripting Language"
by radiantmatrix (Parson) on Oct 27, 2004 at 18:31 UTC

    This strikes me as rather strange. I know "interpreted" and "script" are used interchangeably now, but it seems to me the idea of a script is that it is a human-readable code. Like the script of a play.

    If, from the user's point-of-view, the human-readable code appears to be executed, you have a scripting language. Take the most common form of Perl: a text file which appears to be run as a binary. Even though it's really being compiled into bytecode and interpreted at runtime, it looks like the human-readable code is being executed. In other words, compile and run are one step.

    "Interpreted" is like Java -- the command you execute is a file containing bytecodes which are not human-readable. But those bytecodes are interpreted into native machine code at execute time.

    "Compiled" is like most C programs -- the command you execute contains the machine code.

    Perl is primarily a scripting language, but since you can compile into bytecode using pp or similar, it is really an interpreted language as well. Overlapping is allowed, you know...

    Yeah, there's plenty to debate about those definitions: there will be for any definition. But, the above create divisions which are helpful for knowing what someone means -- when I say "I wrote a script", I mean that the source is the program, and that's how it will be distributed.

    radiantmatrix
    require General::Disclaimer;
    "Users are evil. All users are evil. Do not trust them. Perl specifically offers the -T switch because it knows users are evil." - japhy

      That might be a logically-consistent definition, but it isn't a useful one. I can write a program that will take C code and interpret it on the fly. Would C then be a scripting language?

      By this definition, the only difference is in how it's implemented. It doesn't cover how you use the language. Now, a language that is meant to be interpreted is often optimized for running in an interpreter, and likewise for compiled langs, but it is still possible to implement it the other way.

      So I reject that definition on the grounds that it doesn't make a smeg of practical difference.

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

        That might be a logically-consistent definition, but it isn't a useful one. I can write a program that will take C code and interpret it on the fly. Would C then be a scripting language?
        That's why that definition is useful, because there is overlap, and because it defines a language based on how it can be used. In the case you cite, you'd have an environment (your interpreter) in which C was a scripting language. Just like in csh. C can be a scripting language in some environments, and a compiled language in others.

        Similarly, Perl can be a scripting language or an interpreted language, depending on how it is used.

        Now, a language that is meant to be interpreted is often optimized for running in an interpreter, and likewise for compiled langs, but it is still possible to implement it the other way.
        Exactly. The problem is that languages might have been destined for one type of use, but evolve into another type of use. Imagine a language 'X': it is designed by its original architechts to be a scripted language. Someone finds it very useful, but wants to be able to distribute the language in machine-code form so that the interpreter need not be shipped with the product; so, they build a compiler for 'X'.

        Now, 'X' is a scripting language -- it was clearly designed to be that way. However, it is also, now, a compiled language.

        So I reject that definition on the grounds that it doesn't make a smeg of practical difference.
        Outside of academia, languages need to be useful above all else. Useful languages eventually get modified and built upon until they become "all things to all people". Creating arbitrary lines and saying "this language is a scripting language because $arbitrary_reason" will never make a whit of difference.

        The only useful description of a language is one that gives you an idea of how it can be used. If you use my definitions, saying "Perl is both a scripted and interpreted language" actually conveys useful information. It tells me that I can run Perl programs as scripts or as bytecode-compiled binaries. That gives me a vague idea of what Perl is capable of. It gives me a clue that Perl will require an interpreter of some kind; and, that means it will have certain pros and cons.

        radiantmatrix
        require General::Disclaimer;
        "Users are evil. All users are evil. Do not trust them. Perl specifically offers the -T switch because it knows users are evil." - japhy
Re: At Last, a Useful Definition of "Scripting Language"
by PhilHibbs (Hermit) on Oct 29, 2004 at 11:04 UTC
    I don't think there's any reasonable definition of "Scripting Language" that would include C. If you want to script something on *nix, you use sh, ksh, csh, bash, perl, ruby, etc., not C. IMO, one aspect of a scripting language is that you don't need to wrap your executable code in anything magical, like a main() function. A scripting language should be able to take a single line with a single statement and execute it. A question to you *nix-heads: Does a shell script have to have a #! line at the start, or is this just a nice-to-have to make sure the right shell executes it?

      If C is your "get stuff done" language, why not say it's your scripting language?

      Does a shell script have to have a #! line at the start, or is this just a nice-to-have to make sure the right shell executes it?

      The shebang is there so you can say:

      $ ./script.sh

      Instead of:

      $ bash script.sh

      The shebang also makes it possible for other programs to execute the script without knowing what language the program is written in. For instance, Apache/mod_cgi just needs to fork() and exec() on anything specified as a CGI. No need to check the file extention or somesuch to line it up with a specific interpreter.

      It is perfectly possible to leave the shebang out. You just have know what interpreter to use.

      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

        C is a generic programming language, with features deliberately left out because they can't be provided on all platforms (e.g. graphics). To me, a scripting language is an embedded language that controls the operation of that which it is embedded into. Hence, shell script is a language embedded into the shell. JavaScript is a language built into web browsers and web servers to provide programmatic access to their features.

        Perl is somewhat unusual, as it can be embedded into other applicatons, is designed to replace the existing scripting language that the shells provide, and also is a stand-alone language with wider capabilities.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://402316]
Approved by coreolyn
Front-paged by Old_Gray_Bear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-12-29 12:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (187 votes), past polls