In this article, I will try to answer you about the question, what are programming languages? We will discuss about the computer, computer programming, types of programming languages and two most important methods used in programming languages. So, read full article to get some knowledge. This article is going to be very interesting for you and you will learn a lot from this article.
What is Computer?
Let’s start with definition of a Computer. A computer is a general purpose machines which can perform many computational task. The modern-day Computers are now be able to perform billions or trillions of calculations within a fraction of second. But, the computers can’t do anything on their own.
What is Program?
So, for a computer to do something, there should be one thing that has to give the instructions to it. These instructions will contain step by step information to perform a specific task and these instructions are called as Program.
Who is Programmer?
Now, the person who is going to write these instructions or the program is called as the Programmer. The programmer will write instructions or the program and the computer will execute that program or computer will follow those instructions to perform a specific task. The one Computer has many programs in it.
Types of Programs
There are some programs which will manage the computer hardware resources like Keyboard, Mouse, Speakers etc. These programs are called System Programs. There are some programs which will provide specific functionality to a user for example the Notepad, Web Browser, Music Player, Video Player and all these types of programs are called as the Application Programs.
What are Programming Languages?
Now, we know that we need to give instructions to the computer so that the computer can work on it. So, the thing is, how we can give the instruction to the computer? Or what are the programming languages? in which we can give the instructions to the computer? Now, since the computer is just a machine. How we can communicate with this machine? So, the language in which these instructions are written or the language in which the program is written is called as the Programming Language.
Types of Programming Languages
Now, there are several types of programming languages and we are going to see the details about them. So, you may probably hear that the computers can only understand the binary language. Now, this binary language has only two values, 0 and 1. In this binary language, whatever you want to say has to be in the form of this 0 and 1. These computers are built in such a way that they can understand or they can recognize the pattern of the 0s and 1s and then they can work on it accordingly.
Now, why we have built the computers to understand this binary language? That is because, this binary language which has only two values is easy to create in the hardware level and perform the task in less time. For example, if we have a wire and if the current is flowing through this wire then we can say it is 1. If the current is not flowing then we can say it is zero. So, in general we can say that, “1” stands for something which exists and “0” stands for something which doesn’t exist.
Since, this binary language is easy to create in the hardware level, so the computer is built in the hardware level to recognise this pattern of 0 and 1. The computer has specific patterns of “0” and “1” like 10001001 or 1110110. Each pattern represents a specific set of operations.
So, when the computer will see a specific pattern of 0s and 1s it knows what it has to do. Now, the computers can understand this binary language and this binary language with the computers understand are also called as the Machine Language.
Let’s see the types of programming languages available. In this modern day, we have a lot of programming languages available.
Machine Level Language or Low-Level Language
So, the first type of programming language or the language in which we can communicate with the computer. Now, as you know that computer can understand only binary language or the machine language which is the combination of 0s and 1s. So, the first type of programming languages is the machine level language. In machine level language, we have the instructions in the form of 0 and 1. Whatever you want to say to computer has to be in the form of 0 and 1 and since the computers are built in such a way that they can recognize this 0s and 1s and perform some specific operation on that.
Now the problem with this machine level language is, in order to program in machine level language, one has to know everything about the computer. The programmer has to deal with the hardware directly. Programmer has to work with memory and data directly which is difficult. The programmer needs to know everything about the computer, computer processor, computer architecture everything about that. This is why machine level language is a bit difficult to learn.
Let’s say, you want to write a program in the machine level language and your program consists of thousand lines. All your instruction will contain the combination of 0s and 1s. First of all, it is difficult to write the program in the form of 0s and 1s for any human being and also if you make some mistakes in your program then it is difficult to spot and because of all these, a normal guy can’t really learn the programming easily.
So, to solve these kinds of problems another type of programming languages were invented and they are called as the Assembly level language.
Assembly Level Language
In Assembly level language, instead of that 0s and 1s combination mnemonic the symbolic codes were introduced. For example, if the programmer has to write an instruction. Let’s say he wants to add the numbers 5 and 6. Then in the machine level language it has to be in the form of this 0s and 1s like 11001011010101. In the Assembly level language mnemonic codes were used and the programmer could write “ADD 5 6” statement.
So, a lot of mnemonic or the symbolic codes where used and the programmer could write the program in this way in assembly language. As you can see it was a lot more human readable format and it looks like the humans talk to each other in daily life. The programmer can understand the code just by looking at it and it was a lot easier to code than the machine level language.
Now, the thing is that, as we know the computer only understands the binary language (0s and 1s) or machine level language. So, whenever the programmer writes a program in Assembly language it will first converted into machine language or binary form then the computer will perform that specific task like in our example, we want to add two number 5 and 6. So, there should be thing like who convert our Assembly language program into machine language so that the computer can understand our program and execute it and show the output. In order to convert the Assembly language to Machine language we use a program called Assembler.
The assembler will convert the code written in the Assembly level language to machine level language. Now, this Assembly level language was lot easier to learn and anyone can learn the programming a lot more easily than the machine level language but this assembly level language also had the same difficulties. Although it was a lot easy to write the programs in Assembly level language than the Machine level language. If the program size increases then again it is difficult to spot the errors and also the code written in the Assembly level language was also Computer Architecture dependent.
The Computer Architecture dependent means, the code for one type of computer cannot be executed in another type of computer which has different architecture. So, again to solve these kinds of problems a new type of languages was invented so that a lot more people can come and write the programs. These type of programming languages are called as the Higher-Level Languages.
The high-level languages are designed in such a way that they are very easy for a beginner to learn. These languages were very close to the human readable language. For example, in this higher-level language one could write the instruction to add 5 and 6. The programmer just has to write “5 + 6”. So, as you can see it is a lot more similar to the human language. We use this method in our daily lives in mathematics. Anyone can understand what we are trying to do just by looking at the code. Since, this higher-level language where a lot easier to learn, many people started learning computer programming and started creating lot more programs to solve their daily life problems.
Now again the thing is the program written in the higher-level language cannot be directly executed in the computer that is because the computer can only understand the machine language which can contain 0 and 1. So, we have to convert the program which is written in the high-level language to machine language which computer can understand and execute.
So, for high-level languages there are two ways in which we can convert the source code from high-level language to machine level language and execute it. The one method was the Compilation method, where a program called compiler was used. Another method is called as the interpretation and for this interpretation method another type of program called as interpreter is used. We will discuss the details of compilation and interpretation methods later in this article but here, just remember that these are two different methods which convert the high-level language code into machine level language.
Now here the machine level language and the Assembly level language they are called as the lower-level languages, because while writing the programs in these languages, the programmers could easily access the computer memory and directly work with the data. But, in case of high-level languages, the programmers can’t directly access the memory and work with data.
Middle Level Languages
As we know that in high-level languages, the programmer can’t access the computer memory and work with data, so the solution to this problem is middle-level languages. There are some languages in the high-level language type, which allow the programmer to work with the Computer memory and the data and they are called as the middle-level languages.
In middle-level languages they provide all the features of the higher-level languages and also, they allow the programmer to work with the Computer memory and data directly. Since, these languages provide the feature of the lower-level language and also the high-level language they are called as the middle-level languages.
We have the languages like C and C++. These are the middle-level languages because they allow the programmer to work with the Computer memory and data and also, they provide all the features of this high-level language. In the high-level languages, we have Java, C# (pronounced as C Sharp), Python, etc.
Execution speed comparison
As you know that the computer only understands the Machine level language which is very close to the computer, it executes much faster than all high-level and middle-level languages. So, the execution speed of machine language is very high and after machine level language, we have the Assembly languages and their execution speed is better than the high-level languages but a bit slower than the machine level language and then we have the high-level languages.
How to convert high-level language to machine language
So now, as I discuss before in high-level languages portion, we need to convert the code from higher-level language to machine code in two different ways. One is the Compilation method and other is Interpretation method. So, let’s see Compilation and Interpretation methods in detail.
So, in the compilation method a program called compiler is used. The compiler will take the high-level language program and it will convert that to the machine language and this process is called as the compilation method. As you can see in the image above, the compiler will read the high-level language program and will convert that to the machine language. It will convert the entire program into machine language and then the machine language code will be executed. So, the thing is compiler will convert entire program which is written in the high-level language to machine level language and then that machine level language code will be executed.
Now let’s take a look at this interpretation method mentioned in the above image. So, here also we will be converting the program written in the high-level language to the machine level language and then executing that code. For that purpose, we will be using a program called as the interpreter and this process is called as the interpretation. Now as you can see in the above image, the source code or the programs written in the high-level language and this interpreter will read the first line of the source code or the and then it will convert that to the machine code and then it will execute it immediately. After that, it will go to the next line of the high-level language program it will read that line, convert that code and then it will execute it immediately and then it will go to the third line and then again it will convert that code and then it will execute it and so on.
Difference between Compilation and Interpretation
So, the main difference between compilation and interpretation is that, in the compilation process the entire program which was written in the high-level language was read first, then it was converted to machine level language and then that entire program was executed at once. But, with the interpretation method, the interpreter will read the program which is in the high-level language line by line and it will convert and execute each line immediately at a time. This is how the compiler and interpreter work.
Comparison Table for difference between Compilation and Interpretation
|Compile the program at once||Interpret the program line by line|
|Source code is private||Source code is public|
|Require extra compilation step||No extra step|
|Debugging is difficult||Easier to debug|
Now, there are many languages in the high-level language type and in those languages, some follow the compilation method and some follow the interpretation method. The languages which follow the compilation method are called as the compiled languages. For example, C, C++ etc. These are all the compiled languages where the compilation method is used to convert the high-level language to machine language.
The higher-level languages which follow the interpretation method are called as the interpreted languages. For example, we have Python and the Python is an interpreted language.
All right, we have discussed about what are the programming languages? Type of programming languages. We have also discussed about the two methods of converting code from high-level language to machine language which are compilation and interpretation and difference between them. So, this is about the computer programming languages, types of programming languages, compilation and the interpretation method and I really hope that you found the answer of, what are programming languages? And I hope you have learned something from this article. Thanks for reading!