Machine Code and High-level Languages: Using Interpreters and Compilers
Programming language is coded language that used by the programmers so that they can write instructions on the computer and do whatever they want to perform function. Machine language is the most basic programming language that use binary numbers 1 and 0 and execute code on the computer in fast manner without using translator. There are many programming languages and new ones are being developed.
A low level language is close to writing actual machine instructions that provide very less abstraction of programming concepts. Assembly and Machine code are the type of low-level programming language. The language is useful because the code written in that run very fast on any platform and require less memory but sometimes it is more difficult to lookup because a reader should have deeper knowledge of machine language. Example of low-level language is C provide minimal amount of abstraction on the smallest possible cost that enable to provide good performance and efficiency. The language has excellent for close control of the CPU like many drivers are coded in assembly language. But the language also have some of the disadvantages to use programming command can be quite obscure and difficult. This language also produce least portable source code.
High-level language is a programming language that enables development of a program in much simpler programming context and is generally independent of the computer's hardware architecture. The language more focus on the programming logic rather than underlying components of hardware like memory addressing and register utilization. High level languages are designed by the programmers those closely related to humans. The programming style of high-level language is easier to learn an implement and code to be focused on specific program that needs to be created. The language doesn't require addressing hardware constraints to great extent while developing a program. Though the high-level code must be interpreted into machine language before executing it. Examples of High-level language includes C++, FORTAN, JAVA, PASCAL, PERL, PHP, PYTHON, RUBY and many more.
The primary function of compiler is to processes statements written in a particular programming language and turn into machine language which is known as code that used by computer's processor. In other words we can define compiler is a computer program that can transform source code written in programming language into another target language often having object code. Compiler is basically use to translate high-level language code to low-level language i.e assembly language or machine code. Generally, compilers are a specific type of translator which also support cross-compiler. In cross-compiler, compiled program can run on a computer whose CPU or OS is different from the one on which compiler runs is called as cross-compiler.
To execute program instruction written in high-level language is done by two-ways, first is by the help of compiler which compiles the program and second method is to pass the program through an interpreter. So interpreter translate statements of a program into machine code and translate only one instruction at a time and execute it. First it read the first statement translate it and then execute it after that read the next statement of the program do the same for second one also. So it proceed till all the statements are translated and executed. One of the main advantage of using interpreter is that it enables to check each and every line of code which reduce the chances of getting errors.