The Evolution of Code: From Binary Machine Language to Natural High-Level Tongues
As-salamu alaykum. How is everyone? I hope you're all doing well. Today we're going to discuss programming languages. But first, we need to understand what a programming language actually is. Well, we humans talk to each other. But how do we do that? Certainly, in their own language. In our own country, we speak our mother tongue, and internationally we use a specific language, namely English. Why do we do that? So that the other person can understand it and convert it into their mother tongue to remember it. In the same way, the robots, computers, and AI that we commonly use also have their own specific language. And it is this very language that helps them understand our commands. But what process do they use? I'm sure you have many questions running through your mind. So, let's get into the details.
The Concept of a Program:
Do you know who first introduced the concept of a programming language or program? It was Lady Ada Augusta, the daughter of the English poet Lord Byron. Now, let's get to the question: what exactly is this programming language? The words, letters, numbers, symbols, and the rules for their arrangement used to write programs are collectively called a programming language. And a program is an ordered set of commands or instructions in the language of a computer to solve a problem. And to write this program, various types of programming
languages are used. Well, did you know that these programming languages didn't appear overnight? They have been modified and modernized step-by-step through different generations. So, let's find out what those generations are.
Different Generations of Programming Languages:
The journey of programming languages began in 1945. Since then, hundreds of programming languages have been invented. These languages have been divided into five generations based on their features. They are:
1. First-generation language: Machine language, invented in 1945.
2. Second-generation language: Assembly language, invented in 1950.
3. Third-generation language: High-level language, invented in 1960.
4. Fourth-generation language: Very high-level language, invented in 1970.
5) Fifth-generation language: Natural language, discovered in 1980.
Again, based on the characteristics of program writing, programming languages are divided into two parts. Namely:
1. Low-level languages
2. High-level languages
You can understand this by looking at the image below.
[ Computer Programming Languages ]
│
┌──────────────┴──────────────┐
▼ ▼
[ Low-Level Languages ] [ High-Level Language ]
│ │
┌──────┴──────┐ ┌──────┼──────┐
▼ ▼ ▼ ▼ ▼
[ First [ Second [ Third [ Fourth [ Fifth
Generation ] Generation ] Generation] Generation] Generation]
Okay, so we've learned about the different generations and how the languages are divided. Now let's get to what their main purpose is. Let's dive into more detail.
Machine Language
First, let's talk about machine language. What exactly is machine language? Remember how I mentioned at the beginning that computers have their own language? That native language is called machine language or low-level language. Typically, machine language is written using two binary digits: ‘0’ and ‘1’. A computer can only understand machine language; if a program is written in another language, the computer first converts it into machine language with the help of a suitable translator. A program written in machine language is also called an object program. However, while machine language is easy for the computer, it is extremely tedious and time-consuming for humans. Can you guess why? It's simple: just as you would have to work very hard to learn the native language of another country. In the same way, learning a computer's native language is comparatively difficult and time-consuming for humans. You have surely heard of binary digits. Since a program must be written using only the two binary digits 0 and 1, creating a program in this language becomes impossible. So, you might ask, what is its advantage? So, let's take a quick look at its advantages and disadvantages below.
Advantages:-
Programs execute quickly.
Programs can be executed using less logic.
Programs can be executed using less memory.
Programs written in this language can be understood directly by the computer. Therefore, no translator is needed.
Now, let's look at the disadvantages.
Disadvantages:-
Writing programs in this language is extremely tedious and time-consuming. A program written for one type of machine cannot be used on another type of machine. Furthermore, a knowledge of computer organization is essential for program development. It also requires highly skilled programmers, which is not possible for everyone.
The instructions given in machine language are divided into 4 parts.
1. Arithmetic, i.e., addition, subtraction, multiplication, and division.
2. Control, i.e., load, store, and jump.
3. Input-Output, i.e., read and write.
4) Direct Use: This includes start, stop, and end instructions.
A machine language instruction is also divided into two parts. For example:
1. Opcode: The opcode tells the computer what type of operation to perform.
2) Operand: The operand is the data on which the opcode will operate.
You can understand this better with an example.
Example:
Suppose I want to add 43 and 10-2 using machine language. Then, here is what I would do:
Example of machine language addition (Table Line Analysis)
Location (Hex)
Instruction Code (Binary)
Instruction
Comments
100
0010 0001 0000 0100
LDA 104
Load first Operand into AC
101
0001 0001 0000 0101
Add 105
Add second Operand to AC
102
0011 0001 0000 0110
STA 106
Store sum in location 106
103
0111 0000 0000 0001
HLT
Halt Computer
104
0000 0000 0101 0011
Operand
83 decimal
105
1111 1111 1111 1110
Operand
-2 decimal
106
0000 0000 0000 0000
Operand
Store Sum Here
I hope you understood the topic.
Assembly Language
Now let's talk about the assembly language. The assembly language is the next level of programming language after machine language. This language is composed of various symbols. That's why it is also called a symbolic language. It is easier for programmers to write and read programs in this language than in machine language. Instructions are given in symbolic code in the assembly language. A program written in this language cannot be understood directly by the computer. Therefore, an assembler, a type of translator program, is used to convert a program written in assembly language into machine language. The various symbols used in assembly language are called mnemonics. For example: ADD, SUB, MUL, DIV, etc.
An assembly language instruction has four parts. They are:
1. Label Field
2. Opcode
3. Operand
4. Comment
Just as we saw a moment ago. You might be asking, what is the function of these? Well, let's take it one step further.
Label: This contains the symbolic address of the instruction. A jump instruction from another part of the program can be used to go to any label.
Opcode: This contains the mnemonic for the instruction. For example, the LDA instruction for loading and the DIV instruction for division.
Comment: Comments are not part of the program. They are placed next to each instruction for ease of understanding.
Now let's discuss the advantages and disadvantages of the assembly language.
Advantages:-
Programs written in this language are efficient and compact.
There is no need to specify memory addresses.
Fewer errors occur during program development.
Debugging is extremely easy.
Disadvantages:-
There are also some disadvantages to writing programs in assembly language:-
Programming in this language is extremely tedious and time-consuming.
Likewise, programs written for one type of machine cannot be used on another type of machine. Furthermore, an assembler program is required to execute the program. And the computer cannot understand this language directly.
So, let's look at an example of how assembly language is used.
Again, like before, we will perform the addition of 43 and -2 using assembly language -
ORG 100 / Origin of program is location 100
LDA A / Load Operand from location A
ADD B / Add Operation from location B
STA C / Store Sum in location C
HLT / Halt Computer
A, DEC 83 / Decimal operand
B, DEC -2 / Decimal operand
C, DEC 0 / Sum stored in location C
END
Medium-Level and High-Level Languages
Now let's talk about medium-level and high-level languages.
A programming language whose symbols and words are similar to mathematical and English language terms and are easily understandable to humans is called a high-level programming language. And the language that is intermediate between Assembly Language and high-level languages is called a mid-level or intermediate language. A mid-level language acts as a bridge between hardware and programming. It is a type of programming language that can be executed on any type of computer. These languages emerged around the 1960s. Mid-level languages were used because low-level languages were difficult for programmers to understand. The advantages of a mid-level language are:
1. Programs written in this language are easy for programmers to understand.
2. It can be executed on any type of computer.
3. A program written once can be modified later.
4. The likelihood of errors is low.
5. Errors can be corrected.
On the other hand, high-level languages can be written, understood, and remembered by people quickly. They are similar to the English language. It is not necessary to know the internal organization of the computer to write programs in these languages. For example: C++, BASIC, PASCAL, FORTRAN, etc.
Let's look at some of the advantages of these high-level languages.
Advantages:-
Programs written in high-level languages can be used on any computer.
These languages are easy to learn, and programs can be written quickly.
The likelihood of errors is low, and they are easy to correct.
Library functions are available.
You don't have to think about the hardware when writing programs.
Along with the advantages, this language also has some disadvantages.
Disadvantages:-
Disadvantages:-
1. You need to know the syntax of the structure and commands before writing the program.
2. A translator is needed for conversion to machine language.
3. Requires more memory compared to low-level languages.
4. Less flexible compared to low-level languages.
This high-level language is used for many tasks, including creating application packages and other software. Below are two examples of high-level languages:-
┌──────────────────────────────────────┐
│ Section .text │ <── [ Assembly Language Code ]
│ global _start │
│ │
│ _start: │
│ mov edx, len │
│ mov ecx, msg │
│ mov ebx, 1 │
│ mov eax, 4 │
│ int 0x80 │
└──────────────────────────────────────┘
┌──────────────────────────────────────────────┐
│ #include <stdio.h> │ <── [ C Programming Code ]
│ int main() │
│ { │
│ char ch; │
│ printf("Enter a letter "); │
│ ch = getchar(); │
│ printf("\nYou entered the letter: %c", ch);│
│ return 0; │
│ } │
└──────────────────────────────────────────────┘
I hope you have understood the topic.
So far, we have learned about the intricacies of various low-level languages. Now, let's look at some popular high-level ones.
C
In 1972, Dennis Ritchie invented the C language at Bell Laboratories in the United States. Today, C is known as a very powerful and popular high-level language. The C language can be used to create everything from operating systems and various application programs to complex database management programs, internet browsers, or even the Windows interface. It is a language that allows you to coordinate numerous small parts to create a complex program. Knowing C makes it easier to learn any other language. C combines the programming techniques of both assembly and high-level languages. This means you can work with bits, bytes, and memory addresses in this language. At the same time, you can also work with data types like in high-level languages, which is why it is known as a middle-level language. C is more suitable for creating software that works with limited space and resources.
C++
C++ is a widely used object-oriented programming language. It was invented in 1980 by Bjarne Stroustrup at AT&T Bell Laboratories in the United States. Initially, its name was ‘C with Classes’. Later, after adding more new features, it was named C++ in 1983. C++ has all the features of C, plus additional features and benefits. For this reason, C++ is called an extended version or a superset of C. C++ has made unique contributions to compiler and interpreter development, database handling, communication system design, distributed system design, real-time system design, and Windows-based applications. Moreover, graphical window management programming for systems like Windows and BitTorrent has been developed using C++. C++ is a legend in the world of object-oriented programming and was the inspiration for the creation of Java. Mozilla Firefox, Chromium for Open and Linux, and the vast majority of it are written in C++.
Visual Basic
Visual Basic is unparalleled for rapid and easy program development. This language is especially popular with new or amateur programmers. It was developed by Microsoft based on the BASIC language and an integrated development environment (IDE) was released to the market in 1991 under the name Visual Basic. Visual Basic was popular with many due to its drag-and-drop ActiveX controls and its ability to create direct executables and Dynamic Link Libraries (DLLs). Visual Basic provides easy and rapid development. VB.NET, built using many of VB's ideas, is Microsoft's framework that offers various APIs for creating object-oriented and web applications, and many parts of Windows are now built with VB.NET.
Java
Java is a powerful, modern programming language. Sun Microsystems introduced the Java programming language in 1991. Its use in developing practical software for the internet is unparalleled. For this reason, Java is also called the internet version of C++. Java has become extremely popular due to the growing popularity of internet networking programs. The main feature of Java is that once it is compiled for a platform, it can be run directly on any other platform. In other words, it has the WORA (Write Once, Run Anywhere) feature.
JavaScript provides benefits for the development of visual basic systems and other software. Because popular web browsers enabled Java applets to run within web pages, it quickly became popular.
JavaScript (JavaScript)
JavaScript is a lightweight programming language used to make web pages interactive. It can insert dynamic text into HTML. JavaScript is known as a browser language. JavaScript is influenced by the Java and C languages. In 1995, Brendan Eich, an engineer at Netscape, created JavaScript.
Oracle (ORACLE)
Oracle is the result of Dr. E. F. Codd's extensive research. It was developed using a combination of the C and Java programming languages. Oracle Corporation was the first company to commercially release a true relational database. Oracle has gained acceptance in the modern world as a network-based database program. As a result, it plays an important role as a database program. Oracle's administrative system is very robust. Additionally, its security system is very powerful.
Fortran (FORTRAN)
The English word FORTRAN stands for Formula Translation. This language is extremely useful for solving scientific and engineering problems using mathematical methods. The IBM company introduced this language in 1957. Although it is very old, its relevance has not diminished. Because it can perform calculations extremely quickly, this language is still used in large-scale simulations. Fortran is used more in supercomputing and high-performance computing than by the average user. Scientists use it to solve many major mathematical problems in physics and chemistry for their research.
Ruby (Ruby)
With the goal of making programming more fun, a Japanese programmer named Yukihiro Matsumoto created the Ruby programming language in 1993. Ruby quickly became very popular for creating web applications. Ruby has caught the attention of many people with its 'Ruby on Rails' framework. It can be used to create a wide variety of web applications in an excellent way by leveraging the Ruby language's various libraries. The only problem with the Ruby language is preparing quality code.
Python
Python is a high-level, object-oriented, and web-based programming language. It is used to create many multipurpose applications, including dynamic web applications. The language was created in 1991 by a Dutch scientist, Van Rossum. Python's code syntax is very concise, and the language has a rich standard library. Features and new modules that are available in other languages can be easily used in Python. Many programs for Linux-based operating systems are written in Python. Python's diverse uses are notable in the information security industry. Python is used for rapidly deploying server-side software. Notable among the major IT giants that use Python are Google and NASA. It is currently one of the most popular languages and was recognized as the best programming language by the IEEE in 2018.
Perl (Perl)
A high-level dynamic programming language. Perl performs tasks dynamically at runtime that other programming languages complete at compile time. It was invented by Larry Wall in 1987. Perl has borrowed features from many other languages, such as C, awk, sed, and Unix.
Interpreter Program
We have been mentioning interpreter programs for some time now; let's learn in more detail what this interpreter program is and how it works.
A program that executes a source program by interpreting it line-by-line is called an interpreter. (object) program is called a translator program. A translator program is used to convert a program written in a high-level language into machine language. Currently, there are three types of translator programs. They are:
1. Compiler
2. Interpreter
3. Assembler
┌──────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Source Program │ ──> │ Translator Program │ ──> │ Object Program │
└──────────────┘ └──────────────────┘ └─────────────────┘
The advantage of a translator is
1) Linking the program
2. Reporting program errors
3. Allocating the necessary memory in main memory
4) Reduces program dependency by on-demand execution.
Disadvantages:-
1. Line-by-line error identification and correction is not possible.
2) Debugging and testing are slow.
3) Requires more memory.
Interpreter
An interpreter is a translator program that translates a high-level language source program, line by line, into a machine language object program. The interpreter does not create an object program. It provides the opportunity to see and correct errors in the program as it is being executed (run).
It translates one line at a time, which makes it comparatively slower. Interpreted languages are used by interpreters. For example: Java, Python.
Advantages of an Interpreter:-
1. An interpreter is more user-friendly.
2. It is easy to debug or modify the program.
3. Since the interpreter is small in size, it consumes less memory.
4) The interpreted object program does not have to be stored in memory.
5) Interpreters are used for small computers.
Disadvantages of an Interpreter:-
1) It takes 5 to 25 times longer than a compiler to execute a program.
2) The program's instructions must be translated one by one each time the program is executed.
Assembler
An assembler is a translator used to convert a program written in assembly language into machine language. It stores all data and instructions in the main memory and, if there is any error anywhere in the program, it detects it and reports it with a message. For example – GAS, GNU assemblers.
Program Organization
Now, let's discuss program organization. The organization of a program refers to its structure. Every program primarily consists of three parts: input, output, and processing. A complete program is formed by the coordination of these parts. Input refers to all the information, data, and instructions that are given to the computer with the goal of obtaining a result. Process means processing the provided information according to the instructions given in the program. And output means the result obtained from the processing.
Example:-
To find the product of two numbers-
Input:- The two numbers must be provided.
Process:- The two numbers are multiplied.
Output:- The product is displayed.
┌─────────┐ ┌──────────┐ ┌──────────┐
│ Input │ ──> │ Process │ ──> │ Output │
└─────────┘ └──────────┘ └──────────┘
int x = 30; // Input
int y = 7;
z = x * y; // Process
printf(“Total = %d”, z); // Output section
There are many more unknown topics about programming languages. But not today; we will discuss them in the next installment. Until then, everyone take care.
