CONCEPTS OF PROGRAMMING LANGUAGES Week 11 Session by Manesh T SESSION OBJECTIVE 1. Introduction To Computer Program or Language 2. Levels of Computer languages 3. Language Processors 4. Generations of Computer Programming 5. 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 3 LEVELS OF PROGRAMMING LANGUAGES High-level Language class Triangle { ... float surface() return b*h/2; } Assembly Level Language LOAD r1,b LOAD r2,h MUL r1,r2 DIV r1,#2 RET Machine level Language 0001001001000101001001 001110110010101101001. .. 4 LEVELS OF PROGRAMMING LANGUAGESCOND 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 var1 = var1 + var2 ; 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 E.g,: TASM Debugging is Debugging is faster slow 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 10 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’) {….} } Fortran, Pascal, Ada, C, C++, Java, C# Fourth Generation Languages Database select fname, lname from employee where department=‘Sales’ SQL Fifth Generation Languages Functional Logic fact n = if n==0 then 1 else n*(fact n-1) uncle(X,Y) :- parent(Z,Y), brother(X,Z). Prolog 11 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 1. The program is divided into modules and the modules are then divided into functions. 2. Each module can work independent of one another. Example: ADA, Prolog OBJECT ORIENTED PROGRAMMING 1. The Program is divided into number of small units called Object. The data and function are build around these objects. 2. The data of the objects can be accessed only by the functions associated with that object. 3. 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 Features: 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