Lesson Objective
- Understand and recognise the differences between high and low level programming languages.
- Explain how assemblers, compilers, assemblers work.
- Compare the diffierences of assemblers, compilers, assemblers.
KS3, GCSE, A-Level Computing Resources
Programming languages have evolved over time, and we can group them into four main categories based on how close they are to the computer's inner workings.
The first two generations, like machine code and assembly language, are like speaking directly to the machine in its own language, which is complex and hard for humans to understand.
The third and fourth generations, like C++ and Python, are more like natural languages, making them easier for people to write and understand. They act as an intermediary, translating our instructions into machine code the computer can execute.
Think of your computer as a machine that only speaks a specific language of ones and zeros (machine code). Low-level languages are like translators that let you communicate directly with the machine in its native tongue. Unlike "higher-level" languages like Python or Java, which are more human-friendly, low-level languages require you to understand the specific instructions, or commands, that the processor can understand. This gives you fine-grained control but also makes them more complex and less portable (they won't work on every computer). Essentially, low-level languages bridge the gap between your ideas and the machine's capabilities, but at the cost of being closer to the hardware and less intuitive for humans.
Machine code, also known as machine language, is the fundamental language of computers. It's a set of instructions written in binary (0s and 1s) that the processor (CPU) directly understands and executes. It's the lowest level of programming, meaning it's the closest you can get to speaking directly to the computer's hardware.
Here's a breakdown of its key features:
You should note ALL the other generations of programming languages will convert your program into this machine code.
Assembly code is a low-level programming language that acts as a bridge between human-readable code and the machine code understood by computers. Think of it like a translator allowing you to communicate directly with the computer's hardware, albeit in a way more intuitive than its native binary language.
Here are some key features of assembly code:
Example: Machine Code
00000000 00000001 00000001 00000000 00000001 00000001 00000001 00000001 00000000 00000000 00000000 00000001 00000001 00000000 00000000 00000001 00000001 00000001 00000000 00000000 00000001 00000001 00000001 00000001 00000001 00000001 00000000 00000001 00000000 00000001
Example: Assembly Code
LDR R1, 301 ;load contents of 301 into R1
LDR R2, 302 ;load contents of 302 into R2
ADD R1, R1, R2 ;add R2 to R1, store in R1
LDR R3, 303 ;load contents of 303 into R3
ADD R1, R1, R3 ;Add R3 to R1, store in R1
STR R1, 304 ;store result in 304
Extra Note: Many machine code and assembly instructions contain two parts:
Both opcode and operand values are ultimately represented in binary.
High level languages are not dependent upon the computer architecture and require a translator or compiler to convert them to machine code.
Writing directly in machine code is incredibly difficult and not feasible for larger programs. Assembly language, while a step up, still requires memorizing specific codes and instructions, making it complex and error-prone for intricate projects.
Enter third-generation languages! These languages, like English or French, use familiar words and structures, allowing you to focus on what you want your program to do instead of how it does it. You can group and organize your code into routines and subroutines, making it easier to understand and maintain.
Java, php, C, C+, C#, Pascal, Cobol, Visual Basic, etc are also examples of third generation programming languages.
Fourth-generation languages take a different approach than traditional "how-to" programming. Instead of meticulously telling the computer every step to take (procedural), these languages focus on "what needs to be done" (declarative). Think of it like giving instructions instead of writing the entire recipe!
This makes them especially useful for tasks like accessing databases, where you specify what information you need rather than the intricate steps to retrieve it.
And the best part? They're designed to be understood easily! With syntax mirroring everyday language and forgiving error handling, even people without extensive programming experience can feel comfortable using them.
Prolog, MySQL are also examples of forth generation programming languages.
Example: Java
String name = "Ahmed";
system.out.println(name);
int n1 = 4;
int n2 = 5;
system.out.println(n1 + n2);
Example: SQL
FROM Customers SELECT firstnames
WHERE age > 24
Computers can only run machine code. When you write a program in a second, third or fourth generation language then the program must be translated into machine language with either a Assembler or Compiler or Interpreter.
An assembler is a program that translates an assembly language program into machine code.
A compiler a the source code from a high level language and translates it into machine code. The resulting code will run much faster as it requires no translation at run time. Compilers turn high level code into one workable executable (exe) files.
An interpreter analyses and executes each line of code within a high level programming language. It does not look at any other part of the code except the line it is running. Execution is slower because the program is analysed line by line at runtime. The advantage is that the code runs immediately without having to wait for the code to be compiled. It is also clear to see which part of the code is being executed.