Analysis of Programming Languages 1 Instructor Dr Tarek

  • Slides: 19
Download presentation
Analysis of Programming Languages (1)

Analysis of Programming Languages (1)

Instructor: Dr. Tarek Morad E-mail: hagras@gmail. com Textbook: Programming Languages Principles, & Paradigms Allen

Instructor: Dr. Tarek Morad E-mail: hagras@gmail. com Textbook: Programming Languages Principles, & Paradigms Allen B. Tucker, Robert E. Noonen (second edition - 2007) 2

PRINCIPLES OF LANGUAGE DESIGN o Programming languages have four properties: n n Syntax Names

PRINCIPLES OF LANGUAGE DESIGN o Programming languages have four properties: n n Syntax Names Types Semantics o For any language: n Its designers must define these properties n Its programmers must master these properties 3

Syntax o The syntax of a programming language is a precise description of all

Syntax o The syntax of a programming language is a precise description of all its grammatically correct programs. n Words and symbols n Programmar o Context-free grammar o A study of languages syntax raises many questions n How dose the compiler analyze the syntax of the program? n How are syntax error detected? n How does the context free grammar facilitate the development of syntactic analyzer? 4

Names o The vocabulary includes a carefully designed set of rules for naming entities

Names o The vocabulary includes a carefully designed set of rules for naming entities n Variables, function classes parameters o Named entities are bound in a running program to: n n Scope Visibility Type Lifetime 5

Types o Kinds of values that programs can manipulate n Simple types o numbers,

Types o Kinds of values that programs can manipulate n Simple types o numbers, characters, booleans, … n Structured types o Strings, lists, trees, hash tables, … n A language’s type system can help to: o Determine legal operations o Detect type errors 6

Semantics o Meaning of a program A study of languages semantics raises many questions

Semantics o Meaning of a program A study of languages semantics raises many questions o When a program is running, what happens to the values of the variables? o What does each statement mean? o How are objects allocated to memory at run -time? 7

PARADIGMS o Pattern of thought that guides a collection of related activities o There

PARADIGMS o Pattern of thought that guides a collection of related activities o There are four main programming paradigms: n n Imperative Object-oriented Functional Logic (declarative) 8

Imperative Paradigm o Follows the classic von Neumann-Eckert model: n Program and data are

Imperative Paradigm o Follows the classic von Neumann-Eckert model: n Program and data are indistinguishable in memory n Program = a sequence of commands n State = values of all variables when program runs n Large programs use procedural abstraction o Example imperative languages: n Cobol, Fortran, C, Ada, Perl, … 9

The von Neumann-Eckert Model 10

The von Neumann-Eckert Model 10

Object-oriented (OO) Paradigm o An OO Program is a collection of objects that interact

Object-oriented (OO) Paradigm o An OO Program is a collection of objects that interact by passing messages that transform the state. o Example OO languages: Java, C++, C#, and Python, Smalltalk, … 11

Functional Paradigm o Functional programming models a computation as a collection of mathematical functions.

Functional Paradigm o Functional programming models a computation as a collection of mathematical functions. n Input = domain n Output = range o Functional languages are characterized by: n Functional composition n Recursion o Example functional languages: n Lisp, Scheme, ML, Haskell, … 12

Logic Paradigm o Logic programming declares what outcome the program should accomplish, rather than

Logic Paradigm o Logic programming declares what outcome the program should accomplish, rather than how it should be accomplished. o When studying logic programming we see: n Programs as sets of constraints on a problem n Programs that achieve all possible solutions o Example logic programming languages: n Prolog 13

Special Topics o Event handling n E. g. , GUIs, home security systems o

Special Topics o Event handling n E. g. , GUIs, home security systems o Concurrency n E. g. , Client-server programs o Correctness n How can we prove that a program does what it is supposed to do under all circumstances? 14

Evolving of Programming Languages (1) o Science and Engineering n 1 st program in

Evolving of Programming Languages (1) o Science and Engineering n 1 st program in 1940 to predict the trajectories of ballistics during World War II n The major driving force is computational power n Current computing power: 280 teraflops n Fortran I (formula translator) 1954 o Disadvantage: the consistence n Algol (algorithmic language) 1959 o Better defined language than Fortran 15

Evolving of Programming Languages (2) o Computer Science Education n n Teaching Programming Basic

Evolving of Programming Languages (2) o Computer Science Education n n Teaching Programming Basic 1960 Pascal 1970 derivative of Algol C, C++ and Java n n Model human intelligent behavior Functional and logical programming Lisp is the 1 st AI language 1960 Scheme, ML, Haskell o Artificial Intelligence 16

Evolving of Programming Languages (3) o Information Systems n Managing Information Systems n Cobol

Evolving of Programming Languages (3) o Information Systems n Managing Information Systems n Cobol (COmmon Business Oriented Language ) 1950 o More wordy than comparable language n SQL (Structure Query Language) 1980 n Used for specifying and retrieving information form relational databases 17

Evolving of Programming Languages (4) o Systems and Networks o o o Basic software

Evolving of Programming Languages (4) o Systems and Networks o o o Basic software that runs systems Operating systems components Network software Compilers and Interpreters Virtual machines Embedded systems n Imperative languages o Close to machine language o C language o Supporting concurrent and event-driven 18

Evolving of Programming Languages (5) o World Wide Web n Internet is the most

Evolving of Programming Languages (5) o World Wide Web n Internet is the most dynamic area of programming n Event-driven and object-oriented programming n Visual Basic, Java, Python, Perl, … 19