Programming Languages There is another type of software that enables us to make software (program) on our own. This is called programming language. It operates in close conjunction with operating system and enables us (the programmer) to exploit certain capabilities of operating system while creating the program. This software is called language because it resembles different characteristics of human language (for example syntax rules that are similar to our grammar). Programming languages are categorized in different types according to the method by which a programmer creates the instructions. Programming languages are mainly categorized into two types – low level and high languages.
A low-level language is a programming language much closer to the hardware. It requires a thorough knowledge (low level) of the hardware for which the program is being created. Program written for one type of machine may not run (in fact does not run) on other machines of different manufacture. These can be divided into two types – machine language and assembly language.
Machine language is the lowest level programming language, which is the only language understood by a computer. While easily understood by computers, machine languages are almost impossible for humans to use because they consist entirely of numbers. Early computers were usually programmed using machine language.
As the machine language involves only numbers specific to a machine, developers thought that if they can represent those numbers by some symbols, it would be easier to make programs. So, they developed assembly languages in which those numbers are replaced by some symbols (called mnemonic). (For example if 78 is the number that tells the computer to add two numbers, ADD could be used to represent it.) Each number is replaced by a symbol so that by remembering the symbol for each number, programmers now can write programs. As machine language is the only language understood by computers, they also developed a program that could convert the programs written in symbols into machine language. This converting program is called assembler. Like the machine language, assembly language programs are also dependent on the machine because numbers may vary form machine to machine. But the flexibility it offered was it could be made to run on other machines by slightly changing the code or changing the assembler. Moreover, it’s easier to learn assembly language than the machine language.
220.127.116.11.3 High Level Language
A high level language is a programming language that enables a programmer to write programs more or less independent of a particular type of computer. Such languages are considered highlevel because they are closer to human languages and further from machine languages. Every high level language has its own set of rules to represent instructions. This rule is called syntax. The main advantage of high-level languages over low-level languages is that they are easier to read, write, and maintain.
The first high-level programming languages were designed in the 1950s. Now there are dozens of different languages, such as Ada, Algol, BASIC, COBOL, C, C++ , FORTRAN, LISP, Pascal, and Prolog etc. Like assembly language programs, programs written in a high-level language also need to be translated into machine language. This can be done in two ways – by a compiler or interpreter.
Compiler A compiler is a program that translates program (called source code) written in some high level language into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instructions. A compiler translates high-level instructions directly into machine language and this process is called compiling.
Interpreter An interpreter translates high-level instructions into an intermediate form, which it then executes. Interpreter analyzes and executes each line of source code in succession, without looking at the entire program; the advantage of interpreters is that they can execute a program immediately. Compilers require some time before an executable program emerges. However, programs produced by compilers run much faster than the same programs executed by an interpreter.
Compiled programs generally run faster than interpreted programs. The advantage of an interpreter, however, is that it does not need to get through the compilation stage during which machine instructions are generated. This process can be time-consuming if the program is long. The interpreter, on the other hand, can immediately execute high-level programs. For this reason, interpreters are sometimes used during the development of a program, when a programmer wants to add small sections at a time and test them quickly. Because compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language. For example, there is a C compiler for PCs and another for Unix computers.
Compile Compiling is a process of transforming a program written in a high-level programming language from source code into object code. Programmers write programs in a form called source code. Source code must go through several steps before it becomes an executable program. The first step is to pass the source code through a compiler, which translates the high-level language instructions in the source code follow its syntax rules. If not it will inform the programmer where rules have been violated. The final step in producing an executable program –after the compiler has produced object code – is to pass the object code through a linker. The linker combines molecules (different program segments) and gives real values to all symbolic addresses (memory locations), thereby producing machine code.
Program written in a particular programming language in its original form is called source code (program). The word source differentiates code from various other forms that it can have (for example, object code and executable code). To execute the program, however, the programmer must translate it into machine language. The compiler translates the source code into a form called object code. Source code is the only format that s readable by humans. When we purchase programs, we usually receive them in their machine-language format. This means that we can execute them directly, but cannot read or modify them.
Object code is the code produced by a compiler. Object code is often the same as or similar to a computer’s machine language. The final step in producing an executable program is to transform the object code into machine languages, if it is not already in this form. A program called linker does this job.