Scripting Language vs Programming Language [closed]
Asked Answered
P

14

385

Can anyone explain the difference between Scripting Language and Programming Language please?
Also can you state some examples for each. I have Googled a lot but I always find the best answers from Stack Overflow.

Pellegrino answered 22/6, 2013 at 17:41 Comment(1)
See also #98768Caswell
P
522

Scripting languages are programming languages that don't require an explicit compilation step.

For example, in the normal case, you have to compile a C program before you can run it. But in the normal case, you don't have to compile a JavaScript program before you run it. So JavaScript is sometimes called a "scripting" language.

This line is getting more and more blurry since compilation can be so fast with modern hardware and modern compilation techniques. For instance, V8, the JavaScript engine in Google Chrome and used a lot outside of the browser as well, actually compiles the JavaScript code on the fly into machine code, rather than interpreting it. (In fact, V8's an optimizing two-phase compiler.)

Also note that whether a language is a "scripting" language or not can be more about the environment than the language. There's no reason you can't write a C interpreter and use it as a scripting language (and people have). There's also no reason you can't compile JavaScript to machine code and store that in an executable file (and people have). The language Ruby is a good example of this: The original implementation was entirely interpreted (a "scripting" language), but there are now multiple compilers for it.

Some examples of "scripting" languages (e.g., languages that are traditionally used without an explicit compilation step):

  • Lua
  • JavaScript
  • VBScript and VBA
  • Perl

And a small smattering of ones traditionally used with an explicit compilation step:

  • C
  • C++
  • D
  • Java (but note that Java is compiled to bytecode, which is then interpreted and/or recompiled at runtime)
  • Pascal

...and then you have things like Python that sit in both camps: Python is widely used without a compilation step, but the main implementation (CPython) does that by compiling to bytecode on-the-fly and then running the bytecode in a VM, and it can write that bytecode out to files (.pyc, .pyo) for use without recompiling.

That's just a very few, if you do some research you can find a lot more.

Ppi answered 22/6, 2013 at 17:43 Comment(18)
So you are basically saying that a scripting language is something you need an interpreter and not a compiler for?Jut
@mg30rg: I'm saying compiled or interpreted ("scripting") is more a matter of environment than it is language.Ppi
@T.J.Crowder Just to be clear, I'm not trying to argue here. I'm in desperate need of an answer to the original question, to settle a debate. I can tell scripting from coding because I feel which one I'm doing, but that is not a valid argument, also it does not work in all cases. i.e. I clearly feel that I'm scripting when I'm writing a batch file, an install script or a powershell script, but I'm not really sure when I'm creating an ASP or PHP based server. Also lots of JavaScript "magic" feels like real programming. (Its something I usually see others doing.)Jut
@mg30rg: Heh -- scripting can totally be "real" programming. (You wouldn't believe some of the bash scripts I've seen...) I think the simplest way to define it (and again, this isn't a language thing, it's an environment thing) is: Does the runtime environment see the source code? If so, I'd call that "scripting;" if not, I wouldn't. So in that sense, browser-based JavaScript is "scripting" because even if engines like V8 compile it on-the-fly, the source is still delivered to the runtime environment. Similarly shells scripts. A traditional C program's source isn't delivered to the runtime.Ppi
@mg30rg: But again, these lines are getting blurrier all the time. :-) Consider Java bytecode. You can't run it without a JVM, but it isn't source code. (It can usually be turned back into reasonable-looking source code by a decompiler, but...) I don't (remotely) think of Java in a traditional environment as a scripting language. But then, I also don't spend a lot of time thinking about the categories, either. :-)Ppi
Isn't python compiled to C?Psychoactive
@CME64: No, the main implementation (CPython) compiles to bytecode on the fly and runs the bytecode in a VM. While there are Python-to-C tools (Cython and Pyrex), that's not usually how Python is run.Ppi
VBA has an explicit compilation step. It compiles automatically on runtime to pcode. It should not be in the list with VBScript.Haematogenesis
@Vityata: Please read the answer closely. There is no explicitly compilation step with VBA (and it used to not be compiled at all).Ppi
@T.J.Crowder - times are changing, but runtime compilation is compilation. At least remove VBA from the list, it is confusing lots of people.Haematogenesis
@Vityata: Citation? (For the "lots of people"). Frankly, I very much doubt it. Re "runtime compilation is compilation" -- again, read the answer. "e.g., languages that are traditionally used without an explicit compilation step " More: dictionary.com/browse/explicitPpi
@T.J.Crowder - if I did not know that VBA compiles to Pcode, I would have thought that it is a scripting language like VBScript.Haematogenesis
@Vityata: And you're one person. Who apparently didn't -- with all due respect -- even really read the answer. (What makes you think VBScript isn't compiled to some kind of pcode on the fly as well? In fact, I believe it was, even back on IIS6.)Ppi
@T.J.Crowder - if a language uses natural Compiler Directives it means it compiles. And it compiles explicitly, on runtime. Thus, VBA compiles and is not a scripting language.Haematogenesis
@Vityata: No, that's not what explicit means. I'm done here.Ppi
To @Vityata's defense, VBScript is written in Notepad and interpreted as text input, whereas VBA code is compiled to P-Code as you type it in the editor, i.e. the source code you see in the editor after you modified a line of code, is not the code you typed, but the VBE's rendition of the underlying P-Code: the mechanics of VBA vs VBScript are completely and utterly different, and lumping them together in that list just doesn't feel right at all. VBA is much closer to VB6 than it is to VBScript; it's only an explicit restriction that prevents it from building a standalone executable.Crossarm
So what you are actually saying as well, in your first sentence, is that scripting languages are programming languages as well but a programming isn't necessarily a scripting language?Stephens
@ErikvandeVen - In some sense, all programming languages can be scripting languages, because it's possible in the general case to envision an environment in which no explicit compilation step is required. In their usual, traditional environments, though, all (Turing-complete) scripting languages are programming languages, but not all programming languages are scripting languages (again: traditionally). The usual environments for C require explicit compilation, for instance, so in that sense it wouldn't be a "scripting language" (though, again, there are niche environments where it is).Ppi
T
113

To understand the difference between a scripting language and a programming language, one has to understand why scripting languages were born.

Initially, there were programming languages that was written to build programs like excel, word, browsers, games and etc. These programs were built with languages like c and java. Overtime, these programs needed a way for users to create new functionality, so they had to provide an interface to their bytecode and hence scripting languages were born.

A scripting language usually isnt compiled so can run as soon as you write something meaningful. Hence excel may be built using C++ but it exposes a scripting language called VBA for users to define functionality. Similarly browsers may be built with C++/Java but they expose a scripting language called javascript (not related to java in any way). Games, are usually built with C++ but expose a language called Lua for users to define custom functionality.

A scripting language usually sits behind some programming language. Scripting languages usually have less access to the computers native abilities since they run on a subset of the original programming language. An example here is that Javascript will not be able to access your file system. Scripting languages are usually slower than programming languages.

Although scripting languages may have less access and are slower, they can be very powerful tools. One factor attributing to a scripting languages success is the ease of updating. Do you remember the days of java applets on the web, this is an example of running a programming language (java) vs running a scripting language (javascript). At the time, computers were not as powerful and javascript wasn't as mature so Java applets dominated the scenes. But Java applets were annoying, they required the user to sort of load and compile the language. Fast forward to today, Java applets are almost extinct and Javascript dominates the scene. Javascript is extremely fast to load since most of the browser components have been installed already.

Lastly, scripting languages are also considered programming languages (although some people refuse to accept this) - the term we should be using here is scripting languages vs compiled languages.

Tenuous answered 10/9, 2015 at 2:56 Comment(3)
Don't you think you meant : "interpreted languages vs compiled languages" instead of "scripting languages vs compiled languages" ??Guesswork
" An example here is that Javascript will not be able to access your file system", Nodejs say hiHoover
@Hoover NodeJS is a runtime that allow coders to use Javascript as a "language" for coding. NodeJS isn't 100% Javascript.Dignify
A
68

All scripting languages are programming languages.

Languages are not classed as script or not - it entirely depends on the execution environment.

If the environment is one that is interpreted, this is commonly referred to as a scripting environment.

Axes answered 22/6, 2013 at 17:43 Comment(0)
P
20

The differences are becoming fewer and less important. Traditionally, scripting languages extend existing programs... I think that's the main definition of "scripting" is that it refers to writing a set of instructions for an existing entity to perform. However, where scripting languages started with proprietary and colloquial syntax, most of the prevalent ones these days owe some relationship to C.

I think the "interpreted vs compiled" distinction is really a symptom of extending an existing program (with a built in interpreter), rather than an intrinsic difference. What programmers and laymen are more concerned about is, "what is the programmer doing?" The fact that one program is interpreted and another is compiled means very little in determining the difference in activity by the creator. You don't judge a playwright on whether his plays are more commonly read aloud or performed on stage, do you?

Payroll answered 18/12, 2014 at 1:9 Comment(0)
C
12

Programming Language : Is compiled to machine code and run on the hardware of the underlying Operating System.

Scripting Language : Is unstructure subset of programming language. It is generally interpreted. it basically "scripts" other things to do stuff. The primary focus isn't primarily building your own apps but getting an existing app to act the way you want, e.g. JavaScript for browsers, TCL etc.,

*** But there are situation where a programming language is converted to interpreter and vice-verse like use have a C interpreter where you can 'C' Script. Scripts are generally written to control an application behaviour where as Programming Language is use to build applications. But beware that the demarcation is blurring day - by - day as an example of Python it depends on how one uses the language.

Cresset answered 10/10, 2014 at 5:19 Comment(0)
C
10

Scripting languages are a subset of programming languages.

  1. Scripting languages are not compiled to machine code by the user (python, perl, shell, etc.). Rather, another program (called the interpreter, runs the program and simulates its behavior)
  2. Some programming languages that are not scripting (C, C++, Haskell, and other 'compiled' languages), are compiled to machine code, and is subsequently run.
Cp answered 22/6, 2013 at 17:46 Comment(0)
D
6

I think that what you are stating as the "difference" is actually a consequence of the real difference.

The actual difference is the target of the code written. Who is going to run this code.

A scripting language is used to write code that is going to target a software system. It's going to automate operations on that software system. The script is going to be a sequence of instructions to the target software system.

A programming language targets the computing system, which can be a real or virtual machine. The instructions are executed by the machine.

Of course, a real machine understands only binary code so you need to compile the code of a programming language. But this is a consequence of targeting a machine instead of a program.

In the other hand, the target software system of an script may compile the code or interpret it. Is up to the software system.

If we say that the real difference is whether it is compiled or not, then we have a problem because when Javascript runs in V8 is compiled and when it runs in Rhino is not.

It gets more confusing since scripting languages have evolved to become very powerful. So they are not limited to create small scripts to automate operations on another software system, you can create any rich applications with them.

Python code targets an interpreter so we can say that it "scripts" operations on that interpreter. But when you write Python code you don't see it as scripting an interpreter, you see it as creating an application. The interpreter is just there to code at a higher level among other things. So for me Python is more a programming language than an scripting language.

Darvon answered 7/8, 2015 at 19:59 Comment(0)
U
6

Back when the world was young and in the PC world you chose from .exe or .bat, the delineation was simple. Unix systems have always had shell scripts (/bin/sh, /bin/csh, /bin/ksh, etc) and Compiled languages (C/C++/Fortran).

To differentiate roles and responsibilities, the compiled languages (often referred to as 3rd Generation Languages) were seen a 'programming' languages and 'scripting' languages were seen as those that invoked an interpreter (often referred to as 4th Generation Languages). Scripting languages were often used as 'glue' to connect between multiple commands/compiled programs so that the user didn't have to worry about a set of steps in order to carry out their task - they developed a single file, that delineated what steps they wanted to accomplish, and this became a 'script' for anyone to follow.

Various people/groups wrote new interpreters to solve a specific problem domain. awk is one of the better-known ones, and it was used mostly for pattern matching and applying a series of data transforms on input. It worked well, but had a limited problem domain. The expansion of that domain was all but impossible because the source code was unavailable. Perl (Larry Wall, principle author/architect) tool scripting to the next level - and developed an interpreter that not only allowed the user to run system commands, manipulate input and output data, supported typeless variables, but also to access Unix system level APIs as functions from within the scripts themselves. It was probably one of the first widely used high-level scripting languages. It is with Perl (IMHO) that scripting languages crossed the arbitrary line and added the capabilities of programming languages.

Your question was specifically about Python. Because the python interpreter runs against a text file containing the python code, and that the python code can run anywhere that there is a python interpreter, I would say that it is a scripting language (in the same vein as Perl). You do not need to recompile the user python command file for each different OS/CPU Architecture (as you would with C/C++/Fortran), making it significantly more portable and easier to use.

Credit for this answer goes to Jerrold (Jerry) Heyman. Original thread: https://www.researchgate.net/post/Is_Python_a_Programming_language_or_Scripting_Language

Uncleanly answered 12/3, 2018 at 7:42 Comment(0)
D
5

Scripted languages

Scripting languages are interpreted within another program. JavaScript is embedded within a browser and interpreted by that browser.

Examples of scripting languages

  1. JavaScript
  2. Perl
  3. Python

Advantages of Scripting languages:

  1. Simple – Scripting languages are easier to write than programming language.

  2. Fewer Lines of Code (LOC)

Programmed languages

Programming languages like Java are compiled and not interpreted by another application in the same way.

Examples programming languages

  1. C
  2. C++ and
  3. Java

More Details

Drip answered 18/6, 2015 at 10:40 Comment(1)
Scripted languages are programming languages. Also, Java is interpreted by another application called the JVM.Framing
B
5

I'm in a discord with the fact that languages using interpreters are scripting languages and the one gets compiled are programming languages. We can develop an interpreter or compiler for any language. Interpreted environment suits web scripting better and makes it easier that's why we have it.

Well, I feel like there isn't any difference between scripting language and programming language. It's all about getting the job done. When it comes to web related tasks we call them Web scripts considering small task and that way we may also call the system related tasks as system or OS level scripts and the programming language we use to accomplish those tasks as system scripting languages.

Also it's not so that one cannot write system level code in Python and Web scripts in C language (definitely one can do if we can establish the required platform and environment). But all it takes is too much of effort which may affect the time constraint for the rapid development and the small bit of latency reduced is not going to benefit us much in web scripts. But the wise versa is not true if we perform system level tasks in Python.

Bottom line: language selection depends upon the nature of the task to be performed and discriminating a language as scripting language is a myth.

Backsheesh answered 19/6, 2016 at 21:38 Comment(0)
W
4

Apart from the difference that Scripting language is Interpreted and Programming language is Compiled, there is another difference as below, which I guess has been missed..

A scripting language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. In such systems, useful functionality is already available through a user interface, and the scripting language is a mechanism for exposing that functionality to program control.

Whereas a Programming Language generally is used to code the system from Scratch.

src ECMA

Wheels answered 14/7, 2015 at 12:40 Comment(0)
N
4

In Scripting languages like (JavaScript and old PHP versions) we use existing fundamental functions and method for performing our job. Lets take an example in JavaScript we can use ajax or web-sockets only if they are supported by browser or methods exist or them in browser. But in languages like C or C++ , Java we can write that feature from scratch even if any library for that feature is not available but we can't do so in JavaScript.

can you support web-sockets in Internet Explorer 8 or prior with the help of JavaScript But you can write a plugin in C or C++ or Java which may add a feature of web-socket to Internet Explorer 8.

Basically in Scripting languages we write a code in a sequence which execute existing methods in a sequence to complete our job. Entering numbers and formula in a digital calculator to do a operation is also a very example of scripting language.We should note that the compiler/run-time-environment of every scripting language is always written in programming language in which we can add more features and methods and can write new libraries.

PHP This is language which is somewhat b/w programming and scripting. We can add new methods by adding compiled extensions written in another High Level Language. We can't add high level features of networking or creating image processing libraries directly in PHP.

P.S. I am really sorry for revolving my answer around PHP JavaScript only but I use these two because I have a considerable experience in these two.

Necktie answered 4/4, 2016 at 5:25 Comment(0)
I
4

Scripting languages are programming languages that people consider as scripting languages. It's an artificial category with no clear boundary, and where every proposed rule has an exception.

The classical rules used to say that a language is a scripting language are characterizing, not defining. If a language satisfies a number of the rules, there is a good chance it's considered a scripting language. If not, there's a good chance it's not. The rules usually include:

  • It's intended for small "scripts", not large programs.
  • It's embedded in another application, used for small modifications of that application.
  • It's interpreted rather than compiled.
  • It's intended for novice programmers, not professionals.
  • It's name ends in "script".

I would add:

  • A scripting language is a programming language where almost all errors are detected at runtime.

That is, it could be an interpreted language.

If a programming language has significant "compile-time" behavior where it analyses the code and reports errors without running the program, like type errors from C, Java or C#, then it's most likely not considered a scripting language.

Traditionally a lot of scripting languages have been interpreted directly from source, but the more popular of them have gotten more performant implementations that precompile the code, like Python's .pyc files, or optimizing JavaScript engines that compile to native code before running.

If the language could be implemented by an interpreter, which only looks at the source code as it is running it, then it's likely considered a scripting language. Whether it actually is implemented that way is not important, but if it can be, then it also can't require extensive compile-time error checking of the code.

If the language provides a useful static semantics which helps detect errors (other than syntax errors) without needing to run the program, it's probably not a scripting language.

There are always exceptions, usually based on tradition around a language more than any actual rule. BASIC is not usually considered a "scripting language", even though it satisfies pretty much all the criteria that anyone has ever used for being one. That's why Visual Basic Script had to add the "script" to the name, to distinguish itself from Visual Basic, a "real" programming language intended for larger programs.

BASIC is also an old programming language, like COBOL and Fortran, from before people expected static analysis from a language, and basically before "scripting languages" were even a thing.

Infelicitous answered 20/3, 2019 at 7:17 Comment(0)
M
2

If we see logically programming language and scripting language so this is 99.09% same . because we use same concept like loop , control condition ,variable and all so we can say yes both are same but there is only one thing is different between them that is in C/C++ and other programming language we compile the code before execution . but in the PHP , JavaScript and other scripting language we don't need to compile we directly execute in the browser.

Thanks Nitish K. Jha

Mailer answered 10/3, 2016 at 4:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.