Com S 541 Lecture -*- Outline -*- * Computation models (Preface) i.e., the preface of Peter van Roy and Seif Haridi's book, "Concepts, Techniques, and Models of Computer Programming" (MIT Press, 2004), where all references that are not otherwise attributed are found. ** How to study programming languages? Q: How many languages are there? Thousands, probably tens of thousands... To study them may have to - pick a small sample, or - step back from the details Q: How would we pick what to study? Look at programming techniques that are useful, study programming models and computational models ** What is a paradigm or programming model? See Robert W. Floyd, The Paradigms of Programming, CACM 22(8):455-460, August, 1979. ------------------------------------------ PARAGIDM OR PROGRAMMING MODEL def: a *paradigm* or *programming model* is ------------------------------------------ ... a way to design, code, test/verify/reason a way to approach problems in design a way to *organize* programs (a style) a set of questions how to evaluate a design/program what makes a good/bad design/program built on a set of tools (the computation model) variables, procedures, while-loops, declarations, ... Q: How is a paradigm different from a pattern? ** What is a computational model? (Preface) ------------------------------------------ COMPUTATION MODEL def: a *computation model* is ------------------------------------------ ... "a formal system that defines how computations are done." (p. xiii) *** parts It has: - data (with operations, means of computation), - structuring mechanisms (means of combination), and - abstraction mechanisms (means of abstraction) *** presentation Explained in terms of a "simple core language called its kernel language". (p. xiv) New concepts are added to the kernel incrementally. Practical language extensions (sugars and abstractions) are explained by rewriting them into the kernel. Combinations are used to demonstrate various blends of programming techniques. ** overview *** differences Q: How are programming and competition models different? Q: How are programming languages different from programming models? Important not to confuse a programming model with a particular language, there is poetry and prose both in Italian and English But sometimes intertwined (e.g., harder to rhyme in English) *** tradtional view of programming paradigms ------------------------------------------ PROGRAMMING PARADIGMS !--------------------------------------! ! DECLARATIVE ! ! ! ! Logic Constraint ! ! ! ! CL ! ! ! !--------------------------------------! !--------------------------------------! ! ALGORITHMIC ! ! ! ! Imperative Higher-Order ! ! ! ! mostly- ! ! functional ! ! ! ! ! ! ! ! Object-based ! ! Applicative ! ! ! ! Object-oriented ! ! ! ! ! ! Aspect-oriented ! ! ! !--------------------------------------! ------------------------------------------ declarative = no statement of algorithm (differs from Hudak) logic = program is a logical theory + query horn clauses, unification constraint = program is list of constraints equations, constraint solving CL = constraint logic programming logical theory stated as constraints or constraints added to logic algorithmic = state algorithm imperative = program is sequence of changes to state (variables) assignment, while loops, etc. higher-order = program is building tools and applying them, or rule-based (somewhat equational) lambda abstraction procedures that takes procedures as args and return procedures as results (sometimes called functional) applicative = program is a set of rewrite rules, often build tools and then apply them no assignment (and no mutation), lambda abstraction Q: what problem motivates each style? Q: what languages are examples of each style? Examples: Declarative: OBJ3, SETL Logic: Prolog, \Prolog Constraint: Lotus 1-2-3 Constraint-Logic: CLP(R), Prolog III Algorithmic: CSP, GHC Imperative: FORTRAN, COBOL, BASIC, Algol 60, Algol 68, Pascal, C, PL/1 Object-based: Ada 83, CLU, Modula-2, Argus, SR, VisualBasic Object-oriented: Simula, Smalltalk, C++, Ada 95, Eiffel, Objective-C, Sather, ABCL/1, Emerald CLOS, Self, Cecil, Java, VB7 Aspect-oriented: AspectJ, HyperJ Higher-order: Applicative: SISAL, Miranda, Haskell Data-flow: Id Mostly-functional: Scheme, SML, CML, Lisp, Multilisp, APL Q: Where do languges like Python and Perl fit in? Q: How does concurrency fit in? Think about how to redraw this at the end of the semester. *** relationships between computation models (Appendix D) ------------------------------------------ GENERAL COMPUTATION MODEL (APPENDIX D) ______________________________________ |____________________________________| ||__________________________________|| ||| _______________________________||| ||||______________________________|||| |||||Declarative ||||| ||||| sequence, local, ||||| ||||| variable creation/binding||||| ||||| value creation ||||| |||||____________________________||||| |||| |||| |||| Declarative concurrent |||| |||| procedures, if, case, |||| |||| thread |||| |||| by-need synchronization |||| ||||______________________________|||| ||| ||| ||| Security ||| ||| name creation, ||| ||| read-only views ||| |||________________________________||| || || || Exceptions || || try/catch, raise, || || failed values || ||__________________________________|| | | | Explicit state | | cell creation, cell exchange,| | boundness test | |____________________________________| ------------------------------------------ This is the model of the language Oz. Others that we will study are based on it. ** goal Understanding the fundamental concepts of programming models and competition models is the goal. Secondary goal, ability to design programming abstractions (p. xvii-xviii)