Question

What makes a language a scripting language? I've heard some people say "when it gets interpreted instead of compiled". That would make PHP (for example) a scripting language. Is that the only criterion? Or are there other criteria?

See also:

Was it helpful?

Solution

A scripting language is a language that "scripts" other things to do stuff. The primary focus isn't primarily building your own apps so much as getting an existing app to act the way you want, e.g. JavaScript for browsers, VBA for MS Office.

OTHER TIPS

Simple. When I use it, it's a modern dynamic language, when you use it, it's merely a scripting language!

Traditionally, when talking about the difference about scripting versus programming, scripts are interpreted and programs are compiled. A language can be executed in different ways - interpreted or compiled (to bytecode or machine code). This does not make a language one or another.

In some eyes, the way you use a language makes it a scripting language (for example, game developers who develop mainly in C++ will script the objects in Lua). Again, the lines are blurred - a language can be used for a programming by one person and the same language can be used for scripting language by another.

This is from the wikipedia article about scripting languages:

A scripting language, script language or extension language is a programming language that allows control of one or more software applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the end-user. Scripts are often interpreted from source code or bytecode, whereas the applications they control are traditionally compiled to native machine code. Scripting languages are nearly always embedded in the applications they control.

You will notice the use of "usually", "often", "traditionally" and "nearly always" - these all tell you that there is no set of distinct attributes that make a specific language a "scripting language".

"A script is what you give the actors. A program is what you give the audience." -- Larry Wall

I really don't think there's much of a difference any more. The so-called "scripting" languages are often compiled -- just very quickly, and at runtime. And some of the "programming" languages are are further compiled at runtime as well (think of JIT) and the first stage of "compiling" is syntax checking and resource resolution.

Don't get hung up on it, it's really not important.

My definition would be a language that is typically distributed as source rather than as a binary.

There's a lot of possible answers to this.

First: it's not really a question of the difference between a scripting language and a programming language, because a scripting language is a programming language. It's more a question of what traits make some programming language a scripting language while another programming language isn't a scripting language.

Second: it's really hard to say what a XYZ language is, whether that XYZ be "scripting", "functional programming", "object-oriented programming" or what have you. The definition of what "functional programming" is, is pretty clear, but nobody knows what a "functional programming language" is.

Functional programming or object-oriented programming are programming styles; you can write in a functional style or an object-oriented style in pretty much any language. For example, the Linux Virtual File System Switch and the Linux Driver Model are heavily object-oriented despite written in C, whereas a lot of Java or C# code you see on the web is very procedural and not object-oriented at all. OTOH, I have seen some heavily functional Java code.

So, if functional programming and object-oriented programming are merely styles that can be done in any language, then how do you define an "object-oriented programming language"? You could say that an object-oriented programming language is a language that allows object-oriented programming. But that's not much of a definition: all languages allow object-oriented programming, therefore all languages are object-oriented? So, you say, well a language is object-oriented, if it forces you to programming in an object-oriented style. But that's not much of a definition, either: all languages allow functional programming, therefore no language is object-oriented?

So, for me, I have found the following definition:

A language is a scripting language (object-oriented language / functional language) if it both

  • facilitates scripting (object-oriented programming / functional programming), i.e. it not only allows it but makes it easy and natural and contains features that help with it, AND
  • encourages and guides you towards scripting (object-oriented programming / functional programming).

So, after five paragraphs, I have arrived at: "a scripting language is a language for scripting". What a great definition. NOT.

Obviously, we now need to look at the definition of "scripting".

This is where the third problem comes in: whereas the term "functional programming" is well-defined and it's only the term "functional programming language" that is problematic, unfortunately with scripting, both the term "scripting" and the term "scripting language" are ill-defined.

Well, firstly scripting is programming. It's just a special kind of programming. IOW: every script is a program, but not every program is a script; the set of all scripts is a proper subset of the set of all programs.

In my personal opinion, the thing that makes scripting scripting and distinguishes it from other kinds of programming, is that …

Scripts largely manipulate objects that

  • were not created by the script,
  • have a lifetime independent of the script and
  • live outside the domain of the script.

Also, the datatypes and algorithms used are generally not defined by the script but by the outside environment.

