Com S 541 Lecture -*- Outline -*- * paradigms of programming (styles) ** What is a paradigm? (in design/programming) how to go about design, coding, testing a way to approach problems in design a way to *organize* programs (a style) a set of tools variables, procedures, while-loops, declarations, ... a set of questions how to evaluate a design/program what makes a good/bad program Q: How is a paradigm different from a pattern? ** overview Q: are language and style separate things? important not to confuse a style with a language there is poetry and prose both in French and English but sometimes intertwined ------------------------------------------ PARADIGMS (Styles of Programming) !--------------------------------------! ! 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?