Evolution of Programming Languages Generations of PLs.

Slides:



Advertisements
Similar presentations
Copyright © 2003 by Prentice Hall Computers: Tools for an Information Age Chapter 15 Programming and Languages: Telling the Computer What to Do.
Advertisements

MATH 224 – Discrete Mathematics
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
زبانهای برنامه سازی برنامه سازی پیشرفته ارائه دهنده دکتر سيد امين حسيني E.mail: Home page:
Lab6 – Debug Assembly Language Lab
2 We need programming languages to communicate with a computer. The two broad classifications of programming languages are: Low-level and High- level.
Overview of Programming Paradigms
COE Computer Organization & Assembly Language Introduction HLL vs. Assembly Programming Languages.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Computers: Tools for an Information Age
Chapter 16 Programming and Languages: Telling the Computer What to Do.
Introduction to a Programming Environment
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
CS 104 Introduction to Computer Science and Graphics Problems Software and Programming Language (2) Programming Languages 09/26/2008 Yang Song (Prepared.
SOFTWARE SYSTEMS SOFTWARE APPLICATIONS SOFTWARE PROGRAMMING LANGUAGES.
ALGORITHMS AND PROGRAMMING LANGUAGES Lecture 5: Algorithms and programming languages Networks and Communication Department 1.
1 Programming Languages Examples: C, Java, HTML, Haskell, Prolog, SAS Also known as formal languages Completely described and rigidly governed by formal.
Programming a computer. What does programming a computer mean ? Programming a computer: Since a computer can only execute machine instructions (encoded.
Introduction to Computer Programming
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
Programming Languages – Coding schemes used to write both systems and application software A programming language is an abstraction mechanism. It enables.
Programming Languages Generations
Programming Languages: Telling the Computers What to Do Chapter 16.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
AS Computing Introduction to Programming. What is a Computer Program? A list of instructions that a computer must work through, in a logical sequence,
Programming Language Rico Yu. Levels of Programming Languages 1.Low level languages 2.High level languages.
COMPUTER PROGRAMS AND LANGUAGES Chapter 4. Developing a computer program Programs are a set (series) of instructions Programmers determine The instructions.
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
CMPE13Cyrus Bazeghi 1 Programming Languages Telling computers what to do.
Chapter 6 Programming Languages. © 2005 Pearson Addison-Wesley. All rights reserved 6-2 Chapter 6: Programming Languages 6.1 Historical Perspective 6.2.
The Teacher Computing Computer Languages [Computing]
Computer Programs and Programming Languages What are low-level languages and high-level languages? High-level language Low-level language Machine-dependent.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
PROGRAMMING LANGUAGES
1 Text Reference: Warford. 2 Computer Architecture: The design of those aspects of a computer which are visible to the programmer. Architecture Organization.
Logical and Functional Programming
 Computer Languages Computer Languages  Machine Language Machine Language  Assembly Language Assembly Language  High Level Language High Level Language.
Machine Machine language is PL in which program instructions are written in strings of 0s and 1s.The computer circuitry is wired in a manner that it can.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Skill Area 311 Part B. Lecture Overview Assembly Code Assembler Format of Assembly Code Advantages Assembly Code Disadvantages Assembly Code High-Level.
GROUP 2 NAME :  AZMYLL BIN ARSHAD  (18DNS14F2014)  MARYAM JAMILAH BINTI RAHIM  (18ENS14F2004)  SURAYA BINTI MOHAMAD  (18DNS14F2005)  MUHAMMAD SALEH.
CSC141 Introduction to Computer Programming Programming Language.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Programming Languages
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Computer Language
Evolution and History of Programming Languages
Computer Languages [Computing] Computing.
Component 1.6.
Operating System Interface between a user and the computer hardware
CSCI-235 Micro-Computer Applications
Computer Programming.
Assembly Language Programming Part 3
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
C++ Programming: From Problem Analysis to Program Design
Programming Languages and Translators
Unit# 8: Introduction to Computer Programming
TRANSLATORS AND IDEs Key Revision Points.
Translators & Facilities of Languages
Computer Programming.
PROGRAMMING PARADIGMS
Principles of Programming Languages
Instructions.
Presentation transcript:

Evolution of Programming Languages Generations of PLs

First generation computers relied on machine language, the instructions of which are long strings of binary codes.

Generations of PLs 1GL – Machine language. String of 0’s and 1’s. Directly executed by CPU 2GL – Assembly language. Symbolic equivalent of machine language 3GL – Procedural language. Give how to do/ algorithm. E.g. Pascal 4GL – Declarative language. Specify what to do. E.g. SQL 5GL – Related to artificial intelligence

Low Level and High Level PLs Low Level PLs (1-2GLs) – Instructions directly operate computer hardware – Need to have machine level knowledge in order to write programs – Machine dependent – Machine language and assembly language High Level PLs (3-5 GLs) – More English like – Closer to human language

1 GL – Machine language A low level language Consists of strings of 0’s and 1’s Directly executed by the CPU Difficult and tedious to write and maintain Quickly replaced by assembly language (2GL)

2 GL – Assembly Language Instruction has a one-to-one correspondence with its machine language equivalent Instruction consists of opcode = operation code Action Memory Address, register or value e.g. ADD AX, 3 ; increase AX by 3 OpcodeOperand(s) Machine instructions are symbolized using mnemonics into assembly language instructions

A sample machine language program and the corresponding assembly language program

2 GL – Assembly Language A low level language Translated into machine language for execution Manipulate computer down to register level Hardware dependent Difficult to learn and debug Directly control of CPU operations, therefore the codes produce are more efficient

Extended Reading

Microsoft Windows DEBUG Textbook P.6 Act. 1 - Writing a real assembly language program General registers AX BX CX DX The 80x86 CPU has four general registers The accumulator AX stores the results of math operations. The base register BX stores the address or pointer. The counting register CX is used in counting and looping. The data register DX stores data.

Commands of DEBUG Command/ Prompt Operation -A prompt for accepting command rDisplay the contents of CPU registers. raxDisplay the contents of AX. :A prompt for accepting value to the register being worked with. aStart assembling (translating) symbolic instructions into machine codes. i.e. Start to accept assembly language program. tTrace the program. i.e. Execute the program and show the contents of the register. qQuit DEBUG.

A sample assembly language program explained Assembly InstructionExplanation mov ax, 5 Move the value 5 (hex) to register AX. mov bx, 3 Move the value 3 (hex) to register BX. add ax, bx Add the values stored in register AX and BX and the result back to register AX. int 20 Call the DOS interrupt 20 to terminate the program. Choose run > cmd to open the command prompt window Enter debug to the command prompt to run debug

Want to try it out yourself? P.6 Activity 1 Writing a simple assembly language program using DEBUG 5 minutes Typo in textbook P.8 Step 9: the first -t should be -r

3GLs (high level) Close to human language, more English like E.g. Pascal, FORTRAN, BASIC, COBOL, C,... Programmers can focus on solving problems rather than manipulating registers and memory addresses Easy to write, debug and maintain Loss of direct control of CPU operations and memory addresses Programs more portable (machine independent)

Assembly languagePascal 185B:0100 mov ax, 5 185B:0103 mov bx, 3 185B:0106 add ax, bx 185B:0108 int B:010A var a, b : integer; begin a := 5; b := 3; a := a + b end. The same program written in assembly language (2GL) and Pascal (3GL). The use of variables, data types and mathematical expression syntax in 3GL hides the complexities of CPU’s internal operations from the programmer.

4GLs Declarative / non-procedural Specify what to do/ not how to do In 3GLs, detail steps in solving a problem has to be coded, in 4GL fewer statements are necessary More towards solving specific problems - SQL to make queries on relational database - SPSS to perform data analysis

SQL statement for outputting the number of female students in each class from the database table student : SELECT class, COUNT(*) FROM student WHERE sex = "F" GROUP BY class;

5GLs Related to artificial intelligence (AI) Able to search for solution of the problem by itself Based on constraints and conditions given Programmers can focus on what problems need to be solved and what constraints and conditions are to be satisfied, rather then algorithm to solve the problem E.g. Prolog

Prolog (Program Logic) In Prolog, the program logic is represented by relations, and queries can be constructed and run on these relations. Relations are defined by clauses and there are two types of clauses: facts and rules

Facts in Prolog loves(peter, snacks). - a fact clause that defined the relation loves between two objects peter and snacks - note that a clause must end with a full stop - object names must be in lower case (upper-case is for variable) - the fact defined can be interpreted as ‘Peter loves snacks’ (not the other way round) The following 5 clauses define 5 facts: loves(peter, snacks). loves(peter, mary). loves(mary, fruit). loves(mary, snacks). loves(mary, tom).

Queries in Prolog loves(peter,tom). can be interpreted as ‘Does Peter love tom?’ loves(peter,X). can be interpreted as ‘What/ who does Peter love?’ loves(X,snacks). can be interpreted as ‘Who loves snacks?’ Notes: - X is in upper case to indicate that it is a variable - loves(peter,tom). can be a fact clause or a query, depend on usage

QueryResult loves(peter,tom).no loves(peter,X).X = snacks X = loves(X,snacks).X = Queries in Prolog Fill in the table based on the following facts: loves(peter, snacks). loves(peter, mary). loves(mary, fruit). loves(mary, snacks). loves(mary, tom). Peter mary

Rules in Prolog loves(peter, X) :- loves(mary, X). means Peter loves X if Mary loves X lovers(X, Y) :- loves(X, Y), loves(Y, X). means X and Y are lovers if X loves Y and Y loves X

Given the 5 facts and the rule loves(peter, snacks). loves(peter, mary). loves(mary, fruit). loves(mary, snacks). loves(mary, tom). loves(peter, X) :- loves(mary, X). The query loves(peter, X) returns X = snacks X = (and more...)

Given the 5 facts and the rule loves(peter, snacks). loves(peter, mary). loves(mary, fruit). loves(mary, snacks). loves(mary, tom). loves(peter, X) :- loves(mary, X). The query loves(peter, X) returns X = snacks X = mary X = fruit X = snacks X = tom

Given the 3 facts and the rule loves(tom, mary). loves(peter, mary). loves(mary, tom). lovers(X, Y) :- loves(X, Y), loves(Y,X). The query lovers(peter, mary). returns The query lovers(mary, tom). returns The query lovers(tom, mary). returns no true

Your turn now (P.15 Activity 2) Step1: Create a text file named loves.pl storing all the relations (facts and rules) Step2: Open GNU Prolog enter the command consult('s:/loves.pl'). Step3: Make queries

Generations of PLs 1GL – Machine language. String of 0’s and 1’s. Directly executed by CPU 2GL – Assembly language. Symbolic equivalent of machine language 3GL – Procedural language. Give how to do/ algorithm. E.g. Pascal 4GL – Declarative language. Specify what to do. E.g. SQL 5GL – Related to artificial intelligence. E.g. Prolog

Hierarchy of programming languages

Try it out with GNU Prolog Step1: Create a text file named loves.pl storing all the relations (facts and rules) Step2: Open GNU Prolog enter the command consult('s:/loves.pl'). Step3: Make queries Reminders: -don’t leave out the full stop -place loves.pl in your S drive ~ simpler path