There are quite a couple of occasions where my students have asked me the difference between programming and scripting (or programs and scripts). I thought the time has finally come for me to write an article on it and close the case!
The term programming refers to the solving of a problem by writing down steps that can be executed by a computer. A program, therefore, is a series of instructions to perform a particular task. There are a variety of styles of programming, and a variety of techniques for execution of programs. Scripting happens to be one of the approaches to programming, and is therefore a subset of programming. All scripts are programs, but all programs need not be scripts!
A script is usually a quick, small piece of code written for use by a special interpreter that can understand the script and either translate it to some other code, or execute it immediately. The primary goal behind the invention of a scripting language is usually providing a limited scope of operations, tailor-made to a specific type of situation. For example, if you are building a massive game, the core part of it would be mostly written in a non-scripting programming language, while most of the in-game programming part can be written as scripts that are executed by an interpreter. The advantage of scripts here would be that their syntax could be tailor-made to the requirements of the game, making scripts small, powerful and convenient to write.
Due to this historic distinction, it is normally expected that scripts are interpreted whereas programs are usually compiled and executed. This distinction is no longer true today. We have scripting languages that support compilation, and we always had programming languages that were interpreted though they were not scripting languages per se.
A scripting language is also known for keeping things simple – usually by hiding as much implementation details as possible (for example, you can just say that “x” is a variable without even specifying it’s type), and by keeping things flexible (for example, you could assign one variable to another without bothering about any type conversion). (Non-scripting) programming languages, on the other hand, are usually expected to provide fine grain control on how things should be within the program, forcing the programmer to think of elements that are not very strongly connected with the problem (like whether a variable should be an integer or a real number, and of what size).
In conclusion, the distinction between whether a piece of code is a script (and also a program) or just a program has become more blurry with time, but some general differences can be observed in the table below:
Script | Program |
---|---|
Is generally small and simple | Comes in all sizes! Not surprising to find huge programs |
Is usually tailor-made for a specific class of applications, though general-purpose scripting languages exist | Is usually developed for general-purpose programming, though special-purpose programming languages exist |
Focuses on simplicity | Focuses on programming control |
Tries to provide a custom environment within which scripts can run | Tries to provide a blank slate on which the programmer can do anything |
Usually interpreted; that’s where the flexibility comes from | Usually compiled; that’s where the power comes from |
Related Articles
No user responded in this post