Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programming Language อ. รัชดาพร คณาวงษ์ วิทยาการคอมพิวเตอร์ คณะ วิทยาศาสตร์ มหาวิทยาลัยศิลปากร.

Similar presentations


Presentation on theme: "Programming Language อ. รัชดาพร คณาวงษ์ วิทยาการคอมพิวเตอร์ คณะ วิทยาศาสตร์ มหาวิทยาลัยศิลปากร."— Presentation transcript:

1 Programming Language อ. รัชดาพร คณาวงษ์ วิทยาการคอมพิวเตอร์ คณะ วิทยาศาสตร์ มหาวิทยาลัยศิลปากร

2 What are PLs? A tool for instructing machine A way for communicating A notation of algorithms How to expressing concepts A mean for controlling computerized devices

3 Over View Machine language is unintelligible Assembly Language is low level Benefits of Higher-level Language A Role for Programming Languages Programming Paradigms Imperative Programming Imperative Programming Object-Oriented Programming Object-Oriented Programming Logic Programming Logic Programming Functional Programming Functional Programming

4 Machine Lauguage Native language of a computer Hard to understand for human Example 1.1 A code fragment of von Neumann machine is00000010101111001010 00000010111111001000 00000011001110101000 Its meaning is adding theh numbers in location 10 and 11 and stores the result in location 12.

5 Assembly Language A variant of Machine Language in which names and symbols take the place of the actual codes for machine operations, values, and storage locations, making individual instructions more readable. See Example 1.2 Reads a sequence of integers like Reads a sequence of integers like 1 1 2 2 2 3 1 4 4 Remove the same value adjacent and write out Remove the same value adjacent and write out 1 2 3 1 4

6 A random-access machine RAM:random-access machine It is consisted of 4 main components A memory : sequence of locations 0,1,2 A memory : sequence of locations 0,1,2 A program : sequence of instructions A program : sequence of instructions An input file : a sequence of values consumed at a time by read instructions An input file : a sequence of values consumed at a time by read instructions An output file : a sequence of values consumed at a time by write instructions An output file : a sequence of values consumed at a time by write instructions

7 Example of RAM memory 1: M[0] := 0 2: read(M[1]) 3: If M[1] ≥ 0 then goto 5 4: goto 7 5: M[3] := M[0] – M[1] 6: if M[3] ≥ 0 then goto 16 7: writeln(M[1]) 8: read(M[2]) 9: M[3] := M[2] – M[1] 10: if M[3] ≥ 0 then goto 12 11: goto 14 12: M[3] := M[1] – M[2] 13: if M[3] ≥ 0 then goto 8 14: M[1] := M[2] + M[0] 15: goto 3 16: halt 0 27 0 1 2 3 n -27 INPUT OUTPUT

8 Instruction set of a RAM M[l] := nPut integer n into location l. M[l] := M[j] + M[k]Put sum of values locations j & k into location l M[l] := M[j] - M[k]Put the difference of the values in j and k into l M[l] := M[M[j]]Let k = value in location j, In effect, M[l]=M[k] M[M[j]] := M[k]Let l = value in location i. In effect, M[l]=M[k] Read(M[l])Get next input value and put it into location l. Writeln(M[j])Produce value in location j as next output value Goto INext, execute instruction in location i if [j]≥0 If M[j] ≥ 0 then goto iNext, execute instruction in location i if M[j]≥0 HaltStop execution

9 Benefits of Higher-Level Language Readable familiar notations Machine independence Availability of program libraries Consistency checks during implementation that can detect errors

10 Example of High-Level Program New users and programs: many contributors do not know, and do not wish to learn, the instruction set of the machine Readability: more easily understood, repaired and modify. Portability: runs on several machines and whose expression in source code is except for a few modules, identical on each machine. In 1973,The Unix operating system kernel was rewritten in the programming language C.

11 Problems of Scale Programming Language can help in 2 ways. Readable Compact notation reduce the errors Human Error Factor Example: Due to a programming error, the rocket carrying Mariner I, an unmanned probe to the planet Venus, has to be destroyed 290 seconds after launch on July 22,1962. if not (in radar contact with the rocket) then do not correct its flight path

12 An evolutionary of earlier languages

13 Programmming Paradigms Imperative Programming Functional Programming Object-Oriented Programming Logic Programming

14 Imperative Programming Action oriented As a sequence of actions Original Language is Fortran Pascal and C are general-purpose imperative programming language

15 Functional Programming Originated with Lisp, a language designed in 1958 for applications in AI McCarthy et al [1965] explained Lisp as LISP is designed primitively for symbolic data processing. It has been used for symbolic calculations in differential and integral calculus, electrical circuit theory, mathematical logic, pame playing and other fields of AI

16 Object-Oriented Programming Simula’s origins in simulation. Kristen Nygaard and Ole-Johan Dahl [1961] Key concept is a class of objects C++ Smalltalk

17 Logic Programming Developed in 1972 for natural language processing in French by Alain Colmerauer and Philippe Roussel A specialized form of logical reasoning to answer such queries

18 Language Implementation Compiler Once translation is complete:target code run later time called runtime. Once translation is complete:target code run later time called runtime. Interpreter: directly run program (a) COMPILE (b) INTERPRET Application Level………. Language Level………… Machine Level………….. Source ProgramProgram Target Code Machine Interperter


Download ppt "Programming Language อ. รัชดาพร คณาวงษ์ วิทยาการคอมพิวเตอร์ คณะ วิทยาศาสตร์ มหาวิทยาลัยศิลปากร."

Similar presentations


Ads by Google