Compiler

High-level Languages Using Interpreters and Compilers

A program is a set of instructions that tells a computer what to do in order to come up with a solution to a particular problem programs are written using a programming language a programming language is a formal language designed to communicate instructions to a computer there are two major types of programming languages low-level languages and high-level languages low-level languages are referred to as low because they are very close to how different Hardware elements of a computer actually communicate with each other ?

Low level languages are machine oriented and require extensive knowledge of computer hardware and its configuration there are two categories of low-level languages machine language and assembly language machine language or machine code is the only language that is directly understood by the computer and it does not need to be translated all instructions use binary notation and are written as a string of ones and zeros a program instruction and machine language may look something like this technically speaking this is the only language computer hardware understands however binary notation is very difficult for humans to understand this is where assembly languages come in on assembly language is the first step to improve.

Programming structure and make machine language more readable by humans an assembly language consists of a set of symbols and letters a translator is required to translate the assembly language to machine language this translator program is called the assembler it can be called the second generation language since it no longer uses ones and zeros to write instructions but terms like move add sub and end many of the earliest computer programs were written in assembly languages.

Most programmers today don’t use assembly languages very often but they’re still used for applications like operating systems of electronic devices and technical applications which use very precise timing or optimization of computer resources while easier than machine code assembly languages are still pretty difficult to understand this is why high-level languages have been developed a high-level language is a programming language that uses English and mathematical symbols like plus/minus percent and many others in its instructions using the term programming languages.

Most people are actually referring to high-level languages are the languages most often used by programmers to write programs examples of high-level languages are C++ Fortran Java and Python to get a flavor of what a high-level language actually looks like consider an ATM machine where someone wants to make a withdrawal of $100 this amount needs to be compared to the account balance to make sure there are enough funds the instruction in a high-level computer language would look something like this x equals 100 if balance less than X print insufficient balance else: print please take your money this is not exactly how real people communicate but it is much easier to follow than a series of ones and zeros in binary code

There are a number of advantages to high-level languages the first advantage is that high-level languages are much closer to the logic of a human language a high-level language uses a set of rules that dictate how words and symbols can be put together to form a program learning a high-level language is not unlike learning another human language you need to learn vocabulary and grammar so you can make sentences to learn a programming language you need to learn commands syntax and logic which correspond closely to vocabulary and grammar the second advantage is that the code of most high-level languages is portable and the same code can run on different hardware both machine code and assembly languages are Hardware specific and not portable this means that the machine code is used to run a program.

This image has an empty alt attribute; its file name is java-2327538_1920-1024x579.png

On one specific computer needs to be modified to run on another computer portable code in the high-level language can run on multiple computer systems without modification however modifications to code in high-level languages may be necessary because of the operating system for example programs written for Windows typically don’t run on a Mac a high-level language cannot be understood directly by a computer and it needs to be translated into machine code there are two ways to do this and they are related to how the program is executed a high-level language can be compiled or interpreted a compiler is a computer program that translates a program written in a high-level language to the machine language of a computer the high-level program is referred to as the source code a typical computer program processes some type of input data to produce output data the compiler is used to translate.

Source code into machine code or compiled code this does not yet use any of the input data when the compiled code is executed referred to as running the program the program processes the input data to produce the desired output when using a compiler the entire source code needs to be compiled before the program can be executed the resulting machine code is typically a compiled file such as a file with an exe extension once you have a compiled file you can run the program over and over again without having to compile it again if you have multiple inputs that require processing you run the compiled code as many times as needed an interpreter is a computer program that simulates a computer that understands a high-level language this means the interpreter translates the source code line by line during execution consider again a computer program that processes some type of input data to produce output data the interpreter executes the code line by line which results in the desired output data the only result is the output data there is no compiled code.

When using an interpreter every time you want to run the program you need to interpret the code again line by line there is no compiled code to use if you have multiple inputs that require processing to understand the difference between compiling and interpreting let’s examine the equivalent in human languages, for example, consider a movie made in Asia where all the characters speak Vietnamese to market the movie to an international audience the spoken text needs to be translated into English a translator would sit down and carefully translate all the text and create subtitles for the movie anytime someone wants to watch the movie they can turn on the subtitles this type of translation is the equivalent of compiling everything is translated once and can be used many times.

Afterward now consider a delegate from Vietnam giving a speech in the United Nations and Vietnamese in order for the attendees to understand the speech there are a number of translators who provide a translation that is transmitted to the attendee’s headphones this translation occurs close to real-time every time the delegate speaks in Vietnamese the translators get to work this type of translation is the equivalent of interpreting a text is translated line by line as necessary and the results are not used again compiled code tends to be faster since the translation is completed in one step prior to the actual execution interpreted code, on the other hand, is more flexible and can be run interactively, for example, using interpreted code you can try it out a few lines of code to see if they work very quickly.

Without having to go through the steps of compiling and executing the program one advantage of using compiled code is that it does not reveal the original source code this makes it possible to distribute a program without revealing its inner workings when you install a software application on your computer you are typically installing a compiled version of the code you can run the software application but you can’t open up the source code in the original programming language for many companies selling software applications the original source code is a well-kept secret and gives them their competitive advantage over other companies examples of compiled languages include C and its derivatives C++ and C sharp COBOL and Fortran examples of interpreted languages are Java Perl Python and Ruby there are two major types of programming languages.

Low-level languages and high-level languages low-level languages are machine-oriented and require extensive knowledge of computer hardware and its configuration there are two categories of low-level languages machine language and assembly language machine language or machine code consists of binary code and is the only language that is directly understood by the computer an assembly language consists of a set of symbols and letters and requires translation to machine language both machine code and assembly languages are Hardware specific a high-level language is a programming language that uses English and mathematical symbols in its instructions to execute a program in a high-level language it can be compiled or interpreted a compiler translates the entire program written in a high-level language to machine language prior to execution an interpreter translates a program line by line during execution.

Leave a Comment