Programming in C: Unit I (a): Introduction to Programming

Generation of Programming Languages

We now know that programming languages are the primary tools for creating software. As of now, hundreds of programming languages exist in the market, some more used than others, and each claiming to be the best.

GENERATION OF PROGRAMMING LANGUAGES

We now know that programming languages are the primary tools for creating software. As of now, hundreds of programming languages exist in the market, some more used than others, and each claiming to be the best. However, back in the 1940s when computers were being developed there was just one language-the machine language.

The concept of generations of programming languages (also known as levels) is closely connected to the advances in technology that brought about computer generations. The four generations of programming languages include:

• Machine language

• Assembly language

• High-level language (also known as third generation language or 3GL)

• Very high-level language (also known as fourth generation language or 4GL)

First Generation: Machine Language

Machine language was used to program the first stored program on computer systems. This is the lowest level of programming language. The machine language is the only language that the computer understands. All the commands and data values are expressed using 1 and Os, corresponding to the 'on' and 'off' electrical states in a computer.

In the 1950s each computer had its own native language, and programmers had primitive systems for combining numbers to represent instructions such as add and subtract. Although there were similarities between each of the machine languages, a computer could not understand programs written in another machine language (Figure 1.4).

In machine language, all instructions, memory locations, numbers, and characters are represented in strings of 1s and Os. Although machine-language programs are typically displayed with the binary numbers represented in octal (base 8) or hexadecimal (base 16), these programs are not easy for humans to read, write, or debug.

The main advantage of machine language is that the code can run very fast and efficiently, since it is directly executed by the CPU.

However, on the downside, the machine language is difficult to learn and is far more difficult to edit if errors occur. Moreover, if you want to add some instructions into memory at some location, then all the instructions after the insertion point would have to be moved down to make room in memory to accommodate the new instructions.

Last but not the least, the code written in machine language is not portable across systems and to transfer the code to a different computer it needs to be completely rewritten since the machine language for one computer could be significantly different from another computer.

Architectural considerations made portability a tough issue to resolve.

Second Generation: Assembly Language

The second generation of programming language includes the assembly language. Assembly languages are symbolic programming languages that use symbolic notation to represent machine-language instructions. These languages are closely connected to machine language and the internal architecture of the computer system on which they are used. Since they are close to the machine, assembly language is also called low-level language. Nearly all computer systems have an assembly language available for use.

Assembly language developed in the mid 1950s was a great leap forward. It used symbolic codes also known as mnemonic codes that are easy-to-remember abbreviations, rather than numbers. Examples of these codes include ADD for add, CMP for compare, MUL for multiply, etc.nel iw gat how now

Assembly language programs consist of a series of individual statements or instructions that instruct the computer what to do. Basically, an assembly language statement consists of a label, an operation code, and one or more operands.

 Labels are used to identify and reference instructions in the program. The operation code (opcode) is a mnemonic that specifies the operation that has to be performed such as move, add, subtract, or compare. The operand specifies the register or the location in main memory where the data to be processed is located.

However, like the machine language, the statement or instruction in the assembly language will vary from machine to another because the language is directly related to the internal architecture of the computer and is not designed to be machine independent. This makes the code written in assembly language less portable as the code written for one machine will not run on machines from a different or sometimes even the same manufacturer.

No doubt, the code written in assembly language will be very efficient in terms of execution time and main memory usage as the language is also close to the computer.

Programs written in assembly language need a translator often known as assembler to convert them into machine language. This is because the computer will understand only the language of 1s and Os and will not understand mnemonics like ADD and SUB.

The following instructions are a part of assembly language code to illustrate addition of two numbers:

Although assembly languages are much better to program as compared to the machine language, they still require the programmer to think on the machine's level. Even today, some programmers still use assembly language to write parts of applications where speed of execution is critical, such as video games but most programmers today have switched to third or fourth generation programming languages.

Third Generation Programming Languages

A third generation programming language (3GL) is a refinement of the second-generation programming language. The 2GL languages brought logical structure to software. The third generation was introduced to make the languages more programmer friendly.

Third Generation Programming Languages spurred the great increase in data processing that occurred in the 1960s and 1970s. In these languages, the program statements are not closely related to the internal architecture of the computer and is therefore often referred to as high-level languages.

Generally, a statement written in a high-level program- ming language will expand into several machine language instructions. This is in contrast to assembly languages, where one statement would generate one machine lan- guage instruction. Third Generation Programming Lan- guages made programming easier, efficient, and less prone to errors.

High-level languages fall somewhere between natu- ral languages and machine languages. Third Generation Programming Languages include languages such as FOR- TRAN (FORmula TRANslator) and COBOL (Common Business Oriented Language) that made it possible for scientists and business people to write programs using fa- miliar terms instead of obscure machine instructions.

The first widespread use of high-level languages in the early 1960s changed programming into something quite different from what it had been. Programs were written in statements like English language statements, making them more convenient to use and giving the programmer more time to address a client's problems.

