views:

2315

answers:

36

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:

A: 

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.

Martin OConnor
Hilarious that the accepted answer has two downvotes.
Robert S.
There should be some sort of badge for that. How about "Can't handle the truth."? Nah, a little too wordy. ;-)
joseph.ferris
Perl, Python, Ruby, Tcl/Tk - to name but four scripting languages - are not primarily built into a larger application.
Jonathan Leffler
Ergo - they are not scripting languages.
Milen A. Radev
Uh yeah, it'd be nice if this could be unmarked as correct somehow.
Noon Silk
This is silly. A modern JavaScript engines are more than just simple text scanners -- would knowing that "they had JIT compilers" change the summation? See: http://ejohn.org/blog/tracemonkey/ Or what about Clojure which compiles-on-the-fly to Java Bytecode? (And is Java and/or the JVM... time for soccer :)
pst
A: 

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.

Michael Pliskin
Mmm, PHP uses the underlying C library, but it is the case for most languages, including Java (at the lowest level). And it doesn't manipulate these functions...
PhiLho
+5  A: 

"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.

Cd-MaN
Perl compiles to byte-code before it runs.
Brad Gilbert
What about Java? You need a jvm to run a java program but I wouldn't call it a scripting language
Eineki
+16  A: 

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.

moffdub
A: 

Your criteria sounds about right,but is always a bit fuzzy. For instance, Java is both compiled (to bytecode) and then interpreted (by the JVM). Yet it is normally not categorized as a scripting language.

This might be because Java is statically typed. Where as JavaScript, Ruby, Python, Perl etc. are not (all of which are often called scripting languages).

Einar
Java hasn't been interpreted in a long time.
Paul Biggar
+14  A: 

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

kenny
So you think php, python, etc are scripting languages?
Sietse
"Scripting" is a common description for Python and PHP.
S.Lott
php and python - of course they are scripting languages!
Antony Carthy
this is what my definition has been since the start
acidzombie24
What about Lisp or Scheme?
tloach
@Antony Carthy this is wrong. Python isn't a scripting language usually, but it can be, like any other language, that is used within a programm (like Word (VB), Browser (JS))
Joschua
+1  A: 

This duplicates http://stackoverflow.com/questions/100905/programming-vs-scripting-whats-your-definition

Peter Hilton
I don't think so. A language is different from the act of using it. For instance, I could "script" in php, even though it probably isn't considered a scripting language (anymore).
Sietse
PHP is definitely considered a scripting language.
psoul
+2  A: 

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 snd JitYourFavoriteLanguage, 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 there resume.

Robert Gould
Even tho I work in php a lot, I would say that untill it moves from being script-based to having a /real/ fcgi servlet model dispatching tasks delegated from the server, I would personally call it "a rather good scripting language, which can give the illusion of an application"
Kent Fredric
Static / Dynamic, there are dynamic languages that are compiled.
Brad Gilbert
I repeat: 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 snd JitYourFavoriteLanguage, the difference has been blurred even more).
Robert Gould
+34  A: 

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

Martin Beckett
Yeah. "It's not a 'toy language', it's a 'high-level language'" :P
Roberto Bonvallet
Hahaha. +1 ....
DigitalRoss
that was bumptious and off the topic, -1
adf88
So was your comment..... ps your mother!
Martin Beckett
+1  A: 

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.

Panic
A: 

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.

Andy Lester
No computer can run perl or ruby (or any form they could be compiled into) natively. Therefore perl and ruby are scripting languages, interpreted by a parser or VM.
psoul
@psoul: yes. so is java.
Stefano Borini
There are several techniques to compile ruby to machine code although I'm not sure if any of those don't just bundle the interpreter with string representing ruby code, but even if that were true a ruby to machine code translator can be made.Compiling it to machine code wouldn't make it anywhere close to c speed due to all the dynamic dispatch and gc among other things. I don't think there are any ruby processors but have been machines designed to more closely fit the lisp model and processors which ran java bytecode.
Roman A. Taycher
+4  A: 

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

Rodrigo Lopez
This doesnt answer the question at all!
Paul Biggar
Let me re-state that, a scripting language is one where the compiler is included and it is possible to execute code generated on the fly.How does that not answer the question?
Rodrigo Lopez
@Rodrigo: That is an interpreted language. If you are trying to say that any interpreted language is a scripting language, say that.
Paul Biggar
Well, all languages can be used for scripting, the key item for me is how suitable they are. For me the distinguishing feature is that, yes, they are interpreted.
Rodrigo Lopez
Common Lisp is not what I usually think of as a scripting language, but it does have a full-strength `eval` function.
David Thornley
A: 

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.

psoul
You are calling pretty much all languages except those who compile into native binary for scripting languages? Im sure the Java-developers will be happy to be called scripters ;)
truppo
They are.Scripters, that is.
psoul
A: 

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.

