You might have heard words like compiler, interpreter, assembler, machine language, high-level language etc. But what on earth are they? Here, in this article on introduction to programming languages, let’s take a look at programming languages.
What a programming language does is, it makes a computer to do the instructions. For that, a computer must be able to understand that language. But we know that a computer understands only machine language. We humans can’t understand machine language. So, there must be some mechanism to bridge the gap between the two and make the computer understand high-level language. This is what a compiler does. Let’s examine each of these separately.
See the Wikipedia page on machine code. In short, it’s the language that the CPU understands and executes directly. It is in numerical form and represented as binary digits. So, the machine language is all zeroes and ones. Is it easy for you to understand a machine code? Damn! it’s very very hard. That’s why we’re using other languages.
Assembly language is a low-level language. It is specific to the particular processor architecture. For example, think of the Pentium 4 processor. There’s an assembly language for programming the P4 processor. It’s been made by Intel Corporation. When the processor is released, they release the assembly language too. It’s specific for the particular processor. Assembly language, although is called a low-level language, is for humans to read and understand. Computers can’t understand it. We have to convert it to machine language code for the CPU to execute. An assembler does that.
The high-level language is for the humans to read and understand. It’s not for specific to a processor. All the programming languages we hear are high-level languages. Eg. C, C++, Java, Python etc. As I said earlier, a computer can’t carry out the instructions written in high-level languages. That’s what a compiler does. It converts high-level language code to machine language.
A compiler is a software which converts a program written in a high-level language to lower level. It converts a high-level language program into a form that is directly executable by the CPU. That means the compiled high-level programs are stored as machine language code and it is executed directly.
The interpreter is similar to compiler except that the high-level programs are translated only while they are executed. It’s not compiled into machine language as compilers do. Interpreters either interpret the source code directly or the source or the source code is first compiled into a bytecode, which is the highly efficient representation of the high-level program.
Assembler is also a translator like compiler and interpreter. The difference is that assembler translates assembly language into machine language to be directly executed by the processor.
Platform independent languages
For languages like C or C++, the programs are compiled to native code. It can’t be run on other platforms. For example, if we are programming using a Windows system for programming, the programs written are compiled for Windows. Once compiled to native code, it can’t be run on other platforms like Linux or Mac.
Platform independent programs are different. They can be run on all platforms alike. The compiler compiles the program into some intermediate form called bytecode. The bytecode will run on a virtual machine. It will run on all devices where the virtual machine is present. So, once written the programs can be run everywhere. Java is an example of platform independent language.
What do you think about this article on introduction to programming languages? Did I miss any relevant points? Add your valuable feedback as a comment below.