1 / 18

Programming Language

Programming Language. อ.รัชดาพร คณาวงษ์ วิทยาการคอมพิวเตอร์ คณะวิทยาศาสตร์ มหาวิทยาลัยศิลปากร. 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. Over View.

jaxon
Download Presentation

Programming Language

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. 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 • Object-Oriented Programming • Logic 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 is 00000010101111001010 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 1 1 2 2 2 3 1 4 4 • 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 program : sequence of 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

  7. Example of RAM 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 • memory INPUT 0 0 1 27 OUTPUT 2 3 -27 n

  8. Instruction set of a RAM M[l] := n Put 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 I Next, execute instruction in location i if [j]≥0 If M[j] ≥ 0 then goto i Next, execute instruction in location i if M[j]≥0 Halt Stop 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 In 1973,The Unix operating system kernel was rewritten in the programming language C. • 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.

  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. (b) INTERPRET (a) COMPILE Application Level………. Language Level………… Source Program Program Interperter Target Code Machine Level………….. Machine Machine Language Implementation • Compiler • Once translation is complete:target code run later time called runtime. • Interpreter:directly run program

More Related