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?
-
You may want to expand on you're question a little. I feel this is almost a dupe otherwise. Others may not see the distinction– Kent FredricCommented Sep 19, 2008 at 10:59
-
A dupe to which other question?– SietseCommented Sep 19, 2008 at 11:01
-
2stackoverflow.com/questions/98268/… There is a lot of similiarity. Not nessecarily identical, but a lot of shared context/opinion.– Kent FredricCommented Sep 19, 2008 at 11:07
-
7...When a language breaks the API and changes it's syntax every minor release, when it's a wrapper around 100 of dirty unmaintained buggy C libraries, then it's a script language. ;)– ivan_ivanovich_ivanoffCommented Sep 19, 2009 at 23:14
-
1In the "Related" sidebar you'll find stackoverflow.com/questions/1514206/… to which I linked a pile of then existing duplicates going back to stackoverflow.com/questions/101055/… .– dmckee --- ex-moderator kittenCommented May 20, 2010 at 14:31
40 Answers
Simple. When I use it, it's a modern dynamic language, when you use it, it's merely a scripting language!
-
19Yeah. "It's not a 'toy language', it's a 'high-level language'" :P Commented Jun 22, 2009 at 5:28
-
6
-
1Even with -(1+1) it gets about 2x +1s than a checkmarked one. :D Commented Mar 12, 2013 at 13:48
-
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.
-
So what about languages like Python? It's not easy to tell where the focus is, but one could say it's focusing more on own applications, still it's often called a "scripting language". Maybe because the hidden compilation into bytecode of the reference CPython impl. doesn't raise compilation errors regarding "type safety"? Maybe Oded's answer has these...– n611x007Commented Jun 29, 2012 at 6:34
-
Bytecode and type systems don't really have anything to do with it. By the above definition, if an app exposes an API to Python, it is said to use Python as its scripting language. If you build an app entirely in Python, that app uses it as a programming language.– bugCommented Jun 23, 2013 at 3:05
-
"Scripting" isn't a definition of a type of language. It is a characteristic that languages can have. So, Python is a "good scripting language" because it makes it easy to write code that scripts things. Assembly is not a good scripting language because it makes it hard to script. C is somewhere in the middle, because although it has a keyword (system) for calling out, it also saddles the user with lots of cruft before you can get there.– nomenCommented May 17, 2014 at 16:58
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".
-
1
-
1@Ram Bhat - it is confusing, as the distinction is artificial.– OdedCommented May 20, 2010 at 13:37
-
11@Andrey: All modern JavaScript implementations are compiled. And there are interpreters for C. Commented May 20, 2010 at 13:41
-
27This 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. Commented May 20, 2010 at 13:50
-
5@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. Commented May 20, 2010 at 14:00
"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.
-
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!– LazCommented May 20, 2010 at 13:40
-
1And 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. Commented May 20, 2010 at 13:45
My definition would be a language that is typically distributed as source rather than as a binary.
-
5
-
-
22php and python - of course they are scripting languages! Commented May 22, 2009 at 12:05
-
this is what my definition has been since the start– user34537Commented Aug 9, 2009 at 1:13
-
@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))– JoschuaCommented Jun 24, 2010 at 20:31
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.
-
Some of this answer is silly. A language is "object oriented" when it is oriented to programming with objects. A language is "functional" if it has first class functions. That doesn't mean a language can't be both. These are characteristics of languages, not definitions of types. Scripting is similar. A language is a "good scripting language" if it makes it easy to write scripts -- short, simple bits of user-application interaction.– nomenCommented May 17, 2014 at 16:55
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.
-
1It's a very good explanation, but I am sure some people upvote it because they see "porn"– HoKy22Commented Aug 28, 2013 at 19:13
-
"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.
-
-
2What about Java? You need a jvm to run a java program but I wouldn't call it a scripting language– EinekiCommented Dec 29, 2008 at 10:09
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
-
-
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? Commented Aug 18, 2009 at 14:45
-
That is an interpreted language. If you are trying to say that any interpreted language is a scripting language, say that. Commented Mar 20, 2010 at 21:48
-
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. Commented Apr 22, 2010 at 8:21
-
4Common Lisp is not what I usually think of as a scripting language, but it does have a full-strength
eval
function. Commented Jun 15, 2010 at 21:18
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.
-
-
1It supports dynamic typing, but I wouldn't call it a scripting language. Commented May 20, 2010 at 13:50
-
2This 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. Commented May 20, 2010 at 13:54
-
@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. Commented May 20, 2010 at 14:11
A scripting language is typically:
- Dynamically typed
- Interpreted, with very little emphasis on performance, but good portability
- Requires a lot less boilerplate code, leading to very fast prototyping
- 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.
-
2There 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. Commented May 20, 2010 at 13:55
-
@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.– OakCommented May 20, 2010 at 16:39
-
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. Commented May 20, 2010 at 17:54
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.
-
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. Commented May 20, 2010 at 14:14
-
1@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.– PauliLCommented May 20, 2010 at 15:47
-
It is interesting that this answer introduces the idea of a 'hard' language. Does 'hard' need a definition in this context? Commented Jul 26, 2015 at 9:06
-
@DavidVincent: I probably should have meant "harder". No formal definition is necessary, the intuitive understanding should suffice: it is much harder to write a program in Assembly or C than in Ruby or Python, given that the former are much more low-level and verbose than the latter.– AmadanCommented Jul 26, 2015 at 12:39
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.
-
I don't want to denigrate Peter's answer, but can we add more than opinion? Commented Jul 26, 2015 at 9:09
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?
- Chakra & V8 (Microsoft's and Google's JavaScript engines) compile code before execution
- 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:
- copy A.txt to /tmp/work/
- run the nightly cleanup process on the database server
- 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.
-
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– LazCommented May 20, 2010 at 13:52
-
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. Commented May 20, 2010 at 14:00
-
@Will: any distinction would be artificial. This was my opinionated distinction. ;) Commented May 20, 2010 at 14:02
-
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. Commented May 20, 2010 at 14:08
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:
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.
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.
-
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" Commented Sep 19, 2008 at 11:25
-
Static / Dynamic, there are dynamic languages that are compiled. Commented Nov 22, 2008 at 1:46
-
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). Commented Nov 22, 2008 at 3:32
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.
-
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.– anon6439Commented Nov 21, 2008 at 21:49
-
-
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. Commented Oct 11, 2010 at 3:08
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:
Scripting languages don't usually have user-visible compile steps. Typically the user can just run programs in one easy command.
Programs in scripting languages are normally passed around in source form.
Scripting languages normally have runtimes that are present on a large number of systems, and the runtimes can be installed easily on most systems.
Scripting languages tend to be cross-platform and not machine-specific.
Scripting languages make it easy to call other programs and interface with the operating system.
Scripting languages are usually easily embeddable into larger systems written in more conventional programming languages.
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.
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.
-
-
1There should be some sort of badge for that. How about "Can't handle the truth."? Nah, a little too wordy. ;-) Commented Nov 21, 2008 at 21:29
-
3Perl, Python, Ruby, Tcl/Tk - to name but four scripting languages - are not primarily built into a larger application. Commented Mar 20, 2009 at 15:47
-
3
-
3Uh yeah, it'd be nice if this could be unmarked as correct somehow. Commented Aug 15, 2009 at 13:42
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.
-
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...– PhiLhoCommented Nov 22, 2008 at 17:38
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.
-
1You 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 ;)– mthurlinCommented Nov 29, 2008 at 22:02
-
1
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.