Quick Language Tour
description
Transcript of Quick Language Tour
Quick Language TourQuick Language Tour
Languages we did not look atLanguages we did not look atWith a quick survey of what is With a quick survey of what is
interesting about each oneinteresting about each one
FORTRANFORTRANThe earliest algorithmic language The earliest algorithmic language
(50’s)(50’s) Invented the idea of a*b+c*dInvented the idea of a*b+c*dMulti-dimensional arraysMulti-dimensional arraysSubprograms (but no recursion)Subprograms (but no recursion)Separate and independent compilationSeparate and independent compilationControl structures depend heavily on Control structures depend heavily on
gotogoto
FORTRAN, an oddityFORTRAN, an oddityOne oddity in Fortran, no separation One oddity in Fortran, no separation
between tokens, blanks ignoredbetween tokens, blanks ignoredFollowing are equivalentFollowing are equivalent
DO 10 I = 1,100DO 10 I = 1,100DO10I=1,100DO10I=1,100
More diabolicalMore diabolicalDO10I = 1.10DO10I = 1.10
DO 10 I = 1.10DO 10 I = 1.10
FORTRAN, later historyFORTRAN, later history FORTRAN-66FORTRAN-66
First standardized versionFirst standardized version Fortran-77Fortran-77
Updated, but no very major changesUpdated, but no very major changes Fortran-90Fortran-90
Big language with lots of extensionsBig language with lots of extensions Including comprehensive aggregates and Including comprehensive aggregates and
slicing notations.slicing notations. HPF (high performance Fortran)HPF (high performance Fortran)
Parallelization constructsParallelization constructs
Algol-60Algol-60European contemporary of FortranEuropean contemporary of Fortran
A bit laterA bit laterDesigned then implementedDesigned then implemented
Algol-60 reportAlgol-60 reportFeaturesFeatures
Structured programming (if, loop)Structured programming (if, loop)Beginnings of a type systemBeginnings of a type systemRecursive proceduresRecursive proceduresI/O etc provided by library proceduresI/O etc provided by library procedures
Algol-60 Call by NameAlgol-60 Call by NameCall by name means that an Call by name means that an
expression is passed and then expression is passed and then evaluated with current values of evaluated with current values of variables when referenced.variables when referenced.
Jensen’s deviceJensen’s deviceSum (j*j + 1, j, 1, 10)Sum (j*j + 1, j, 1, 10)Means sum j*j+1 for j from 1 to 10Means sum j*j+1 for j from 1 to 10Can even call Sum recursivelyCan even call Sum recursively
Sum (sum (j*k+j+j, j, 1, 10), k, 2, 100)Sum (sum (j*k+j+j, j, 1, 10), k, 2, 100)
Algol-60 Call by NameAlgol-60 Call by NameHere is how sum is codedHere is how sum is coded
real procedure sum (x, i, from, to);real procedure sum (x, i, from, to); integer x, i integer x, i integer from, to; integer from, to;beginbegin integer s; integer s; s := 0; s := 0; for i := from step 1 until to do for i := from step 1 until to do s := s + x; s := s + x; sum := s; sum := s; end end
LISPLISPLISP is quite early, developed during LISP is quite early, developed during
60’s60’s InventedInvented
Functional programmingFunctional programmingUse of lambda formsUse of lambda formsHigher order functionsHigher order functionsListsListsGarbage collectionGarbage collection
Pretty much what scheme is todayPretty much what scheme is today
LISP grew up on the IBM LISP grew up on the IBM 709(0)709(0)
This machine had 36 bit wordsThis machine had 36 bit wordsDivided into prefix/CDR/index/CARDivided into prefix/CDR/index/CAR
CDR and CAR could hold pointersCDR and CAR could hold pointersSo why is CAR the first of the listSo why is CAR the first of the list
Because in the assembly language, the Because in the assembly language, the CAR field was given as the first operand, CAR field was given as the first operand, and the CDR as the secondand the CDR as the second
CAR = CAR = CContents of the ontents of the AAddress ddress RRegisteregisterCDR = CDR = CContents of the ontents of the DDecrement ecrement RRegisteregister
LISP has dynamic scopingLISP has dynamic scoping In a block structured language like In a block structured language like
Pascal, if you reference a non-local Pascal, if you reference a non-local variable, you get the statically variable, you get the statically enclosing one.enclosing one.
With dynamic scoping, you get the With dynamic scoping, you get the most recently declared one whether most recently declared one whether or not you are statically enclosed in or not you are statically enclosed in its scopeits scope
Lisp, Dynamic ScopingLisp, Dynamic ScopingDefine a function f with a parameter Define a function f with a parameter
xxf calls separate function g (not f calls separate function g (not
nested)nested)g has no x declared but references xg has no x declared but references x It gets the x that is the parameter It gets the x that is the parameter
value passed to fvalue passed to f
COBOLCOBOLAnother early language (late 50’s)Another early language (late 50’s)Designed for information processingDesigned for information processing Important featuresImportant features
Scaled decimal arithmetic, 18 digitsScaled decimal arithmetic, 18 digitsDynamic binding (at runtime) for Dynamic binding (at runtime) for
subroutinessubroutinesCan add new subroutines at runtimeCan add new subroutines at runtimeCALL string-expression USING parametersCALL string-expression USING parameters
String-expression is evaluated at run timeString-expression is evaluated at run time
COBOLCOBOL Uses english language flavorUses english language flavor
Idea: managers can read code (a bit bogus)Idea: managers can read code (a bit bogus) ExampleExample
PROCESS-BALANCE.PROCESS-BALANCE. IF BALANCE IS NEGATIVE IF BALANCE IS NEGATIVE PERFORM SEND-BILL PERFORM SEND-BILL ELSE ELSE PERFORM RECORD-CREDIT PERFORM RECORD-CREDIT END-IF. END-IF.SEND-BILL.SEND-BILL. … …RECORD-CREDIT.RECORD-CREDIT. … …
COBOL, A horrible featureCOBOL, A horrible featurePARA.PARA.
GOTO .GOTO .……ALTER PARA TO PROCEED TO LABEL-1ALTER PARA TO PROCEED TO LABEL-1
UGH!UGH!Copied from machine code for 1401Copied from machine code for 1401
ANSI committed tried to remove thisANSI committed tried to remove thisWere threatened with multiple law suitsWere threatened with multiple law suitsSo it is still there So it is still there
COBOL High Level FeaturesCOBOL High Level FeaturesBuilt in indexed files with multiple Built in indexed files with multiple
indexesindexesBuilt in high level functionsBuilt in high level functions
Search and replace stringsSearch and replace stringsSortSortEditEdit
Uses picturesUses picturesPIC ZZZ,ZZ9.99PIC ZZZ,ZZ9.99If you move 1234.56 to above field you getIf you move 1234.56 to above field you get 1,234.56 (with two leading blanks)1,234.56 (with two leading blanks)
COBOL HistoryCOBOL HistoryCOBOL-66 First standardCOBOL-66 First standardCOBOL-74 upgrade, nothing too majorCOBOL-74 upgrade, nothing too majorCOBOL-91 full structured programmingCOBOL-91 full structured programmingLatest COBOL (date?)Latest COBOL (date?)
Full very elaborate object oriented stuffFull very elaborate object oriented stuffStill very widely usedStill very widely used
Particularly on mainframesParticularly on mainframesMainframes are still widely used!Mainframes are still widely used!
PL/1PL/1 Systematic attempt by IBM to combine the Systematic attempt by IBM to combine the
ideas inideas in FortranFortran COBOLCOBOL Algol-60Algol-60 Also added concurrency (a la IBM mainframe OS)Also added concurrency (a la IBM mainframe OS)
Not very successful, but still usedNot very successful, but still used Widely derided as kitchen sink, committee Widely derided as kitchen sink, committee
workwork PL/1 is not as bad as its reputationPL/1 is not as bad as its reputation Hurt badly by poor performance of compilersHurt badly by poor performance of compilers
Algol DevelopmentsAlgol Developments Algol-X, Algol-Y, Algol-WAlgol-X, Algol-Y, Algol-W
Variants adding various features including notably Variants adding various features including notably records.records.
Burroughs built Algol machines and used only Burroughs built Algol machines and used only Algol for all work (no assembler!)Algol for all work (no assembler!)
JOVIALJOVIAL JJules ules OOwn wn VVersion of the ersion of the IInternational nternational ALALgoritmic Languagegoritmic Language Widely used by DoD (still used in some projects)Widely used by DoD (still used in some projects)
Algol-68Algol-68 Major updateMajor update
Algol-68Algol-68Designed by distinguished committeeDesigned by distinguished committeeUnder auspices of IFIP WG2.1Under auspices of IFIP WG2.1
First comprehensive type systemFirst comprehensive type systemGarbage collection requiredGarbage collection requiredFull pointer semanticsFull pointer semanticsIncludes simple tasking facilitiesIncludes simple tasking facilities
Used in the UK, but not really successfulUsed in the UK, but not really successfulLack of compilersLack of compilersBuilding compilers was a really hard taskBuilding compilers was a really hard task
Algol-68 ModulesAlgol-68 ModulesAn interesting addition to Algol-60An interesting addition to Algol-60Module facilityModule facilityFirst comprehensive attempt at First comprehensive attempt at
separate compilation semanticsseparate compilation semantics Influenced later languages including Influenced later languages including
AdaAda
Algol-68 ReactionsAlgol-68 ReactionsSeveral important people thought Several important people thought
Algol-68 had got far too complex, Algol-68 had got far too complex, voted against publication, lost vote, voted against publication, lost vote, and stormed outand stormed outWirthWirthHoareHoareDjikstraDjikstraPer Brinch Hansen (sp?)Per Brinch Hansen (sp?)And several othersAnd several others
PascalPascalDesigned by Wirth as a reaction to Designed by Wirth as a reaction to
A68A68Retained reasonably comprehensive Retained reasonably comprehensive
type systemtype systemPointers, records, but only fixed length Pointers, records, but only fixed length
arraysarraysEmphasis on simplicityEmphasis on simplicityWidely used for teachingWidely used for teaching
Pascal follow onsPascal follow onsBorland picked up PascalBorland picked up PascalAnd developed it into a powerful And developed it into a powerful
languagelanguageThis is the language of Delphi, added:This is the language of Delphi, added:
ModulesModulesString handlingString handlingObject oriented facilitiesObject oriented facilities
Still in use (e.g. MTA)Still in use (e.g. MTA)
Simula-67Simula-67Another Algol developmentAnother Algol developmentFirst object oriented languageFirst object oriented languageObjects are concurrent tasksObjects are concurrent tasksSo message passing involves So message passing involves
synchronizationsynchronizationWidely used in Europe in the 70’sWidely used in Europe in the 70’s
Another thread, BCPLAnother thread, BCPLBCPL is a low level languageBCPL is a low level languageSimple recursive syntaxSimple recursive syntaxBut weakly typedBut weakly typedReally has only bit string typeReally has only bit string typeQuite popular in the UKQuite popular in the UK
B came from BCPLB came from BCPLDon’t know much about thisDon’t know much about thisSeems to have disappeared into the Seems to have disappeared into the
mists of time mists of time Important only for the next slideImportant only for the next slide
C, partly inspired by BC, partly inspired by BAn attempt to create a nice simple An attempt to create a nice simple
languagelanguagePowerfulPowerfulBut easy to compileBut easy to compileFormed the basis of UnixFormed the basis of Unix32 users simultaneously using C and 32 users simultaneously using C and
Unix on a PDP-11 (equivalent in Unix on a PDP-11 (equivalent in power to a very early 5MHz PC, with power to a very early 5MHz PC, with 128K bytes memory!)128K bytes memory!)
C++C++C catches the complexity bug C catches the complexity bug AddsAdds
AbstractionAbstractionComprehensive type systemComprehensive type systemObject oriented featuresObject oriented featuresLarge library, including STLLarge library, including STL
EiffelEiffelPure object oriented languagePure object oriented language In the Pascal traditionIn the Pascal traditionEmphasizes Programming-By-Emphasizes Programming-By-
Contract ™Contract ™The idea is to include assertions that The idea is to include assertions that
illuminate the code, and form the basis illuminate the code, and form the basis of proof by correctnessof proof by correctness
Code is correct if the implementation Code is correct if the implementation conforms to the contractconforms to the contract
AdaAdaA reaction to the multiplicity of A reaction to the multiplicity of
languages used by the DoD in the languages used by the DoD in the 70’s (over 500)70’s (over 500)
Emphasis on life cycle maintainabilityEmphasis on life cycle maintainabilityEmphasis on safetyEmphasis on safetyComprehensive semantics including Comprehensive semantics including
exceptions and high level taskingexceptions and high level taskingFirst standard in 1983First standard in 1983
Ada-95Ada-95Major update, additions includeMajor update, additions include
Full object oriented featuresFull object oriented featuresProtected record semanticsProtected record semanticsSubprogram pointersSubprogram pointersHierarchical librariesHierarchical librariesStandard libraryStandard libraryMany other small featuresMany other small features
Interpreted LanguagesInterpreted LanguagesUCSD PascalUCSD Pascal
First language to use a byte code First language to use a byte code interpretorinterpretor
Widely implemented on many machinesWidely implemented on many machinesLots of applications that could run Lots of applications that could run
anywhereanywhereWidely used commerciallyWidely used commerciallyDied because of transition to PCDied because of transition to PC
Which it did not make successfullyWhich it did not make successfully
JavaJavaAn attempt to simplify C++An attempt to simplify C++Emphasis on safetyEmphasis on safetyPortability via byte code interpretorPortability via byte code interpretorAggressive object oriented viewpointAggressive object oriented viewpointClosely related to JVM, derived from Closely related to JVM, derived from
JavaJavaNot standardized, single vendor Not standardized, single vendor
languagelanguage
C#C#Designed by MicrosoftDesigned by MicrosoftSimilar goals to Java, butSimilar goals to Java, but
Design virtual machine (.NET) firstDesign virtual machine (.NET) firstThen derive corresponding languageThen derive corresponding languageObject orientedObject orientedCleans up CCleans up C
Garbage collectionGarbage collectionFull type safetyFull type safety
C# continuedC# continuedVery similar to JavaVery similar to JavaBut tries to be closer to C and C++But tries to be closer to C and C++
For example, overloading is retainedFor example, overloading is retainedFull interface to COM (what a surprise Full interface to COM (what a surprise
))A nice comparison of C# and Java is atA nice comparison of C# and Java is at
http://www.csharphelp.com/archives/http://www.csharphelp.com/archives/archive96.htmlarchive96.html
Very High Level LanguagesVery High Level LanguagesAnother thread entirelyAnother thread entirelyLanguages with high level semantics Languages with high level semantics
and data structuresand data structures
String Processing LanguagesString Processing LanguagesLanguages where strings are first Languages where strings are first
class citizens (intended for language class citizens (intended for language processing etc)processing etc)COMMIT (language translation project at COMMIT (language translation project at
University of Chicago)University of Chicago)SNOBOL and SNOBOL3 (Bell Labs)SNOBOL and SNOBOL3 (Bell Labs)SNOBOL4SNOBOL4
Comprehensive pattern matchingComprehensive pattern matchingICONICON
Particularly develops notion of back trackingParticularly develops notion of back tracking
SETLSETLA language designed in the 70’sA language designed in the 70’sBased on ZF Set theoryBased on ZF Set theory
Here is printing of primes up to 100Here is printing of primes up to 100Print ( {x in 2 .. 100 |Print ( {x in 2 .. 100 |
notexists d in 2 .. X-1 | notexists d in 2 .. X-1 | x mod d = 0} ) x mod d = 0} )
Notexists here should use nice math Notexists here should use nice math symbol!symbol!
General mappings and setsGeneral mappings and sets
Functional LanguagesFunctional LanguagesMIRANDAMIRANDA
Introduced notion of lazy evaluationIntroduced notion of lazy evaluationDon’t evaluate something till neededDon’t evaluate something till neededProvides pure referential transparencyProvides pure referential transparencySuppose we haveSuppose we have
define f (x, y) = ydefine f (x, y) = yCan replace f (expr1, expr2) by expr2Can replace f (expr1, expr2) by expr2Even if computing expr1 would cause infinite Even if computing expr1 would cause infinite
loop with strict semantics (strict as opposted loop with strict semantics (strict as opposted to lazy)to lazy)
HASKELHASKELComprehensive attempt at defining Comprehensive attempt at defining
modern usable functional languagemodern usable functional languageUses more familiar syntax (not so Uses more familiar syntax (not so
reliant on parens reliant on parens ))Has lazy evaluationHas lazy evaluationAnd large library of stuffAnd large library of stuff