1 / 30

Evolution of Programming Languages

Evolution of Programming Languages. Generations of PLs. http://fahmirahman.wordpress.com/2011/01/04/five-generations-of-computer/. First generation computers relied on machine language, the instructions of which are long strings of binary codes. Generations of PLs. 1GL – Machine language

gibson
Télécharger la présentation

Evolution of Programming Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Evolution of Programming Languages Generations of PLs

  2. http://fahmirahman.wordpress.com/2011/01/04/five-generations-of-computer/http://fahmirahman.wordpress.com/2011/01/04/five-generations-of-computer/ First generation computers relied on machine language, the instructions of which are long strings of binary codes.

  3. 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

  4. 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

  5. 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)

  6. 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 • Machine instructions are symbolized using mnemonics into assembly language instructions

  7. A sample machine language program and the corresponding assembly language program

  8. 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

  9. Extended Reading

  10. Microsoft Windows DEBUG Textbook P.6 Act. 1 - Writing a real assembly language program General registers 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.

  11. Commands of DEBUG

  12. A sample assembly language program explained Choose run > cmd to open the command prompt window Enter debug to the command prompt to run debug

  13. 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

  14. 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)

  15. 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.

  16. 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

  17. 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;

  18. 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

  19. 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

  20. 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).

  21. 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

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

  23. 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

  24. 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 ...)

  25. 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

  26. 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 true

  27. 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

  28. 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

  29. Hierarchy of programming languages

  30. 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

More Related