Unit 5 Programming Languages


Programming Languages

A computer program is a series of instructions that directs a computer to perform tasks. A computer programmer, often called a developer, creates and modifies computer programs. To create a program, programmers sometimes write, or code, a program’s instructions using a
programming language.

A programming language is a set of words, abbreviations, and symbols that enables a programmer to communicate instructions to a computer. Other times, programmers use a program development tool to create a program. A program that provides a user-friendly environment for building programs often is called a program development tool. Programmers use a variety of programming languages and tools to create programs (Figure).
Several hundred programming languages exist today. Each language has its own rules for writing the instructions. Languages often are designed for specific purposes, such as scientific applications, business solutions, or Web page development. When solving a problem or building a solution, programmers often use more than one language; that is, they integrate the languages.
Some programming languages provide less or no abstraction from the hardware. Whereas some provide higher abstraction. To separate programming languages on the basis of level of abstraction from hardware, they are classified into various categories.

Type of Computer Languages

Programming languages are basically classified into two main categories – Low level language and High level language. However, there also exists another category known as Middle level language. Every programming language belongs to one of these category and sub-category.
Two types of languages are low-level and high-level.
A low-level language is a programming language that is machine dependent. A machine-dependent language runs on only one particular type of computer. Each instruction in a low-level language usually equates to a single machine instruction. With a high-level language, by contrast, each instruction typically equates to multiple machine instructions. High-level languages often are machine independent. A machine independent language can run on many different types of computers and operating systems.

Low-Level Languages

Two types of low-level languages are machine languages and assembly languages.

Machine Language

Machine language known as the first generation of programming languages is the only language the computer directly recognizes (Figure 2). Machine language instructions use a series of binary digits (1s and 0s) or a combination of numbers and letters that represents binary digits. The binary digits correspond to the on and off electrical states. As you might imagine, coding in machine language is tedious and time-consuming.

Figure 1 A sample machine language program, coded using the hexadecimal number system.

Assembly Language

With an assembly language, the second generation of programming languages, a programmer writes instructions using symbolic instruction codes (Figure 3). 
Assembly languages also use symbolic addresses. A symbolic address is a meaningful name that identifies a storage location. For example, a programmer can use the name RATE to refer to the storage location that contains a pay rate. Despite these advantages, assembly languages can be difficult to learn. In addition, programmers must convert an assembly language program into machine language before the computer can execute, or run, the program. That is, the computer cannot execute the assembly source program. A source program is the program that contains the language instructions, or code, to be converted to machine language. To convert the assembly language source program into machine language, programmers use a program called an assembler.

High-Level Languages

A high-level language (HLL) is a programming language that enables a programmer to write programs that are more or less independent of a particular type of computer. Such languages are considered high-level because they are closer to human languages and further from machine languages. The high-level programming languages in active use today include Python, Visual Basic, Delphi, Perl, PHP, Ruby, C# and many others.

Models of Programming Languages

Procedural Language

The disadvantages of machine and assembly (low-level) languages led to the development of procedural languages in the late 1950s and 1960s. In a procedural language, the programmer writes instructions that tell the computer what to accomplish and how to do it.
With a procedural language, often called a third-generation language (3GL), a programmer uses a series of English-like words to write instructions. For example, ADD stands for addition or PRINT means to print. These English-like words and arithmetic symbols simplify the program development process for the programmer.
A procedural language is a type of computer programming language that specifies a series of well-structured steps and procedures within its programming context to compose a program. It contains a systematic order of statements, functions and commands to complete a computational task or program.
Procedural programming is based upon the concept of the procedure call. Procedures, also known as routines, subroutines, or functions, simply contain a series of computational steps to be carried out.
As with an assembly language program, the 3GL code (instructions) is called the source program. Programmers must convert this source program into machine language before the computer can execute the program. This translation process often is very complex, because one 3GL source program instruction translates into many machine language instructions. For 3GLs, programmers typically use either a compiler or an interpreter to perform the translation.
A compiler is a separate program that converts the entire source program into machine language before executing it. The machine language version that results from compiling the 3GL is called the object code or object program. The compiler stores the object code on storage media for execution later. A compiler translates an entire program before executing it. An interpreter, by contrast, translates and executes one statement at a time.
An interpreter reads a code statement, converts it to one or more machine language instructions, and then executes those machine language instructions. It does this all before moving to the next code statement in the program. Each time the source program runs, the interpreter translates and executes it, statement by statement. An interpreter does not produce an object program. Figure 11-16 shows the process of interpreting a program.
One advantage of an interpreter is that when it finds errors, it displays feedback immediately. The programmer can correct any errors before the interpreter translates the next line of code. The disadvantage is that interpreted programs do not run as fast as compiled programs.
Hundreds of procedural languages exist. Only a few, however, are used widely enough for the industry to recognize them as standards. These include C and COBOL.
The C programming language, developed in the early 1970s by Dennis Ritchie at Bell Laboratories, originally was designed for writing system software. Today, many programs are written in C (Figure 11-17). C runs on almost any type of computer with any operating system, but it is used most often with the UNIX and Linux operating systems.
COBOL COBOL (COmmon Business-Oriented Language) evolved out of a joint effort between the United States government, businesses, and major universities in the early 1960s. Naval officer Grace Hopper, a pioneer in computer programming, was a prime developer of COBOL. COBOL is a programming language designed for business applications.

