96

What is the difference between a script and a program? Most of the time I hear that a script is running, is that not a program? I am bit puzzled, can anybody elaborate on this?

2
  • Both are synonyms
    – Jus12
    Commented May 8, 2021 at 10:18
  • My two cents (as a comment since question is closed): A program is a sequence of instructions that can be executed by some automated means -- including machine code, script, and bytecode. A script is a program written in a programming language that is interpreted by a native (machine code) application (program) and is generally written by a human. But some people consider a program to be compiled (machine code)
    – steve
    Commented Sep 15, 2022 at 14:03

11 Answers 11

54

I take a different view.

A "script" is code that acts upon some system in an external or independent manner and can be removed or disabled without disabling the system itself.

A "program" is code that constitutes a system. The program's code may be written in a modular manner, with good separation of concerns, but the code is fundamentally internal to, and a dependency of, the system itself.

Scripts are often interpreted, but not always. Programs are often compiled, but not always.

8
  • 3
    What is the system means?
    – explorer
    Commented Oct 8, 2018 at 10:38
  • @explorer - It's the system referred to in a first part of the paragraph. Commented Oct 8, 2018 at 13:28
  • 2
    :-) Okay! What is the system referred in the first part of the paragraph? Is it an application, operating system, an application with many integral/individual parts, or anything else?
    – explorer
    Commented Oct 9, 2018 at 6:36
  • Nevermind! I understood! I did not properly interpreted constitutes earlier.
    – explorer
    Commented Oct 9, 2018 at 6:38
  • 1
    This defines both script and program in terms of 'system'. Which begs the question: What is a system?
    – steve
    Commented Sep 15, 2022 at 13:51
54

For me, the main difference is that a script is interpreted, while a program is executed (i.e. the source is first compiled, and the result of that compilation is expected).


Wikipedia seems to agree with me on this :

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)

2
  • 3
    You say, "(i.e. the source is first compiled, and the result of that compilation is expected)." Do you mean "compilation is executed"? Commented Oct 3, 2015 at 22:55
  • It seems that the definition of 'program' is a matter of opinion. Some say program is compiled to machine code; clearly a script is not that. Some say program is more general; anything that is executable; a sequence of instructions; which then includes scripts. ... Shades of gray: is java/c# a program? Compiles to intermediate language that is not machine code, but is not script (or is it?) and at least sometimes is compiled to machine code at runtime (JIT). Personally, I like program to mean a sequence of instructions. But clearly there is no consensus on that.
    – steve
    Commented Sep 15, 2022 at 13:44
14

Typically, a script is a lightweight, quickly constructed, possibly single-use tool. It's usually interpreted, not compiled. Python and bash are examples of languages used to build scripts.

A program is constructed in a compiled language, like C or C++, and usually runs more quickly than a script for that reason. Larger tools are often written as "programs" rather than scripts - smaller tools are more easily developed as scripts, but scripts can get unwieldy as they get larger. Application and system languages (those used to build programs/applications) have tools to make that growth easier to manage.

You can usually view a script in a text editor to see what it does. You can't do that with an executable program - the latter's instructions have been compiled into bytecode or machine language that makes it very difficult for humans to understand, without specialized tools.

Note the number of "oftens" and "usuallys" above - the terms are nebulous, and cross over sometimes.

13

See:

The Difference Between a Program and a Script

A Script is also a program but without an opaque layer hiding the (source code) whereas a program is one having clothes, you can't see it's source code unless it is decompilable.

Scripts need other programs to execute them while programs don't need one.

3
  • 8
    This link now 404s. Commented May 28, 2014 at 4:56
  • 4
    This link now 200s. Commented Jul 19, 2018 at 12:52
  • 2
    "This link" offers a much better explanation than "this answer" does. The purpose of compiling code is not to "hide" or "dress" anything... I'm surprised this answer got so many votes (and is from such a high-rep user) since it serves little purpose besides making newb's stop asking a common question, by grossly oversimplifying, and circulating puerile misinformation.
    – ashleedawg
    Commented Feb 16, 2019 at 5:54
7

A "program" in general, is a sequence of instructions written so that a computer can perform certain task.

A "script" is code written in a scripting language. A scripting language is nothing but a type of programming language in which we can write code to control another software application.

In fact, programming languages are of two types:

a. Scripting Language

b. Compiled Language

Please read this: Scripting and Compiled Languages

4

Scripts are usually interpreted (by another executable).

A program is usually a standalone compiled executable in its own right (although it might have library dependencies), consisting of machine code or byte codes (for just-in-time compiled programs)

3

There are really two dimensions to the scripting vs program reality:

  1. Is the language powerful enough, particularly with string operations, to compete with a macro processor like the posix shell and particularly bash? If it isn't better than bash for running some function there isn't much point in using it.

  2. Is the language convenient and quickly started? Java, Scala, JRuby, Closure and Groovy are all powerful languages, but Java requires a lot of boilerplate and the JVM they all require just takes too long to start up.

OTOH, Perl, Python, and Ruby all start up quickly and have powerful string handling (and pretty much everything-else-handling) operations, so they tend to occupy the sometimes-disparaged-but-not-easily-encroached-upon "scripting" world. It turns out they do well at running entire traditional programs as well.

Left in limbo are languages like Javascript, which aren't used for scripting but potentially could be. Update: since this was written node.js was released on multiple platforms. In other news, the question was closed. "Oh well."

1

script: it contains set of "scripting language" instructions which controls, runs other system programs, applications also it can be scheduled.

Program: it contains set of instructions, which performs certain task upon compilation of the program with the compiler.

1

According to my perspective, the main difference between script and program:

Scripts can be used with the other technologies. Example: PHP scripts, Javascripts, etc. can be used within HTML.

Programs are stand-alone chunks of code that can never be embedded into the other technologies.

If I am wrong at any place please correct me.I will admire your correction.

2
  • What about python script? Also, the affirmation Php code can be used with Html is wrong. You only have php code. File extension is .php. Inside your program you can print html code. You can do the same with python, java, C#, C etc. All of them (if web program) produce html code.
    – DonJoe
    Commented Jan 23, 2019 at 17:34
  • What would be an example of program by this definition? Most people consider an exe to be a program, but it runs in an operating system. As it's embedded in that OS (a technology), it is therefore not a program?
    – steve
    Commented Sep 15, 2022 at 13:56
0

A framework or other similar schema will run/interpret a script to do a task. A program is compiled and run by a machine to do a task

0

IMO Script - is the kind of instruction that program supposed to run Program - is kind of instruction that hardware supposed to run

Though i guess .NET/JAVA byte codes are scripts by this definition

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