Greg Mattes
+3  A: 

I say 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 AS3/FLEX is not really

Scott Evernden
A: 

Also, you may want to check out this podcast on scripting languages.

none
A: 

Paraphrasing Robert Sebesta in Concepts of Programming Languages:

A scripting language is used by putting a list of commands, called a script, in a file to be executed. The first of these languages, named sh (for shell), began as a small collection of commands that were interpreted as calls to system sub-programs that performed utility funcions, such as file management and simple file filtering. To this basis were added variables, control flow statemens, functions, and various other capabilities, and the result is a complete programming language.

And then you have examples like awk, tcl/tk, perl (which says that initially was a combination between sh and awk but it became so powerfull that he considers it an "odd but full-fledged programming language"). Other examples include CGI and JavaScript.

Eliseo Ocampos
CGI is not a language.
Paul Biggar
:/ You're right, what I meant was that _CGI programming_ is usually done with scripting languages (perl, ruby)
Eliseo Ocampos
+4  A: 

Its 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 its 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.

Paul Biggar
+1  A: 

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.

Dimitri C.
A: 

Even Java is "a scripting language", because it is implemented in C"

Although I hesitate to attempt to improve on mgb's near-perfect answer, the fact is that nothing is better than C for implementation, yet the language is rather low-level and close to the hardware. Pure genius, for sure, but to develop modern SW we want a higher level language that stands on the shoulders of C, so to speak.

So, you have Python, Ruby, Perl, and yes, even Java, all implemented in C. People don't insult Java by calling it a scripting language but it is. If you want a powerful, modern, dynamic, reflective, blah blah blah language you probably are running something like Ruby that is either interpreted directly in C or compiled down to something that is interpreted/JIT compiled, by some C program.

The other distinction people make is to call the dynamically-typed languages "scripting languages".

DigitalRoss
Just so you know, Java's implemented in C++.
Donal Fellows
Java can technically be implemented in anything technically as its a language standard not an implementation, The main sun/openjdk implementation is in c++ with some assembly.
Roman A. Taycher
+17  A: 

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".

Oded
hmmm, so what about javascript? is it programming or scripting?
Amr ElGarhy
thats it? but every interpreted language is not called a scripting language. I'm still confused!
Ram Bhat
@Amr: Well it is called java*script*
sepp2k
@Amr ElHarhy - Javascript started off as a purely scripting language. If you really want to look at a language that blurs the definition, look at python.
Oded
@sepp2k so its not programming language?
Amr ElGarhy
@Ram Bhat - it is confusing, as the distinction is artificial.
Oded
you guys are giving examples..I'd like to know WHAT would classify a language as scripting language? other than compiled and intepreted
Ram Bhat
@Ram Bhat: fact of compilation. is C compiled? yes, so it is not scripting. is Javascript compiled? no, then scripting.
Andrey
@Andrey: *All* modern JavaScript implementations are compiled. And there are interpreters for C.
Jörg W Mittag
@Jörg +1 and this is what brings us back to the distinction being useless.
David Dorward
@Andrey Isn't that software dependant? I mean I've come across C language interpreters! So by that definition it means C is both a scripting language and a "normal" programming language!!
Ram Bhat
@Jörg W Mittag: proove it please. i know that js is being compiled, but i doubt about All
Andrey
This is just plain wrong. Well, actually it is not even *wrong*, it just plain doesn't make sense. There is no such thing as a compiled or interpreted language. A language isn't compiled, a language just *is*. It's a bunch of abstract mathematical rules. Interpretation and compilation are traits of an *execution engine*, not a language. *Every* language can be implemented with either a compiler or an interpreter. In fact, *all* the languages that have been cited as "interpreted" on this page, have almost exclusively compiled implementations, for example JavaScript, PHP, Python, Ruby.
Jörg W Mittag
@Andrey: Chakra (IE9), TraceMonkey/JägerMonkey (Firefox), Nitro (Safari), Carakan (Opera) all compile JavaScript to bytecode and then some of the bytecode is interpreted and some compiled to native code. V8 (Chrome) skips bytecode and compiles JavaScript straight to native code. IronJS compiles JavaScript to CIL bytecode. Rhino compiles JavaScript to JVML bytecode. BESEN (the only ECMAScript 5 engine so far) compiles JavaScript to BESEN bytecode, and a native compiler is currently being added. Some of the above also compile regular expressions to native machine code.
Jörg W Mittag
@Jörg W Mittag - thanks for your comments. I have updated my answer to address the issues you have raised.
Oded
+3  A: 

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.