Think about a shell script: shell scripts usually manipulate files, directories and processes. The majority of files, directories and processes on your system were probably not created by the currently running script. And they don't vanish when the script exits: their lifetime is completely independent of the script. And they aren't really part of the script, either, they are a part of the system. You didn't start your script by writing File and Directory classes, those datatypes are none of your concern: you just assume they are there, and you don't even know (nor do you need to know) how they work. And you don't implement your own algorithms, either, e.g. for directory traversal you just use find instead of implementing your own breadth-first-search.

In short: a script attaches itself to a larger system that exists independently of the script, manipulates some small part of the system and then exits.

That larger system can be the operating system in case of a shell script, the browser DOM in case of a browser script, a game (e.g. World of Warcraft with Lua or Second Life with the Linden Scripting Language), an application (e.g. the AutoLisp language for AutoCAD or Excel/Word/Office macros), a web server, a pack of robots or something else entirely.

Note that the scripting aspect is completely orthogonal to all the other aspects of programming languages: a scripting language can be strongly or weakly typed, strictly or loosely typed, statically or dynamically typed, nominally, structurally or duck typed, heck it can even be untyped. It can be imperative or functional, object-oriented, procedural or functional, strict or lazy. Its implementations can be interpreted, compiled or mixed.

For example, Mondrian is a strictly strongly statically typed lazy functional scripting language with a compiled implementation.

However, all of this is moot, because the way the term scripting language is really used in the real world, has nothing to do with any of the above. It is most often used simply as an insult, and the definition is rather simple, even simplistic:

  • real programming language: my programming language
  • scripting language: your programming language

This seems to be the way that the term is most often used.

It's like porn, you know it when you see it. The only possible definition of a scripting language is:

A language which is described as a scripting language.

A bit circular, isn't it? (By the way, I'm not joking).

