CONCEPTS OF PROGRAMMING LANGUAGES Week 11 Session by Manesh T
Session Objective Introduction To Computer Program or Language Levels of Computer languages Language Processors Generations of Computer Programming Types of Programming Languages
What is a Programming Language? A set of rules or instrcutions A set of rules for converting an algorithm A language framework for describing computations Symbols, words, rules of grammar, rules of semantics Syntax and Semantics Algorithm Flowchart Programs
Levels of Programming Languages class Triangle { ... float surface() return b*h/2; } High-level Language LOAD r1,b LOAD r2,h MUL r1,r2 DIV r1,#2 RET Assembly Level Language 0001001001000101001001001110110010101101001... Machine level Language
Levels of Programming Languages-Cond
Programming Languages (cont’d) A Machine language program consists of a sequence of zeros and ones. Each kind of CPU has its own machine language. Advantages Fast and efficient Machine oriented No translation required Disadvantages Not portable Not programmer friendly
Assembly Language Assembly language programs use mnemonics to represent machine instructions Each statement in assembly language corresponds to one statement in machine language. Assembly language programs have the same advantages and disadvantages as machine language programs. Compare the following machine language and assembly language programs: 8086 Machine language program for var1 = var1 + var2 ; 8086 Assembly program for 1010 0001 0000 0000 0000 0000 0000 0011 0000 0110 0000 0000 0000 0010 1010 0011 0000 0000 0000 0000 MOV AX , var1 ADD AX , var2 MOV var1 , AX
High-Level Programming Languages A high-level language (HLL) has two primary components (1) a set of built-in language primitives and grammatical rules (2) a translator A HLL language program consists of English-like statements that are governed by a strict syntax. Advantages Portable or machine independent Programmer-friendly Disadvantages Not as efficient as low-level languages Need to be translated Examples : C, C++, Java, FORTRAN, Visual Basic, and Delphi.
Language processors Assembler Compiler Interpreter converting Assembly to machine High level language to machine language Line by line compilation Debugging is easy Debugging is faster Debugging is slow E.g,: TASM E.g. TC computer Eg: BASIC
Beyond Fifth Generation Languages Some talk about Agent Oriented Programming Aspect Oriented Programming Intentional Programming Natural language programming Maybe you will invent the next big language
Generations of Programming Languages First Generation Languages Machine 0000 0001 0110 1110 0100 0000 0001 0010 Second Generation Languag es Assembly LOAD x ADD R1 R2 Third Generation Languages High-level imperative/object oriented public Token scan ( ) { while (currentchar == ‘ ’ || currentchar == ‘\n’) {….} } Fourth Generation Languages Database select fname, lname from employee where department=‘Sales’ Fifth Generation Languages Functional Logic fact n = if n==0 then 1 uncle(X,Y) :- parent(Z,Y), brother(X,Z). else n*(fact n-1) Fortran, Pascal, Ada, C, C++, Java, C# SQL Prolog
Types of Programming Languages Procedural Programming Languages Structured Programming Languages Object-Oriented Programming Languages
Programming languages
Assembly Language- Features In this whole problem is solved as a single block. This is suitable only for small problem. Difficult to follow and correct errors Eg, Assembly Language, BASIC.
procedure Programming Features of procedure oriented Programming: Large Programs are divided in to small function or Procedure. Uses Top-Down programming Approach. Data moves freely from one function to another. Most of the functions share common data. Emphasis is given for algorithms. Disadvantages: Very difficult identify which data is used by which function. Error Correction is difficult. Example: C, Pascal
Structured Programming The program is divided into modules and the modules are then divided into functions. Each module can work independent of one another. Example: ADA, Prolog
Object oriented programming The Program is divided into number of small units called Object. The data and function are build around these objects. The data of the objects can be accessed only by the functions associated with that object. The functions of one object can access the functions of other object. Example: C++, Java
Object oriented programming
Object oriented programming
Features of object oriented Emphasis is given on data rather than procedures. Problems are divided into objects. Data structures are designed such that they organize the object. Data and function are tied together.
Possible Questions What are levels of Programming Languages? Illustrate difference between Assembler and Compiler What are features of Procedural Languages What are features of Structural Languages What are features of Object oriented Languages
Thank you! End of Presentation