Object Oriented Programming

Object-oriented programming (OOP) is a programming language model organized around objects rather than "actions" and data rather than logic. In OOPs programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure.
The focus of procedural programming is to break down a programming task into a collection of variables, data structures, and subroutines, whereas in object-oriented programming it is to break down a programming task into objects that expose behavior (methods) and data (members or attributes) using interfaces. The most important distinction is that while procedural programming uses procedures to operate on data structures, object-oriented programming bundles the two together, so an "object", which is an instance of a class, operates on its "own" data structure. The first major object-oriented programming language built from the ground up is Java in 1995.
Programmers use an object-oriented programming (OOP) language or object-oriented program development tool to implement objects in a program. An object is an item that can contain both data and the procedures that read or manipulate that data. An object represents a real person, place, event, or transaction.
A major benefit of OOP is the ability to reuse and modify existing objects. For example, once a programmer creates an Employee object, it is available for use by any other existing or future program. Thus, programmers repeatedly reuse existing objects. For example, the payroll program and health benefits program both use the Employee object. That is, the payroll program would use it to process employee paychecks and the health benefits program would use it to process health insurance payments.

Abstract Data Type (ADT)

Modern object-oriented languages, such as C++ and Java, support a form of abstract data types. When a class is used as a type, it is an abstract type that refers to a hidden representation. In this model an ADT is typically implemented as a class, and each instance of the ADT is usually an object of that class.
Formally, an ADT may be defined as a "class of objects whose logical behavior is defined by a set of values and a set of operations".

4GLs

A fourth-generation programming language (1970s-1990) (abbreviated 4GL) is a nonprocedural language that enables users and programmers to access data in a database. With a nonprocedural language, the programmer writes English-like instructions or interacts with a graphical environment to retrieve data from files or a database. Many object-oriented program development tools use 4GLs.
4GLs are designed with a specific purpose in mind, such as the development of commercial business software.
One popular 4GL is SQL. SQL is a query language that allows users to manage, update, and retrieve data in a relational DBMS (Figure).

Fourth-generation languages (4GLs), are closer to human language than other high-level languages and are accessible to people without formal training as programmers. They allow multiple common operations to be performed with a single command. They are intended to be easier for users than machine languages (first-generation), assembly languages (second-generation), and older high-level languages (third-generation).

Features and Abstraction

4GL's characterized as languages where you indicate what you want, and not how to get it? In the evolution of computing, the 4GL followed the 3GL in an upward trend toward higher abstraction and statement power. The 4GL was followed by efforts to define and use a 5GL.




Advantages of 4GLs

Sometimes 3GL are often more resource efficient and 4GL are often easier to program/maintain.   4GL can provide good solutions quickly.   4GL are at their best as report generators and database apps that will remain fairly static. 
A 4GL normally contains a utility software (tool) that interacts with the database management system (DBMS) software to store, manipulate and retrieve data needed to satisfy user requirements for information .
Advantages
  1. Programming productivity is increased. One line of 4GL code is equivalent to several lines of 3GL code.
  2. System development is faster.
  3. Program maintenance is easier.
  4. The finished system is more likely to be what the user envisaged, if a prototype is used and the user is involved throughout the development.
  5. End user can often develop their own applications.
  6. Programs developed in 4GLs are more portable than those developed in other generation of languages.
  7. Documentation is improved because many 4GLs are self documenting.
Disadvantages of 4GL –
  1. The programs developed in the 4GLs are executed at a slower speed by the CPU.
  2. The programs developed in these programming languages need more space in the memory of the computer system.


Unit 5 Programming Languages Unit 5 Programming Languages Reviewed by R S Rawat on November 19, 2019 Rating: 5

No comments:

Powered by Blogger.