cs 331, principles of programming languages chapter 1

10
CS 331, Principles of Programming Languages Chapter 1

Upload: theodore-shepherd

Post on 17-Jan-2016

215 views

Category:

Documents


0 download

TRANSCRIPT

  • CS 331, Principles of Programming LanguagesChapter 1

  • ObjectivesTo introduce several different paradigms of programmingTo gain experience with these paradigms by using example programming languagesTo understand concepts of syntax, translation, abstraction, and implementation

  • Paradigms of Programming?There are several ways to think about computation:set of instructions to be followedset of expressions to be evaluateda set of rules to be applieda set of objects to be rearrangeda set of messages to be sent and received

  • Some Programming ParadigmsProceduralexamples: C, Pascal, Basic, FortranFunctionalexamples: Lisp, MLObject-orientedexamples: C++, Java, SmalltalkRule-based (or Logic)example: Prolog

  • Why so many?Most important: the choice of paradigm (and therefore language) depends on how humans best think about the problemOther considerations:efficiencycompatibility with existing codeavailability of translators

  • Models of ComputationRAM machineproceduralDirected Acyclic GraphsSmalltalk model of O-Opartial recursive functionsLisp and MLMarkov algorithmsProlog is loosely based on these

  • Lots of LanguagesThere are many programming languages out thereLots of other PL-like objectsdocument languages, e.g. LaTeX, Postscriptcommand languages, e.g. csh, MATLABMarkup languages, e.g. HTML and XMLspecification languages, e.g. Z, UML

  • TranslationCompilationTranslate into instructions suitable for some other (lower level) machineDuring execution, that machine maintains program state informationInterpretationMay involve some translationInterpreter maintains program state

  • Trade-offsCompilationlower level machine may be faster, so programs run fastercompilation can be expensiveexamples: C (and Java?)Interpretationmore ability to perform diagnostics (or changes) at run-timeexamples: Basic, UNIX shells, Lisp

  • Web resourcesProgramming language researchhttp://www.cs.cmu.edu/afs/cs.cmu.edu/user/mleone/web/language-research.htmlFree compilers and interpretershttp://cuiwww.unige.ch/OSG/info/FreeComp/fc/categorie.html