Compilers and Interpreters
When programming, we use compilers or interpreters to convert our code into machine language that a computer can understand.
Compiler
A compiler is a software tool that translates source code written in a programming language into machine code. This process is called “compiling.” The output is usually an executable file that can be run on a specific processor architecture.
Process: Source Program –> Compiler –> Target Program (Machine Language)
Common programming languages that utilize compilers include:
- Fortran
- C
- C++
- C#
- Pascal
- Go
- Rust
- Delphi
- PIC BASIC Pro
Interpreter
An interpreter processes the source code line by line and executes it directly. Unlike compilers, interpreters do not generate standard executable code. The program stops running when it encounters the first error, as the interpretation is done step by step.
Process:
Source Program –> Interpreter –> Target Program (Machine Language)
Languages that use interpreters include:
- Python
- Ruby
- Java
- LISP
- BASIC
- AWK
- PHP
Summary:
- A compiler checks the entire program for errors before execution.
- An interpreter processes the code line by line, stopping at the first error.
2.5 Source Code
A source code is the version of a program written in a programming language that is human-readable and has not yet been converted into machine language.
File Extensions:
- If written in C:
.C
- If written in Assembly:
.ASM
- If written in Java:
.JAVA
- If written in Python:
.PY
A source code editor is a specially designed text editor for writing and modifying source code. It can be an independent application or integrated into an IDE or web browser.
Python Editors:
- IDLE
- Jupyter
- PyCharm
- Spyder
- VSCode
Executable Files
An executable file is created by compiling a source program written in a programming language into machine language. These files are ready to run on the computer. In Windows and MS-DOS systems, the file extension for executable files is .EXE
.
To convert Python files with a .PY
extension into .EXE
, you can use tools like PyInstaller or py2exe.
Python Language
Python is:
- Object-oriented
- Interpreted
- A high-level programming language that is easy to learn due to its simple syntax.
Key Features:
- Simple and readable syntax
- Facilitates learning and retention
Creator: Guido van Rossum, a Dutch programmer, created the Python programming language.
Applications of Python:
- Web Development
- Game Design
- Robotics Applications
- Data Analysis
- Machine Learning Applications
- Artificial Intelligence Applications
- Browser Automation
- Enhancing Program Functionality
- Performing Calculations
- Creating Lottery Applications
- Building Dictionaries
- Developing Social Media Applications
Python Installation
IDLE (Integrated Development and Learning Environment) is included with every Python installation. It is designed to assist in more efficient coding. Among the various IDEs available, IDLE is particularly user-friendly for beginners.
For more information on Python and to download the latest version, visit python.org.