Program vs Script: Understanding the Differences and Purposes

  • Thread starter jd12345
  • Start date
  • Tags
    Program
In summary, scripting languages are distinct from the core code of an application and are often interpreted from source code or bytecode, while programs are compiled to native machine code. The term "script" is more commonly used for simpler, user-modifiable programs, while more complex programs are typically referred to as "programs". However, there is some overlap in terminology and the distinction between scripting languages and interpretive languages can be blurred. Ultimately, the terms used depend on the preferences of the programmers and the type of language being used.
  • #1
jd12345
256
2
I am having this doubt for a long time and want to clear once and for all.
Here are the questions: -
1) What is the difference between program and script? (I believe program is run on a machine while script is run on another software but still I want your answers in case I am wrong)
2) Why are scripts lightweight and not that strict compared to compiled programs?
3) Why are scripts interpretive but programs compiled?
 
Physics news on Phys.org
  • #2
jd12345 said:
I am having this doubt for a long time and want to clear once and for all.
Here are the questions: -
1) What is the difference between program and script? (I believe program is run on a machine while script is run on another software but still I want your answers in case I am wrong)
2) Why are scripts lightweight and not that strict compared to compiled programs?
3) Why are scripts interpretive but programs compiled?

Your answer to #1 is not quite right, IMO. Can you try again? And what are your answers to the rest of the questions? Have you tried looking up definitions for these terms?
 
  • #3
berkeman said:
Your answer to #1 is not quite right, IMO. Can you try again? And what are your answers to the rest of the questions? Have you tried looking up definitions for these terms?

Here are the wikipedia answers: -
Script:
"Scripts" are distinct from the core code of the application, which is 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.

Program:
The program has an executable form that the computer can use directly to execute the instructions.
The same program in its human-readable source code form, from which executable programs are derived (e.g., compiled)

So scripts are interpreted while programs are compiled. Since these are the definitions there is no point asking why this is so.

So the question remaining is: Why are scripts lightweight and not so strict?
I find no reason why they can't be.

Another question which comes: Are all interpretive languages scripts?
From the definition I suppose yes.
 
  • #4
A scripting language is just a programming language like any other. A program written in a scripting language, however, may not compile down to an executable file--which means, to run it, you'll need the source code. From the point of view of the programmer herself, it makes little difference (except, possibly, for performance).
 
  • #5
jd12345 said:
So scripts are interpreted while programs are compiled.

Not always true. The original BASIC language was the earliest wide-spread interpretive language and programs written in it were never called "scripts", they were called "programs" and were thought of as such. The fact that they were interpreted at run-time was irrelevant.

Similarly, APL, an early interpreted language was the same in that programs written in APL were never thought of or described as "scripts" but as "programs".

On the other hand, complex programs written in JavaScript are not likely to be thought of or described as "scripts" but as "programs" even though they are written in a scripting language.
 
  • #6
jd12345 said:
So the question remaining is: Why are scripts lightweight and not so strict? I find no reason why they can't be.
I'm wondering what you might mean by 'strict'? Is this perhaps your translation from another language?

Another question which comes: Are all interpretive languages scripts?
From the definition I suppose yes.
There is a grey area where either term could apply, IMHO, and the designers seem to have settled on one term or the other in their early published documentation, and then it sticks.
 
  • #7
Technically speaking, the fact that you had source code (and not an executable file), when moving a function from one user or machine to another, was probably the first reason people started calling them scripts rather than programs.

Often that was because they were interpreted, but that is no longer the case in all situations.
 
  • #9
jd12345 said:
Are all interpretive languages scripts?

Actually, you are confusing terminology here. A "script" is a program not a language. The right form would be "are all scripting languages interpretive" and I think the answer to that is yes although as has been mentioned, interpretive languages may have compilers.
 
  • #10
If you read the wiki article, scripting is more like what dos or windows call batch files and linux / posix / unix calls shell scripts, placing commands normally entered one at a time by the user into a text file. Usually there are additional features such as looping, conditionals, "calling" or "spawning" of other scripts. There are also more general purpose scripting languages, and I don't know where the line is drawn between a scripting language and an interpretive language.

I would consider APL and Basic to be interpretive languages, not scripting languages. Even though APL and Basic can be used interactively like a calculator, they also include the ability to define functions.
 
  • #11
rcgldr said:
I would consider APL and Basic to be interpretive languages, not scripting languages. Even though APL and Basic can be used interactively like a calculator, they also include the ability to define functions.

JavaScript is by definition a scripting language but can easily be used to write complex programs, including functions. As I said earlier, I don't think any such programs would be called scripts, but a very small JavaScript program might be.
 

FAQ: Program vs Script: Understanding the Differences and Purposes

What is the difference between a program and a script?

A program is a set of instructions that can be executed by a computer to perform a specific task or set of tasks. It is typically written in a high-level programming language and compiled into machine code. On the other hand, a script is a series of commands or instructions written in a scripting language that can be executed directly by an interpreter without the need for compilation. Scripts are often used for smaller, specific tasks.

What are the main purposes of a program?

The main purpose of a program is to perform a specific task or set of tasks in a systematic and efficient manner. Programs are commonly used for complex and large-scale operations, such as developing software applications, managing databases, or creating operating systems. They are also used for automating repetitive tasks and performing calculations or data processing.

What are the main purposes of a script?

The main purposes of a script are to automate small tasks, manipulate data, and perform simple operations. Scripts are commonly used for tasks that do not require a full-blown program, such as web development, system administration, and data analysis. They can also be used to enhance the functionality of a program or to add new features.

Why are programs typically compiled while scripts are interpreted?

Programs are compiled because the source code needs to be translated into machine code, which is the only language that a computer can directly understand and execute. This allows for faster and more efficient execution of the program. On the other hand, scripts are interpreted because their source code does not need to be converted into machine code. Instead, an interpreter reads and executes the code line by line, making it easier to identify and fix errors.

Can a script be converted into a program and vice versa?

Yes, a script can be converted into a program by adding additional code and compiling it into machine code. However, this may not always be necessary or feasible, as scripts and programs serve different purposes and have different development processes. Additionally, a program can be converted into a script by removing unnecessary code and making it more concise. This can be useful for simplifying the program or for creating a script that can be easily shared and executed on different platforms.

Back
Top