Introduction-to-Programming-Languages

In Sri Lanka people use three languages Sinhala, Tamil and English. The purpose of a language is to allow people to communicate. If we want to communicate with a computer it would be ideal if you could use a language like English. Unfortunately computers at present are not intelligent enough to understand human languages.

Because of this computer scientists have developed computer friendly languages. These computer languages could be learnt relatively easily by people. Using such a computer language you can communicate with a computer. More specifically you could instruct the computer to perform a particular task.

Computer Languages Generations

First Generation Computer Languages

In the computer there is a component called the central processing unit (CPU). The main purpose of the CPU is to execute instructions given to the computer. The instructions even a modern day computer can understand directly are numbers given in binary format. This language is called machine code (See Fig 4.1). This is the language that a computer really understands. Machine code is dependent on the type of CPU your computer has.

The Intel Pentium IV is the CPU used in new personal computers. There are older versions of this CPU, e.g. Pentium III, Pentium II, 80486, etc. These belong to a family of processors called the Intel 80×86. The machine code in these processors are similar.

There are other types of CPUs like the PowerPC used in Apple computers, UltraSparc used in Sun Workstations. The internal design of these CPUs are very different from the Intel 80×86 family of processors. Because of this, machine code of these processors are different from the Intel processors.

If you think of a calculator it could add, substract, multiply. These are the operations it can perform. A CPU of a computer has instructions to mainly perform arithmetic calculations such as add and logical operations such as or, and etc.. The instructions supported by the CPU are called the instruction set.

People do not instruct computers using machine code today. But when the first electronic computers were developed during the 1940s, the only type of computer language that was available was machine code. Computer scientists had to literally write all instructions using numbers. Machine Code is an example of a first generation computer language.

Second Generation Computer Languages

Using machine code was very difficult and error prone so in the 1950s they came up with the idea of using simple English words to replace the numerical instruction codes. These words were called mnemonics, and this computer language was named as Assembly.

Now the computer scientists could give instructions using simple words. They next converted these instructions into machine code so that the CPU could understand them using a software developed called an Assembler.

In Assembly every assembly instruction corresponds to a machine code instruction. Since Assembly languages corresponded to machine code, each different type of CPU has its own type of assembly. Assembly is still used today to program small electronic devices because assembly programs are more efficient in speed and requires the least amount of memory compared to programs developed using third generation languages . Assembly is classified as a second generation computer language. Both machine code and assembly are called low level languages.

Third Generation Computer Languages

A program is a list of instructions that performs a particular task. Assembly programs were very long, this made it difficult to maintain programs written in Assembly. In the late 1950 Computer Scientists came up with high level computer languages which were closer to English and Mathematics.

High Level languages are relatively easy for people to learn and to program computers.

shows examples of four programs written in diffe rent high level programming languages which display the message “Hello World” on the computer screen.

The computer cannot understand instructions given in a high level language. A transla tor is needed to convert the high level language program into machine code. Imagine that you got an opportunity to go to Japan as part of a student exchange program. As a student ambassador you need to make a speech to students about SriLanka. How would you carry out your speech?

If you knew how to speak in Japanese, that would be the best way to carryout your speech. But if you knew English couldn’t you still made the speech? You could by getting help of a translator who is conversant in both Japanese and English.

This is exactly how things work in a computer. A translator is used to translate instructions given in a high level language into machine code.

Coming back to the earlier example you could use two approaches to conduct your speech. One way to carry out your speech is for you to speak a few sentences in English and pause allowing the translator to repeat what you have said in Japanese. The second approach is that you could prepare your speech before hand and give a written copy of it to the translator. You could conduct your speech completely in English. Your Japanese friends would not understand anything you say, but would probably patiently wait till you finish. After you have finished the translator could now repeat your entire speech in Japanese.

These two approaches are used by computers to translate high level language programs to machine. Translator software which uses the first approach are called Interpreters and the latter are known as compilers.

An Interpreter converts a program written in a high level language to machine code as follows.

1. Interpret the next high level language instruction to machine code
2. Execute translated machine code instruction
3. Goto 1st step

A compiler on the other hand translates (compiles) the entire high level language program into machine code. The converted machine code program is usually stored on disk. In Microsoft Windows such machine code files generally have the extensions .EXE. You can get the computer to execute these instructions by running the executable file. i.e. by typing the name of the executable file in the command prompt or by selecting the executable using the Windows Task Bar Run command.

There are hundreds of different high level programming languages available with newer ones being developed regularly. This is because different people have made different attempts to make Programming (Writing Computer programs) much easier.

Some of the high level computer languages are general purpose. This means that these languages could be used to write programs which solve a wide range of problems. These could include, business applications, games, web applications etc. Java, C++, Visual Basic are example of such languages.

There are some high level languages which are special purpose. These languages are intended for writing specific types of programs only. For example COBOL was a language that was used for developing Business type applications. Fortran is used to developing scientific, engineering types of applications.

Most of the languages that are used in the software industry fall into the Third Generation Computer Language category.

Fourth Generation Computer Languages

When you use a third generation language to perform a task you need to provide a detail description of how this task should be carried out. For very narrow domains (specific areas) fourth generation programming languages have been developed, where you only needed to describe what is required. The most famous example of a fourth generation language is the Structured Query Language (SQL) which is used with databases.

Using SQL you can retrieve data from a database in different formats for various conditions just by specifying the headings you need, where they are stored (tables), and the conditions.

compares the differences when instructing a computer using SQL and Visual Basic (Third Generation Language) to retrieve data from a database. The example prints a list of students who have obtained an Avg above 75 from a database. In the Visual Basic example you are required to write all the details on how the data should be retrieved. In the SQL example only the requirements need to be specified.

Third Generation vs Fourth Generation

 

Fifth Generation Computer Languages

Computer Languages which are related to Artificial Intelligence e.g. Prolog is an example of Fifth Generation Languages. Prolog is used to develop Expert Systems.

Modern Computer Programming Languages

Almost all High Level computer languages used in the computer industry today are third generation computer languages. Professional Developers (Programmers) generally use software tools that support the program development (Integrated Development Environments) to enhance productivity. These tools include screen generators, report generators etc which automatically generate program coding when the developer draws data entry screens, reports using tool palettes.

The figure shows the initial screen when you start Delphi. The Form shown in the figure is the main window of the application program being written. You can addvarious controls from the Toolbox to the Form and properties of each control can be set making use of the Properties Windows.

 

Integrated Development Environment, for Delphi

Please follow and like us:
error

Leave a Reply

Your email address will not be published. Required fields are marked *