Timo Westkämper
What about Objective-C ?
mouviciel
It supports dynamic typing, but I wouldn't call it a scripting language.
Timo Westkämper
This is just plain wrong. Well, actually it is not even *wrong*, it just plain doesn't make sense. There is no such thing as a compiled or interpreted language. A language isn't compiled, a language just *is*. It's a bunch of abstract mathematical rules. Interpretation and compilation are traits of an *execution engine*, not a language. *Every* language can be implemented with either a compiler or an interpreter. In fact, *all* the languages that have been cited as "interpreted" on this page, have almost exclusively compiled implementations, for example JavaScript, PHP, Python, Ruby.
Jörg W Mittag
@jorg-w-mittag, Feel free to edit my answer to make it more correct. Your points are valid. Normally though, if you talk about a language, you also talk about the default execution engine.
Timo Westkämper
+12  A: 

"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.

clintp
hmmm.. I'm not hung up, but most interviewers and teachers are. And I've never had anyone of these people give me a satisfying answer!
Ram Bhat
And if you gave one of the other answers here, as an interviewer I'd think you really didn't have a handle on the question. The distinction really is blurry and there's no clear-cut answer. If you'd said "Well, traditionally..." I'd take that, but then I'd expect you to discuss things like runtime compilation and JIT'ing as well.
clintp
+1  A: 

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.

FrustratedWithFormsDesigner
Thanks.. This makes things a bit clearer. So to recap, scripting languages are designed to use already existing programs together in a sequence. BUT languages like C can be used to do the same via API's. So technically speaking it all depends upon use
Ram Bhat
No, you're just making an artificial distinction (which is what this is). If you can whip up something quickly with it, a language will often be called a scripting language, but that's not a strict definition or anything. Commonly interpreted languages are often called scripting languages as well.
Will
@Will: any distinction would be artificial. This was my opinionated distinction. ;)
FrustratedWithFormsDesigner
@FrustratedWithFormsDesigner: yeah, but "scripting" in this case is a highly colloquial and vague usage. Deciding that it's "to use already existing programs together in a sequence" is very specific, and not quite right. That sounds like a *shell script*, maybe, but not Perl. Then to contrast that with APIs (?) ... I just didn't want the guy to get too far off track.
Will
A: 

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.

Oak
There is no such thing as a compiled or interpreted language. A language isn't compiled, a language just *is*. It's a bunch of abstract mathematical rules. Interpretation and compilation are traits of an *execution engine*, not a language. *Every* language can be implemented with either a compiler or an interpreter. In fact, *all* the languages that have been cited as "interpreted" on this page, have almost exclusively compiled implementations, for example JavaScript, PHP, Python, Ruby.
Jörg W Mittag
@Jorg: Good point, I agree. But I didn't say that cannot be compiled, just said that these kinds of languages are typically interpreted rather than compiled, in common usage.
Oak
Are they? All current implementations of Python, PHP, Perl and Lua are compiled. With the exception of MRI, all current implementations of Ruby are compiled. (And there *are* actually not one, but *two* JIT compilers for MRI.) With the exception of JScript, all current JavaScript implementations are compiled. Note that JScript's successor, Chakra, is compiled. Many implementations of Scheme are compiled. ELisp is compiled.
Jörg W Mittag
+3  A: 

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.

Joren
+2  A: 

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.

Amadan
Actually, the original BASIC implementation was a compiler. It was only later that BASIC clones were written as interpreters, because interpreters are supposedly easier to write than compilers.
Jörg W Mittag
@Jörg: Not quite so. While the very first test implementations of Dartmouth BASIC were compiled (called Card BASIC) the actual implementations were interpreters. In fact, probably the most important new feature of BASIC was that it was interactive. No need to punch the source code into a cards and feed them to compiler. The user could just sit at the teletype, write the program and then run it.
PauliL
+1  A: 

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.

Donal Fellows
A: 

just to breif

Scripting languages run inside another program. Scripting languages are not compiled. Scripting languages are easy to use and easy to write. but …

Very popular programming languages (Java, C#) run inside a ‘parent’ program – like scripting languages. Scripting languages today are used to build complex software. Computers are so fast these days, and scripting languages are so efficient, that for most business operations, there is no practical speed advantage (that there once was,) with a compiled programming language.

Srikanth Naidu
+1  A: 

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.

phreed
A: 

As someone else noted, there's no such thing as a compiled or interpreted language, since any language can be either compiled or interpreted. But languages which have been traditionally interpreted rather than compiled (Python, Perl, Ruby, PHP, JavaScript, Lua) also are the ones that people tend to call scripting languages. So it's relatively reasonable to say that a scripting language is one that is commonly interpreted rather than compiled. The other characteristics which scripting languages have in common are related to the fact that they are interpreted.

Scripting languages are really a subset of programming languages; I don't think most people would claim that any of the languages I mentioned earlier aren't also programming languages.

kerkeslager
+1  A: 

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.

Marcus Adams
+1  A: 

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

Romain Hippeau
+3  A: 
Jörg W Mittag
+1  A: 

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.

David Thornley
A: 

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.

Justin L.