Programming Language
Programming Language
low-level language
A **low-level language** is a type of programming
language that is closer to the computer’s hardware and
farther from human language. It provides little or no
abstraction from a computer's machine code, meaning
the programmer has more direct control over how the
computer’s hardware operates.
Low-level languages are fast and efficient because they
interact directly with the computer's central processing
unit (CPU). However, they are more difficult for humans to
read, write, and understand compared to high-level
languages.
### Types of Low-Level Languages:
1. **Machine Language** (Machine Code):
- This is the lowest level of programming language,
consisting entirely of binary code (0s and 1s) that the
computer's CPU directly understands.
- **Example**: A sequence like `10101011 00001100`
tells the computer to perform very specific operations.
- **Advantages**: Very fast execution, since it directly
interacts with the hardware.
- **Disadvantages**: Extremely difficult for humans
to write and understand.
2. **Assembly Language**:
- Assembly language is one step above machine
language and uses human-readable mnemonics
(shortened text) to represent machine-level instructions.
Each assembly instruction corresponds directly to a
machine language instruction.
- **Example**: Instead of binary, you might write
`MOV A, 5` to move the value 5 into a register (A).
- **Advantages**: Easier to understand than machine
language, but still gives the programmer control over the
hardware.
- **Disadvantages**: Harder to learn and use
compared to high-level languages, and it's specific to a
particular CPU architecture.
high-level language
A **high-level language** is a type of programming
language that is designed to be easy for humans to read
and write. It is closer to human languages and far away
from the computer's machine code (binary). High-level
languages are more abstract, meaning they hide the
complex details of how the computer works, letting you
focus on what you want to do, rather than how the
computer will do it.
### Key Features of High-Level Languages:
- **Easy to read and write**: The code looks more like
English or math, making it easier to understand.
- **Portable**: You can run the same code on different
types of computers without needing to change it.
- **Automatic memory management**: You don’t
have to worry about managing the computer’s memory
(unlike in low-level languages).
### Types of High-Level Languages:
1. **Procedural Languages**:
- These languages follow a step-by-step approach,
where you write a series of instructions that tell the
computer exactly what to do.
- **Example**: **C, Pascal**
- **How to think about it**: It’s like giving the
computer a recipe—first do this, then do that, and so on.
2. **Object-Oriented Languages**:
- These languages organize the program around
**objects** (which represent real-world things) and their
interactions. You can create objects, give them properties
(like a car with speed and color), and make them interact
with each other.
- **Example**: **Java, Python, C++**
- **How to think about it**: It’s like playing with
Lego blocks—you build objects, give them functions, and
let them interact.
3. **Scripting Languages**:
- These are often used for automating tasks or
controlling other software. They’re generally interpreted
(not compiled) and run in a simpler, faster way.
- **Example**: **JavaScript, Python, Ruby**
- **How to think about it**: It’s like writing quick
instructions to automate a simple task, like opening a file
or updating a webpage.
4. **Functional Languages**:
- Instead of giving step-by-step instructions, you define
**functions** and use them to transform data. These
languages focus more on **what** to do, rather than
**how** to do it.
- **Example**: **Haskell, Lisp**
- **How to think about it**: It’s like telling the
computer, "Here’s some data, apply this function, and
give me the result," without worrying about the steps.
### Summary:
- **High-level language**: Easier for humans to use
and understand, focusing more on **what** you want to
achieve than on the inner workings of the computer.
- **Types**:
- **Procedural** (step-by-step instructions),
- **Object-Oriented** (working with objects),
- **Scripting** (quick scripts for tasks),
- **Functional** (transforming data with functions).