Presentation is loading. Please wait.

Presentation is loading. Please wait.

Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.

Similar presentations


Presentation on theme: "Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined."— Presentation transcript:

1 Theory of Programming Languages Introduction

2 What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined by “codes” stored in memory Assembly Languages –Mnemonics for the Instruction Codes –Low-level One instruction per operation –Machine-dependent

3 High-Level Languages Code abstractions allowed more readable and writeable programs –Assignments –Loops –Conditionals Machine – independent Retains the processor-model of computation Allows human to human communication

4 Definition A Programming Language is a notational system for describing computation in machine-readable and human-readable form

5 Computation Turing machine –Mathematical concept of a machine whose operation is simple enough to be described with great precision –Powerful enough to to perform any computation a computer can –Church’s Theorem: It is impossible to build a machine that is inherently more powerful than a Turing machine.

6 Computation (For our purposes) Any process which can be carried out by a computer We will concentrate on general-purpose languages that are designed to be used in general processing

7 Machine Readablilty Simple enough to allow efficient translation –There must be an algorithm to translate the language –This algorithm must not have too great a complexity –This is usually ensured by restricting the structure of the programming language to that of Context-free grammars (CFG’s)

8 Human Readability The language should allow abstractions of actions of the computer that are easy to understand –It should tend to resemble a natural language (English for us) For large programs, there must be suitable mechanisms for reducing the amount of detail required to understand the program as a whole

9 Abstractions in Programming Languages Data Abstraction –Abstract properties of the data Strings Trees Control Abstraction –Abstract properties of the transfer of control Loops Procedure calls (sort, search)

10 Data Abstractions Basic Abstractions –Abstract the internal representation of data values Variables and data types Structured Abstractions –Arrays and Records –Data Structures Unit Abstractions –Data encapsulation –Information hiding

11 Control Abstractions Basic Abstractions –Variable assignment –GOTO’s Structured Abstractions –Selection –Looping –Sub programs

12 Unit Abstractions Grouping a collection of related procedures into a unit whose inner workings do not need to be understood to understand the program –Ex: all I/O procedures –Ex: all statistical procedures (mean, mode, median, variance, etc)

13 Other Abstractions Parallel processing mechanisms –Threads –Processes –Tasks (Ada)

14 Computational Paradigms Imperative (Procedural) Programming Object-Oriented Programming Functional Programming Logic Programming Event-driven Programming Concurrent Programming

15 Imperative Programming Imperative programming is characterized by –Sequential execution of instructions –Use of variables representing memory locations –Use of assignment to change values of variables

16 Object-oriented Programming Three major topics of object-oriented programming –Polymorphism –Inheritance –Encapsulation Object –State –Behavior

17 Functional Programming Functional programming bases computation on evaluation of functions (or function applications) No notion of variables or assignment Repetitive operations are done by recursive functions (no notion of loops)

18 Logic Programming Logic programming is based on symbolic logic A logic program is a collection of declarations which are true about the desired result No notion of flow-of-control

19 Event-driven Programming Programming based on response to events The underlying system recognizes the events so there is no need for control-flow mechanisms except in response to events

20 Concurrent Programming Synchronization –Threads, for example

21 Language Definition Syntax –The structure of the language (grammar) –Notational systems for formal description BNF Syntax diagrams Semantics –The meaning of the language constructs –Notational systems for formal description Operational semantics Denotational semantics Axiomatic semantics

22 Language Translation For a programming language to be useful, it needs a translator –Interpreter A translator that executes a program directly –Compiler A translator that produces an equivalent program in a form suitable for execution

23 Interpretation source code inputinterpreter output

24 Compilation executable code processorinput output source code compile target code further translation executable code

25 Phases of translation Lexical analyzer (scanner) Syntax analyzer (parser) Semantic analyzer

26 Language Design Machine and human readability are overriding requirements Facilities for the natural expression of the structure of data Goal of abstraction is complexity control


Download ppt "Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined."

Similar presentations


Ads by Google