Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Quoted from Wikipedia:

A scripting language, script language or extension language is a programming language that allows control of one or more applications and makes the compiler of the language part of the language runtime, and as a result, enables code to be generated dynamically. "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 application is typically first compiled to native machine code.

  1. I was wondering what "enables code to be generated dynamically" means? Isn't code in a scripting language written before it gets run, so how is it generated dynamically?
  2. By definition, is a scripting language always an interpreted language? Conversely, is an interpreted language always a scripting language? They seem to be very close related, or even the same thing.
  3. How is a language non-scripting?

Thanks and regards!

share|improve this question
1  
If I wanted to learn about this, I would want to start with examples of languages and scripts, not an encyclopedic definition. What languages do you know? –  Job Jul 9 '11 at 2:41
    
C, C++, Python, Matlab, R, Bash, Dos, html, latex. I now need the encyclopedic and accurate definition. –  Tim Jul 9 '11 at 2:49
    
I recommend researching the turing test and popular systems that can consistently pass the turing test. Looking into these should give you a good idea what other people have done which should provide insight into how you could go about approaching your project. en.wikipedia.org/wiki/Turing_test –  SpartanDonut Jan 27 '12 at 18:59

4 Answers 4

up vote 8 down vote accepted

There is no technical standard that defines a scripting language. It's just a word that is defined by common usage, and like any other word in common usage, there is no guarantee that all the usages are consistent. Tackling your specific questions:

  1. The dynamic code generation they are talking about is machine code. In a classic interpreted language (think BASIC interpreter), each time a line of a script is executed, that line is translated on the spot into native machine code. It's more complicated now, since many scripting languages will be translated into byte code for a virtual machine, and the byte code may get cached.

  2. This is where it gets very fuzzy, and changes with time. In ye olden days, pretty much every scripting language was a classic interpreted language. Nowadays many use byte code, virtual machines, and may use Just-in-time compilers. At that point the line between interpreted languages and compiled languages is blurry. Still, I don't know of any language commonly referred to as a scripting language that is compiled in the classic sense of a one time conversion to native machine code.

  3. Languages commonly called scripting languages usually provide a suite of high level data structures like sets, lists, and dictionaries, as well as features like regular expressions. There are interpreted languages that don't provide those high level features, and they usually aren't called scripting languages. I don't think many folks would refer to interpreted BASIC or even UCSD Pascal as a scripting language.

share|improve this answer
    
Actually, there is an IEEE standard definition of "scripting language". I'd have to look up the exact phrasing, but it's something along the lines of "a programming language designed to connect two or more applications". –  Thomas Owens Jul 10 '11 at 11:46
    
The absence of a separate compile / link stage usually means that a scripting language is dynamically typed and a lot of statically detectable errors cannot be detected beforehand. OTOH this means that nearly all interfaces use late binding and there's no 'fragile base class' problems, etc — you can even change code on the fly. –  9000 Jul 10 '11 at 12:39
    
@Thomas Owens, really? I mean I'm sure there are IEEE publications that offer a definition of a scripting language, but that's not the same thing as a promulgated standard. In any event, they may have offered that definition as a standard, but it doesn't fit common usage. Sed and Awk are inevitably referred to as scripting languages, but they certainly weren't designed to connect two or more applications, except insofar as any two applications reading from stdin and writing to stdout can be pipelined, but then that would make 'C' a scripting language. –  Charles E. Grant Jul 10 '11 at 16:51
    
@Charles E. Grant I thought the definition was either in the IEEE Glossary or the SWEBOK, but I haven't found it. That wasn't the exact phrasing, but it's pretty close. Either way, it is pretty accuarate because it specifically isolates languages like sed, awk, bash scripting, Windows batch scripts, and so on from more robust languages like Python and Ruby (which have the capability to be scripting languages, but also much more). –  Thomas Owens Jul 10 '11 at 17:16

Here is my definition of script, I hope that can help you understand.

Script - is a quick solution for some simple problem. Some examples are: deployment script (copies app files to required places, restarts services), log parsing script, etc. Performance does not matter here, ability to write and change script quickly - that is matters. So, scripting language is the language suitable for writing scripts.

I was wondering what "enables code to be generated dynamically" means? Isn't code in a scripting language written before it gets run, so how is it generated dynamically?

"enables code to be generated dynamically" means that on scripting language you could do something like eval("print 'hello world!")`.

By definition, is a scripting language always an interpreted language? Conversely, is an interpreted language always a scripting language? They seem to be very close related, or even the same thing.

Yes, sort of. But, many of modern scripting languages is not strictly interpreted. E.g. python generates bytecode from the source. It is not machine code, but there is still compilation phase exists.

How is a language non-scripting?

Any language which does not allow to write one-liners is non-scripting. E.g. you can't write C app without main() function, or java app without writing single class. But you can do it with python, which is fully object-orientired, but allows to write simple programs without any functions or classes.

share|improve this answer

The first question to answer, what is a script (and how does it differ from a program).

A script is a pre-defined sequence of commands which typically requires no interaction with the console (and in fact often no user interface at all). A scripting language is a language which supports scripting. In general, any language can do what a scripting language does, but they are not necessarily interpreted (e.g. an awk script could be converted to C).

share|improve this answer
    
User input has little or nothing to do with whether something is scripted or not. A good counter example is the LAMP model (which drives the majority of websites) where the "P" is a scripting language like Perl, Python, or PHP. –  Mark Mann Jul 9 '11 at 19:22
    
I've rephrased my answer to specify that I meant a script requires no console interaction; this is a more accurate statement of my opinion. –  James McLeod Jul 10 '11 at 11:36

Charles E. Grant hit the nail on the head, but I would like to add something. From a practical point of view, scripting languages are (mostly) ones where you don't have to set up a build process for getting a running solution. So you can just grab a text editor, type your Perl / Python / Ruby / Bash / VBScript / awk / [... add your favorite scripting language here ..] code in there, save it to a file and execute it. This also makes it easy to create programs which generates scripting code dynamically on your users machine and execute that code, what is meant by the wikipedia statement you cited.

When using languages like C / C++ / Java / Fortran / COBOL / Pascal / [... add your favorite non-scripting language here ...], you typically have to set up a compile / link stage before you get something executable from your source code. In a lot of scenarios, the user does not have a compiler for those languages on his machine, so you cannot easily write programs which create other programs in the same language on-the-fly and execute those on the users machine. There are, of course, languages which are not considered as scripting languages where this is possible either (like C# and VB.NET, I am not sure about Java), but as Charles E. Grant wrote, the line between those categories is fuzzy.

To your question about "interpreted languages": to my understanding, what goes behind the scenes is not important for the distinction between scripting and non-scripting languages. It does not matter if your run time environment interprets the source code directly, or if it compiles it to some byte code, which may be just-in-time compiled to machine code. As long as the environment makes you "feel" it runs your source code directly without the need of setting up a build stage, it is a scripting language.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.