Although 3GLs relieve the programmer of demanding details, they do not provide the flexibility available in low- level languages. However, a few high-level languages like C and FORTRAN combine some of the flexibility of assembly language with the power of high-level languages, but these languages are not well suited to an amateur programmer.

While some high-level languages were designed to serve a specific purpose (such as controlling industrial robots or creating graphics), other languages were flexible and considered to be general-purpose languages. Most of the programmers preferred to use general-purpose high-level languages like BASIC (Beginners' All-purpose Symbolic Instruction Code), FORTRAN, PASCAL, COBOL, C++, or Java to write the code for their applications.

Again, a translator is needed to translate the instructions written in high-level language into computer-executable machine language. Such translators are commonly known as interpreters and compilers. Each high-level language has many compilers.

For example, the machine language generated by one computer's C compiler is not the same as the machine language of some other computer. Therefore, it is necessary to have a C compiler for each type of computer on which the C program has to be executed.

Third generation programming languages have made it easier to write and debug programs, which gives programmers more time to think about its overall logic. The programs written in such languages are portable between machines. For example, a program written in standard C can be compiled and executed on any computer that has a standard C compiler.

Fourth Generation: Very High-Level On Languages

With each generation, programming languages started becoming easier to use and more like natural languages. However, fourth generation programming languages (4GLs) are a little different from their its prior generation because they are basically non-procedural. When writing code using a procedural language, the programmer has to tell the computer how a task is done-add this, compare that, do this if the condition is true, and so on, in a very specific step-by-step manner. In striking contrast, while using a non-procedural language the programmers define only what they want the computer to do, without supplying all the details of how it has to be done.

There is no standard rule that defines what a 4GL is but certain characteristics of such languages include:

• the code comprising instructions are written in English- like sentences;

• they are non-procedural, so users concentrate on 'what' instead of the 'how' aspect of the task;

• the code is easier to maintain;

• the code enhances the productivity of the programmers as they have to type fewer lines of code to get something done. It is said that a programmer becomes 10 times more productive when he writes the code using a 4GL than using a 3GL.

A typical example of a 4GL is the query language that allows a user to request information from a database with precisely worded English-like sentences. A query language is used as a database user interface and hides the specific details of the database from the user. For example, when working with structured query language (SQL), the programmer just needs to remember a few rules of syntax and logic, and it is easier to learn than COBOL or C.

Let us take an example in which a report has to be generated that displays the total number of students enrolled in each class and in each semester. Using a 4GL, the request would look similar to one that follows:

TABLE FILE ENROLLMENT

SUM STUDENTS BY SEMESTER BY CLASS

So we see that a 4GL is much simpler to learn and work with. The same code if written in C language or any other 3GL would require multiple lines of code to do the same task.

Fourth generation programming languages are still evolving, which makes it difficult to define or standardize them. The only downside of a 4GL is that it does not 229 make efficient use of the e machine's resources. However, the benefit of executing a program fast and easily, far outweighs the extra costs of running it.

Fifth Generation Programming Languages

Fifth generation programming languages (5GLs) are cen- tred on solving problems using constraints given to the program, rather than using an algorithm written by a pro- grammer. Most constraint-based and logic programming languages and some declarative languages form a part of the fifth-generation languages. Fifth generation program- ming languages are widely used in artificial intelligence research. Typical examples of 5GLs include Prolog, OPS5, and Mercury.

Another aspect of a 5GL is that it contains visual tools to help develop a program. A good example of a fifth generation language is Visual Basic.

So taking a forward leap than the 4GLs, 5GLs are designed to make the computer solve a given problem without the programmer. While working with a 4GL, the programmer had to write specific code to do a work but with 5GL, the programmer only needs to worry about what problems need to be solved and what conditions need to be met, without worrying about how to implement a routine or algorithm to solve them.

Generally, 5GLs were built upon Lisp, many originating on the Lisp machine, such as ICAD. Then, there are many frame languages such as KL-ONE.

In the 1990s, 5GLs were considered to be the wave of the future, and some predicted that they would replace all other languages for system development (except the low- level languages). In 1982 to 1993 Japan had put much research and money into their fifth generation computer systems project, hoping to design a massive computer network of machines using these tools. But when larger programs were built, the flaws of the approach became more apparent. Researchers began to observe that starting from a set of constraints for defining a particular problem, then deriving an efficient algorithm to solve the problem is a very difficult task. All these things could not be automated and still requires the insight of a programmer.

However, today the fifth-generation languages are back as a possible level of computer language. Software vendors across the globe currently claim that their software meets the visual 'programming' requirements of the 5GL concept.

Programming in C: Unit I (a): Introduction to Programming : Tag: : - Generation of Programming Languages


Related Topics



Related Subjects


Programming in C

CS3251 2nd Semester CSE Dept 2021 | Regulation | 2nd Semester CSE Dept 2021 Regulation