cs:3820 programming language conceptshomepage.cs.uiowa.edu/.../3820/fall16/notes/1-intro.pdf ·...
TRANSCRIPT
![Page 1: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/1.jpg)
CS:3820ProgrammingLanguageConcepts
Fall2016
IntroductionandOverview
Copyright 2016, Cesare Tinelli and others.Parts of these notes were originally developed by Allen Tucker, Robert Noonan and Peter Sestoft and are used with permission. They are copyrighted materials and may not be used in other course settings outside of the University of Iowa in their current form or modified form without the express written permission of one of the copyright holders. During this course, students are prohibited from selling notes to or being paid for taking notes by any person or commercial firm without the express written permission of one of the copyright holders.
![Page 2: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/2.jpg)
Distinguishingprogramminglanguagesproperties:– Syntax– Names– Types– Abstractions– Semantics
Foranylanguage:– Itsdesignersmustdefinetheseproperties– Itsprogrammersmustmastertheseproperties
1Principles
![Page 3: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/3.jpg)
Thesyntax ofaprogramminglanguageisaprecisedescriptionofallitsgrammaticallycorrectprograms
Whenstudyingsyntax,weaskquestionslike:– Whatisthegrammarforthelanguage?– Whatisthebasicvocabulary?– Howaresyntaxerrorsdetected?
Syntax
![Page 4: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/4.jpg)
Variouskindsofentitiesinaprogramhavenames:variables,types,functions,parameters,classes,objects,…
Namedentitiesareboundinarunningprogramto:– Scope– Visibility– Type– Lifetime
Names
![Page 5: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/5.jpg)
Atype isacollectionofvaluesandofoperationsonthosevalues
• Simpletypes– numbers,characters,Booleans,…
• Structuredtypes– Strings,lists,trees,hashtables,…
• Alanguage’stypesystem canhelp:– determinelegaloperations– detecttypeerrors– optimizecertainoperations
Types
![Page 6: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/6.jpg)
Mechanismsforgeneralizingcomputationsordata:– Procedures/functions– Modules– Abstractdatatypes– Classes– Memorymodels
Abstractions
![Page 7: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/7.jpg)
ThemeaningofaprogramiscalleditssemanticsInstudyingsemantics,weaskquestionslike:– Whenaprogramisrunning,whathappenstothevaluesofthevariables?
– Whatdoeseachconstructdo?– Whatunderlyingmodelgovernsrun-timebehavior,suchasfunctioncall?
– Howarevariablesandobjectsallocatedtomemoryatrun-time?
Semantics
![Page 8: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/8.jpg)
Aprogrammingparadigm isapatternofproblem-solvingthoughtthatunderliesaparticulargenreofprogramsandlanguages
Thereareseveralmainprogrammingparadigms:– Imperative– Object-oriented– Functional– Logic– Dataflow
} focus of this course
2Paradigms
![Page 9: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/9.jpg)
FollowstheclassicvonNeumann-Eckertmodel:– Programanddataareindistinguishableinmemory– Program=sequenceofcommandsmodifyingcurrentstate– State=valuesofallvariableswhenprogramruns– Largeprogramsuseproceduralabstraction
Exampleimperativelanguages:– Cobol,Fortran,C,Ada,Perl,…
ImperativeParadigm
![Page 10: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/10.jpg)
AnOOProgramisacollectionofobjectsthatinteractbypassingmessagesthattransformlocalstate
Majorfeatures:– EncapsulatedState– Messagepassing– Inheritance– SubtypePolymorphism
ExampleOOlanguages:Smalltalk,Java,C++,C#,Python,…
Object-oriented(OO)Paradigm
![Page 11: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/11.jpg)
Functionalprogrammingmodelsacomputationasacollectionofmathematicalfunctions– Input=domain– Output=range
Majorfeatures– Functionalcomposition– Recursion– Referentialtransparency
Examplefunctionallanguages:– Lisp,Scheme,ML,Haskell,F#,…
FunctionalParadigm
![Page 12: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/12.jpg)
Functionalprogrammingmodelsacomputationasacollectionofmathematicalfunctions– Input=domain– Output=range
Notablefeaturesofmodernfunctionallanguages:– Functionsasvalues– Symbolicdatatypes– Patternmatching– Sophisticatedtypesystemsandmodulesystems
FunctionalParadigm
![Page 13: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/13.jpg)
Logicprogrammingdeclareswhatoutcomeoftheprogramshouldbe,ratherthanhowitshouldbeachieved
Majorfeatures:– Programsassetsofconstraintsonaproblem– Computationofallpossiblesolutions– Nondeterministiccomputation
Examplelogicprogramminglanguages:– Prolog,Datalog
LogicParadigm
![Page 14: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/14.jpg)
Howandwhendidprogramminglanguagesevolve?
Whatcommunitieshavedevelopedandusedthem?– ArtificialIntelligence– ComputerScienceEducation– ScienceandEngineering– InformationSystems– SystemsandNetworks– WorldWideWeb– …
3ABriefHistory
![Page 15: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/15.jpg)
ML
SASL HASKELL
LISP
COBOL
VISUAL BASIC
GJ
JAVA
2000
C#
BASIC
CCPL BBCPL
FORTRAN77
BETA
2010
Java 5
C# 2 C# 4
STANDARD MLOCAMLCAML LIGHT
VB.NET 10
Go
F#
Scala
FORTRAN90
ADA ADA95 ADA2005
FORTRAN2003
FORTRAN
ALGOL
PASCAL
C++ALGOL 68
SIMULA
SMALLTALK
PROLOG
1956 1970 1980 19901960
SCHEME
LanguageGenealogy
![Page 16: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/16.jpg)
ML
SASL HASKELL
LISP
COBOL
VISUAL BASIC
GJ
JAVA
2000
C#
BASIC
CCPL BBCPL
FORTRAN77
BETA
2010
Java 5
C# 2 C# 4
STANDARD MLOCAMLCAML LIGHT
VB.NET 10
Go
F#
Scala
FORTRAN90
ADA ADA95 ADA2005
FORTRAN2003
FORTRAN
ALGOL
PASCAL
C++ALGOL 68
SIMULA
SMALLTALK
PROLOG
1956 1970 1980 19901960
SCHEME
LanguageGenealogyMostly
academic
Old mainstream
Modernmainstream
![Page 17: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/17.jpg)
DesignConstraints– Computerarchitecture– Technicalsetting– Standards– Legacysystems
DesignOutcomesandGoals
4OnLanguageDesign
![Page 18: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/18.jpg)
Keycharacteristics:– Simplicityandreadability– Reliability– Support– Abstraction– Orthogonality– Libraries– Efficientimplementation– Community
Whatmakesasuccessfullanguage?
![Page 19: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/19.jpg)
• Smallinstructionset– E.g.,JavavsScheme
• Simplesyntax– E.g.,C/C++/JavavsPython
• Benefits:– Easeoflearning– Easeofprogramming
SimplicityandReadability
![Page 20: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/20.jpg)
• Programbehavior isthesameondifferentplatforms• E.g.,earlyFortran,C
• Typeerrorsaredetected• E.g.,CvsHaskell
• Semanticerrorsareproperlytrapped• E.g.,CvsC++
• Memoryleaksareprevented• E.g.,CvsJava
Reliability
![Page 21: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/21.jpg)
• Accessible(publicdomain)compilers/interpreters• Goodtextsandtutorials• Widecommunityofusers• Integratedwithdevelopmentenvironments(IDEs)
LanguageSupport
![Page 22: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/22.jpg)
Alanguageisorthogonal ifitsfeaturesarebuiltuponasmall,mutuallyindependentsetofprimitiveoperations.
• Fewerexceptionalrules=conceptualsimplicity– E.g.,restrictingtypesofargumentstoafunction
• Tradeoffs withefficiency
Orthogonality
![Page 23: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/23.jpg)
• Embeddedsystems– Real-timeresponsiveness(e.g.,navigation)– FailuresofearlyAdaimplementations
• Webapplications– Responsivenesstousers(e.g.,Googlesearch)
• Corporatedatabaseapplications– Efficientsearchandupdating
• AIapplications– Modeling humanbehaviors
EfficiencyIssues
by the Trento people by the Trento people
![Page 24: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/24.jpg)
Compiler– producesmachinecodeInterpreter– executesinstructionsonavirtualmachine• Somecompiledlanguages:– Fortran,C,C++,Rust,Swift
• Someinterpretedlanguages:– Scheme,Python,Javascript
• Hybridcompilation/interpretation– JavaVirtualMachine(JVM)languages(Java,Scala,Clojure)– .NETlanguages(C#,F#)
5CompilersandInterpreters
![Page 25: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/25.jpg)
Compilation
![Page 26: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/26.jpg)
Interpretation
![Page 27: CS:3820 Programming Language Conceptshomepage.cs.uiowa.edu/.../3820/Fall16/notes/1-intro.pdf · 2016-08-26 · – Dataflow} focus of this course 2 Paradigms. ... – Responsiveness](https://reader033.vdocuments.net/reader033/viewer/2022050417/5f8d1850a7969b0c617ff869/html5/thumbnails/27.jpg)
• AbriefintrotofunctionalprogrammingwithF#• Lexicalanalysis,regularexpressions,finiteautomata,lexer generators• Syntaxanalysis,top-downversusbottom-upparsing,LLversusLR,
parsergenerators• Expressionevaluation,stackmachines,Postscript• CompilationofasubsetofCwith*p,&x,pointerarithmetic,arrays• Typechecking,typeinference,staticallyanddynamicallytyped
languages• ThemachinemodelofJava,C#,F#:stack,heap,garbagecollection• TheintermediatebytecodelanguagesoftheJavaVirtualMachine
and.NET• Garbagecollectiontechniques,dynamicmemorymanagement• Continuations,exceptions,alanguagewithbacktracking• Selectedadvancedtopics
27
6 CourseContents