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?
相关问题
- mv wrapped inside an if in shell scripting
- Why do I use double quotes in shell scripts [dupli
- Is divide by zero an error or an exception?
- Is there an easy way to convert HTML with multiple
- Piping Batch File output to a Python script
相关文章
- Is there a non-java, cross platform way to launch
- Temporal Extraction (i.e. Extract date/time entiti
- Are there any reasons not to use “this” (“Self”, “
- Call/Return feature of classic C++(C with Classes)
- What does “exposition only” mean? Why use it?
- What are the major differences between C and C++ a
- Why should I use UL/LI in my HTML?
- “Adapter” or “adaptor”?
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.
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:
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 think Mr Roberto Ierusalimschy has a very good answer or the question in 'Programming in Lua':
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".
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.
A scripting language is a language that configures or extends an existing program.
A Scripting Language is a Programming language.
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:
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 …
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
andDirectory
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 usefind
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:
This seems to be the way that the term is most often used.