Basically, there is nothing that makes a language a scripting language except that it is called such, especially by its creators. The major set of modern scripting languages is PHP, Perl, JavaScript, Python, Ruby and Lua. Tcl is the first major modern scripting language (it wasn't the first scripting language though, I forget what it is, but I was surprised to learn that it predated Tcl).

I describe features of major scripting languages in my paper:

 A Practical Solution for Scripting Language Compilers
 Paul Biggar, Edsko de Vries and David Gregg
 SAC '09: ACM Symposium on Applied Computing (2009), (March 2009)

Most are dynamically typed and interpreted, and most have no defined semantics outside of their reference implementation. However, even if their major implementation becomes compiled or JITed, that doesn't change the "nature" of the language.

They only remaining question is how can you tell if a new language is a scripting language. Well, if it's called a scripting language, it is one. So Factor is a scripting language (or at least was when that was written), but, say, Java is not.

"Scripting language" is one of those fuzzy concepts which can mean many things. Usually it refers to the fact that there exists a one step process taking you from the source code to execution.

For example in Perl you do: perl my_source.pl

Given the above criteria PHP is a scripting language (even though you can have a "compilation" process for example when using the Zend Encoder to "protect" the source code).

PS. Often (but not always) scripting languages are interpreted. Also often (but again, not always) scripting languages are dynamically typed.

All scripting languages are programming languages. So strictly speaking, there is no difference.

The term doesn't refer to any fundamental properties of the language, it refers to the typical use of the language. If the typical use is to write short programs that mainly do calls to pre-existing code, and some simple processing on the results, (that is, if the typical use is to write scripts) then it is a scripting language.

I think Mr Roberto Ierusalimschy has a very good answer or the question in 'Programming in Lua':

However, the distinguishing feature of interpreted languages is not that they are not compiled, but that any compiler is part of the language runtime and that, therefore, it is possible (and easy) to execute code generated on the fly

One division is

  • scripting = dynamically interpreted
  • normal = compiled

A dynamically interpreted language is interpreted at runtime whereas a compiled language is compiled before execution.

I should add that as Jörg has pointed out, the interpreted / compiled distinction is not a feature of the language, but of the execution engine.

You might also be interested in this explanation of Type system, which is related and focuses more on the language aspect, instead of the execution engine. Most scripting languages are dynamically typed, whereas "normal" languages are mostly statically typed.

In general the division of statically vs dynamically typed languages is better defined and has more implications on the usability of the language.

A scripting language is typically:

  1. Dynamically typed
  2. Interpreted, with very little emphasis on performance, but good portability
  3. Requires a lot less boilerplate code, leading to very fast prototyping
  4. Is used for small tasks, suitable for writing one single file to run some useful "script".

While a non-scripting language is usually: 1. Statically typed 2. Compiled, with emphasis on performance 3. Requires more boilerplate code, leading to slower prototyping but more readability and long-term maintainability 4. Used for large projects, adapts to many design patterns

But it's more of a historical difference nowadays, in my opinion. Javascript and Perl were written with small, simple scripts in mind, while C++ was written with complex applications in mind; but both can be used either way. And many programming languages, modern and old alike, blur the line anyway (and it was fuzzy in the first place!).

The sad thing is, I've known a few developers who loathes what they perceived as "scripting languages", thinking them to be simpler and not as powerful. My opinion is that old cliche - use the right tool for the job.

Scripting languages were originally thought of as a control mechanisms for applications written in a hard programming language. The compiled programs could not be modified at runtime, so scripting gave people flexibility.

Most notably, shell script was automating processes in the OS kernel (traditionally, AppleScript on Macs); a role which more and more passed into Perl's hands, and then out of it into Python lately. I've seen Scheme (particularly in its Guile implementation) used to declare raytracing scenes; and recently, Lua is very popular as the programming language to script games - to the point that the only hard-coded thing in many new games is the graphics/physics engine, while the whole game logic is encoded in Lua. In the same way, JavaScript was thought to script the behaviour of a web browser.

The languages emancipated; no-one now thinks about the OS as an application (or thinks about it much at all), and many formerly scripting languages began to be used to write full applications of their own. The name itself became meaningless, and spread to many interpreted languages in use today, regardless of whether they are designed to be interpreted from within another system or not.

However, "scripting languages" is most definitely not synonymous with "interpreted languages" - for instance, BASIC was interpreted for most of its life (i.e. before it lost its acronimicity and became Visual Basic), yet no-one really thinks of it as scripting.

UPDATE: Reading material as usual available at Wikipedia.

First point, a programming language isn't a "scripting language" or a something else. It can be a "scripting language" and something else.

Second point, the implementer of the language will tell you if it's a scripting language.

Your question should read "In what implementations would a programming language be considered a scripting language?", not "What is the difference between a scripting language and a programming language?". There is no between.

Yet, I will consider a language a scripting language if it is used to provide some type of middle ware. For example, I would consider most implementations of JavaScript a scripting language. If JavaScript were run in the OS, not the browser, then it would not be a scripting language. If PHP runs inside of Apache, it's a scripting language. If it's run from the command line, it's not.

I see a scripting language as anything not requiring an overt heavy-weight feeling 'compile' step. The main feature from a programmers standpoint is: you edit code and run it right away.

Thus I would regard JavaScript and PHP as scripting languages, whereas ActionScript 3/Flex is not really.

My friend and I just had this argument: What is the difference between a programming language and a scripting language.

A popular argument is that programming languages are compiled and scripting languages are interpreted - However I believe this argument to be completely false...why?

  1. Chakra & V8 (Microsoft's and Google's JavaScript engines) compile code before execution
  2. QBasic is interpreted - does this make Qbasic a "scripting" language?

On that basis, this is my argument for the difference between a programming language and a scripting language:

A programming language runs at the machine level and has access to the machine itself (memory, graphics, sound etc).

A scripting language is sand boxed and only has access to objects exposed to the sand box. It has no direct access to the underlying machine.

In My Opinion, I would say that dynamically interpreted languages such as PHP, Ruby, etc... are still "normal" langauges. I would say that examples of "scripting" languages are things like bash (or ksh or tcsh or whatever) or sqlplus. These languages are often used to string together existing programs on a system into a series of coherent and related commands, such as:

  1. copy A.txt to /tmp/work/
  2. run the nightly cleanup process on the database server
  3. log the results and send them to the sysdamin

So I'd say the difference (for me, anyway) is more in how you use the language. Languages like PHP, Perl, Ruby could be used as "scripting languages", but I usually see them used as "normal languages" (except Perl which seems to go both ways.

I'll just go ahead and migrate my answer from the duplicate question


The name "Scripting language" applies to a very specific role: the language which you write commands to send to an existing software application. (like a traditional tv or movie "script")

For example, once upon a time, HTML web pages were boring. They were always static. Then one day, Netscape thought, "Hey, what if we let the browser read and act on little commands in the page?" And like that, Javascript was formed.

A simple javascript command is the alert() command, which instructs/commands the browser (a software app) that is reading the webpage to display an alert.

Now, does alert() related, in any way, to the C++ or whatever code language that the browser actually uses to display the alert? Of course not. Someone who writes "alert()" on an .html page has no understanding of how the browser actually displays the alert. He's just writing a command that the browser will interpret.

Let's see the simple javascript code

<script>
var x = 4
alert(x)
</script>

These are instructs that are sent to the browser, for the browser to interpret in itself. The programming language that the browser goes through to actually set a variable to 4, and put that in an alert...it is completely unrelated to javascript.

We call that last series of commands a "script" (which is why it is enclosed in <script> tags). Just by the definition of "script", in the traditional sense: A series of instructions and commands sent to the actors. Everyone knows that a screenplay (a movie script), for example, is a script.

The screenplay (script) is not the actors, or the camera, or the special effects. The screenplay just tells them what to do.

Now, what is a scripting language, exactly?

There are a lot of programming languages that are like different tools in a toolbox; some languages were designed specifically to be used as scripts.

Javasript is an obvious example; there are very few applications of Javascript that do not fall within the realm of scripting.

ActionScript (the language for Flash animations) and its derivatives are scripting languages, in that they simply issue commands to the Flash player/interpreter. Sure, there are abstractions such as Object-Oriented programming, but all that is simply a means to the end: send commands to the flash player.

Python and Ruby are commonly also used as scripting languages. For example, I once worked for a company that used Ruby to script commands to send to a browser that were along the lines of, "go to this site, click this link..." to do some basic automated testing. I was not a "Software Developer" by any means, at that job. I just wrote scripts that sent commands to the computer to send commands to the browser.

Because of their nature, scripting languages are rarely 'compiled' -- that is, translated into machine code, and read directly by the computer.

Even GUI applications created from Python and Ruby are scripts sent to an API written in C++ or C. It tells the C app what to do.

There is a line of vagueness, of course. Why can't you say that Machine Language/C are scripting languages, because they are scripts that the computer uses to interface with the basic motherboard/graphics cards/chips?

There are some lines we can draw to clarify:

  1. When you can write a scripting language and run it without "compiling", it's more of a direct-script sort of thing. For example, you don't need to do anything with a screenplay in order to tell the actors what to do with it. It's already there, used, as-is. For this reason, we will exclude compiled languages from being called scripting languages, even though they can be used for scripting purposes in some occasions.

  2. Scripting language implies commands sent to a complex software application; that's the whole reason we write scripts in the first place -- so you don't need to know the complexities of how the software works to send commands to it. So, scripting languages tend to be languages that send (relatively) simple commands to complex software applications...in this case, machine language and assembly code don't cut it.

May I suggest that scripting languages has been a term lots of people are moving away from. I'd say it mostly boils down to compiled languages and dynamic languages nowadays.

I mean you can't really say something like Python, or Ruby are "scripting" languages in this day and age (you even have stuff like IronPython and JIT-your-favorite-language, the difference has been blurred even more).

To be honest, personally I don't feel PHP is a scripting language anymore. I wouldn't expect people to like categorize PHP differently from say Java on their resume.

Scripting languages tend to run within a scripting engine which is part of a larger application. For example, JavaScript runs inside your browsers scripting engine.

A scripting language is a language that is interpreted every time the script is run, it implies having a interpreter and most are very human readable, to be useful a scripting language is easy to learn and use.

Every compilable language can be made into a script language and vice versa it all depends on implementing a interpreter or a compiler, as an example C++ has an interpreter so it can be called a script language if used so (not very practical in general as C++ is a very complex language), one of the most useful script languages at present is Python...

So to answer your question the definition is on the use of a interpreter to run quick and easy scripted programs, to address simple tasks or prototype applications the most powerful use one can make of script languages is to include the possibility for every use to extend a compiled application.

I prefer that people not use the term "scripting language" as I think that it diminishes the effort. Take a language like Perl, often called "scripting language".

  • Perl is a programming language!
  • Perl is compiled like Java and C++. It's just compiled a lot faster!
  • Perl has objects and namespaces and closures.
  • Perl has IDEs and debuggers and profilers.
  • Perl has training and support and community.
  • Perl is not just web. Perl is not just sysadmin. Perl is not just the duct tape of the Internet.

Why do we even need to distinguish between a language like Java that is compiled and Ruby that isn't? What's the value in labeling?

For more on this, see http://xoa.petdance.com/Stop_saying_script.

An important difference is strong typing (versus weak typing). Scripting languages are often weakly typed, making it possible to write small programs more rapidly. For large programs this is a disadvantage, as it inhibits the compiler/interpreter to find certain bugs autonomously, making it very hard to refactor code.

Scripting languages are programming languages where the programs are typically delivered to end users in a readable textual form and where there is a program that can apparently execute that program directly. (The program may well compile the script internally; that's not relevant here because it is not visible to the user.)

It's relatively common for scripting languages to be able to support an interactive session where users can just type in their program and have it execute immediately. This is because this is a trivial extension of the essential requirement from the first paragraph; the main extra requirement is the addition of a mechanism to figure out when a typed-in statement is complete so that it can be sent to the execution engine.

For a slightly different take on the question. A scripting language is a programming language but a programming language is not necessarily a scripting language. A scripting language is used to control or script a system. That system could be an operating system where the scripting language would be bash. The system could be a web server with PHP the scripting language. Scripting languages are designed to fill a specific niche; they are domain specific languages. Interactive systems have interpreted scripting languages giving rise to the notion that scripting languages are interpreted; however, this is a consequence of the system and not the scripting language itself.

A scripting language is a language that configures or extends an existing program.
A Scripting Language is a Programming language.

The definition of "scripting language" is pretty fuzzy. I'd base it on the following considerations:

  1. Scripting languages don't usually have user-visible compile steps. Typically the user can just run programs in one easy command.

  2. Programs in scripting languages are normally passed around in source form.

  3. Scripting languages normally have runtimes that are present on a large number of systems, and the runtimes can be installed easily on most systems.

  4. Scripting languages tend to be cross-platform and not machine-specific.

  5. Scripting languages make it easy to call other programs and interface with the operating system.

  6. Scripting languages are usually easily embeddable into larger systems written in more conventional programming languages.

  7. Scripting languages are normally designed for ease of programming, and with much less regard for execution speed. (If you want fast execution, the usual advice is to code the time-consuming parts in something like C, and either embed the language into C or call C bits from the language.)

Some of the characteristics I listed above are true of implementations, in which case I'm referring to the more common implementations. There have been C interpreters, with (AFAIK) no obvious compile step, but that's not true of most C implementations. You could certainly compile a Perl program to native code, but that's not how it's normally used. Some other characteristics are social in nature. Some of the above criteria overlap somewhat. As I said, the definition is fuzzy.

I would say scripting language is the one heavily manipulating entities it doesn't itself define. For instance, JavaScript manipulates DOM objects provided by the browser, PHP operates enormous library of C-based functions, and so on. Of course not a precise definition, more a way to think if it.

If it doesn't/wouldn't run on the CPU, it's a script to me. If an interpreter needs to run on the CPU below the program, then it's a script and a scripting language.

No reason to make it any more complicated than this?

Of course, in most (99%) of cases, it's clear whether a language is a scripting language. But consider that a VM can emulate the x86 instruction set, for example. Wouldn't this make the x86 bytecode a scripting language when run on a VM? What if someone was to write a compiler that would turn perl code into a native executable? In this case, I wouldn't know what to call the language itself anymore. It'd be the output that would matter, not the language.

Then again, I'm not aware of anything like this having been done, so for now I'm still comfortable calling interpreted languages scripting languages.

A script is a relatively small program. A system is a relatively large program, or a collection of relatively large programs.

Some programming languages are designed with features that the language designer and the programming community consider to be useful when writing relatively small programs. These programming languages are known as scripting languages, e.g. PHP.

Similarly, other programming languages are designed with features that the language designer and the programming community consider to be useful when writing relatively large programs. These programming languages are known as systems languages, e.g. Java.

Now, small and large programs can be written in any language. A small Java program is a script. For example, a Java "Hello World" program is a script, not a system. A large program, or collection of programs, written in PHP is a system. For example, Facebook, written in PHP, is a system, not a script.

Considering a single language feature as a "litmus test" for deciding whether the language is best suited for scripting or systems programming is questionable. For example, scripts may be compiled to byte code or machine code, or they may be executed by direct abstract syntax tree (AST) interpretation.

So, a language is a scripting language if it is typically used to write scripts. A scripting language might be used to write systems, but such applications are likely to be considered dubious.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top