- It’s a program.
- You can write it and execute it right away.
- The computer will do the compiling and other tasks in the background.
What is a script ?
A program that allows you to “write source code → run it immediately.”
To be more specific:
A program that allows humans to convert the source code written in human language into a form that computers can understand (compile) without having to be aware of it.
Script refers to a type of program where you can write code and execute it immediately. In simple terms, a script is a “program that you can run right after you write it.”
1. Basic Concept of a Script
A script allows you to perform the process of “writing code → executing it immediately” without explicitly needing to compile it. Typically, when you run a program, you must first compile the source code into a format that the computer understands. However, with scripts, this compilation step is handled automatically in the background.
2. Program Execution Flow
The typical flow of getting a program to run involves:
- Programming – Writing the source code in a human-readable format.
- Compiling – Converting the source code into a format the computer can understand.
- Executing – Running the converted code on the computer.
For scripts, the “compiling” step is handled automatically by the computer, so you don’t need to worry about it. You can write your code and run it directly.
3. Features of Scripts
Scripts have the following features:
- Immediate Execution – You can run the code right after writing it.
- Automatic Compilation – The compilation process is managed by the computer behind the scenes, so you don’t need to handle it manually.
Examples of scripting languages include PHP, JavaScript, and Perl.
4. Example of a Script
Consider a simple PHP script:
print "Hello, World!";
When executed, this script displays “Hello, World!” on the screen. If you modify the script to:
print "Hello, Universe!";
And run it again, the screen will display “Hello, Universe!”
Here’s what happens in the background:
- You update and save the source code.
- The source code is automatically compiled into a format the computer understands.
- The compiled code is executed, showing “Hello, Universe!” on the screen.
The key point is that the script handles the compilation process automatically, so you only see the immediate result of your changes.
5. Summary
When you encounter the term “script,” think of it as a “program that you can write and execute immediately.” The computer takes care of the compilation process behind the scenes, allowing you to quickly see the results of your code changes.