COMP313-11 Notes 1 ====================================================================== intro ====================================================================== self + my languages + you + goals + assignment + video what is a pl abstractions in pl computational paradigms language definition language translation language design ====================================================================== what is a pl ====================================================================== PL is a notational system for describing computation in machine-readable and in human-readable form 3 key concepts: - computation: turing machine (universal, (alonzo) church's hypothesis) turing-complete (general-purpose vs special-purpose, e.g SQL) - machine-readable: fast translation and interpretation, context-free languages - human-readable: communication, software engineering ====================================================================== abstractions in pl ====================================================================== data abstractions and control abstractions, at multiple levels bit patterns -> primitive types (int, double, ...) more structure: arrays, structs, objects, classes / abstract data types packages, modules, libraries control: basic statements and expressions: x = x+3; GOTO ... named variables IF/SWITCH, loops (FOR WHILE ...) functions procedures methods recursion threads/processes turing complete: integer variables + integer arithmetic execute sequence of statements, need assignment, selection (if) and looping (e.g. while) ====================================================================== computational paradigms ====================================================================== imperative/procedural vs. declarative (?) HOW vs. WHAT object-oriented: data+ops + inheritance functional: everything is an expression, i.e. has a value if strict then no side-effects ("mathematical" functions) turing complete: integer variables + arithmetic functions, plus define functions using existing functions, selection and recursion gcd x y = if y == 0 then x else gcd y (x `mod` y) logic, e.g.Prolog gcd(X,0,X). gcd(X,Y,Z) :- not(Y=0), U is X mod Y, gcd(Y,U,Z). also "style-question", can use functional style in oo, or write C-like Java, etc. ====================================================================== language definition ====================================================================== syntax + semantics : structure + meaning context-free grammars, e.g if statement like ::= if ( ) [ else ] semantics: ".. evaluate first, if it is not 0, then is executed, else (i.e. if is 0), then if present, is executed operational semantics, denotational semantics, axiomatic semantics "procedural" semantics == defined by an implementation ...??? ====================================================================== language translation ====================================================================== source -+ V input -> interpreter -> output [ source -> compiler -> "binary" ]+ executable code -+ V input -> cpu -> output ====================================================================== language design ====================================================================== data and control abstractions for "complexity control" efficiency readability productivity ====================================================================== questions ====================================================================== why have different loops (for/while/do-while ..., continue/break/return...) why some many turing-complete languages? ...