Presentation on theme: "Evolution of PLs We can extend this timeline as follows:"— Presentation transcript:
1 Evolution of PLs We can extend this timeline as follows: 2001: AspectJ (from Java, an Aspect oriented language)2001: D (although based on C++, it borrows features found in Java, C# and Eiffel, it is a systems programming language)2001: Joy (a purely functional language like Haskell but with no formal parameters)2004: Groovy (from Java, a scripting language with features similar to Python, Perl, Ruby)2005: F# (a language to be used in .net, functional based on Haskell)2007: Ada 2005 (follow-up from Ada 95)
2 Toward High Level Languages Machine language was difficultFloating point hardware was not yet available (1950s)FP operations were performed as a series of integer operationstime consumingPseudocode short cuts were developedA single FP operation would be translated by the interpreter at run-time into integer machine operations saving the programmer from having to write all the int operationsSimilarly, short codes developed on some architecturesAssembly language was the next logical step in the mid 1950sThe idea of translating from a short code, pseudocode or mnemonic into machine code gives rise to the next idea: compilingYou have to realize during the 1950s that computers were not very reliable. Early computers, made of vacuum tubes, would fail if execution time was more than a couple of minutes (vacuum tubes would burn out during execution!)There was little need to use machine translators because programs were short and because there was little to gain in terms of execution speed.However, as computer technology progressed, substitution mechanisms were derived as listed on this slide. Short codes were used to substitute numeric codes for arithmetic operations, variable names and parens (see page 42)
3 Birth of FORTRAN IBM 704 had greater capabilities including FP ops This, combined with the success of pseudocodes, led some programmers to believe that a greater compilation technique could make programmer even easierFORTRAN – FORmula TRANslator was developedPlans announced in 1954Compiler would translate mathematical formulas (assignment statements) into machine languagethere would also be simple control and I/O statementsThe language would operate on Integer and Floating Pt datacompiler would produce machine code as efficient as any code produced by humans (controversial, disbelieved by most programmers)the compiler could also discover coding (syntax) errors and report themFORTRAN 0 was published to report on the language, but never implementedMost programmers in the 1950s felt that machine translation was not possible and if it was possible, it would either yield code that would have errors or inefficient code. FORTRAN proved the doubters were wrong and of course revolutionized computer programmer. Whether you’ve ever programmed in machine language, be thankful for this development.The original idea behind FORTRAN was that a program would be a list ofInput statementsMathematical formulae (to compute values)Output statementsAlong with some rudimentary control to have loops and selectionsSo FORTRAN is not really far above the level of machine language with the exception of the ability to write mathematical formulae in a mathematical-like notation.
4 Early FORTRAN Implementations FORTRAN I released April 57, included:I/O FormattingVariable name lengths up to 6 charactersimplicit data typing by variable name (I..N names are ints, all others are floating point)Control constructsuser-defined subroutinesearly IF stmt: IF <expr> N1, N2, N3iterative stmt: Do N1 var = first, last (post-test loop)FORTRAN II released Spring 58Fixed many of the bugs from FORTRAN IAdded independent compilation of subroutineswithout this, changes to the program required recompilation of all limiting program sizes due to the unreliable nature of early computers!this would lead to the development of longer programs and library routinesFORTRAN IV released 1962One of the most popular programming languages up until FORTRAN 77Explicit and implicit type declarationsLogical If stmtPassing subroutine names as parametersOne problem with FORTRAN was that there was no delimiter so that there could be no if-else or nested if statements. Instead, they offered the truly perverse numeric IF statementIF <expr> N1, N2, N3This means if <expr> < 0 then GO TO N1, if <expr> = 0 then GO TO N2, if <expr> > 0 then GO TO N3. This is easy to implement on top of machine language which would essentially perform <expr> and then test the negative flag, zero flag and positive flag and use a conditional branch.The FORTRAN IV If statement expects only a single operation, usually a GO TO statement. You could build an If-Else or nested If-Else by using several IF and GO TO statements.IF A.GT. B THEN GO TO 10 // 10 is the if clauseIF A.LE.B THEN GO TO 20 // 20 is the else clause
5 FORTRAN 77 - 95 FORTRAN 77 (1977-1990) FORTRAN 90 FORTRAN 95 Character string handlingLogical loopsIf-then-elseFORTRAN 90Built-in array operations and dynamic arraysRecordsPointersModules for data structure encapsulation and information hidingRecursive subprograms and keyword parametersType checking of parametersCASE stmt, EXIT statement, CYCLE statementFORTRAN 95Forall statementFORTRAN 95 removed many old items (assigned and compute GOTO statements, arithmetic IF statement)FORTRAN 77 finally brought FORTRAN up to date with languages like C and Pascal, but still did not have recursion, records or pointers. These would all wait for FORTRAN 90, by which time almost no one used FORTRAN! We will discuss why recursion was not possible in FORTRAN when we reach chapter 10.
6 FORTRAN I and 90 Examples Program Example INTEGER LIST(99) Implicit noneInteger :: Int_List(99)Integer :: List_Len, Counter, Sum, Average, ResultResult = 0Sum = 0Read *, List_LenIf ((List_Len > 0) .AND. (List_Len < 100)) ThenDo Counter = 1, List_LenRead *, Int_List(Counter)Sum = Sum + Int_List(Counter)End DoAverage = Sum / List_LenIf (Int_List(Counter) > Average) ThenResult = Result + 1End IfPrint *, ‘Values > Average is: ’, ResultElsePrint *, ‘List length value not legal’End Program ExampleINTEGER LIST(99)ISUM = 0IRES = 0IAVG = 0Read *, ILENIf (ILEN) 50, 50, 1010 If (ILEN – 100) 20, 50, 5020 Do 30 I = 1, ILENRead *, LIST(I)ISUM = ISUM + LIST(I)30 ContinueIAVG = ISUM / ILENDo 40 I = 1, ILENIf (LIST (I) .GT. IAVG) ThenIRES = IRES + 1End If40 ContinuePrint *, ‘Values > Average is: ’, IRESGO TO 6050 Print *, ‘List length value not legal’60 ContinueEnd
7 COBOLDept. of Defense promoted non-mathematical language for business use, more “English-like”FORTRAN not suitable for business because of poor compilation, variables names were too small, no records or string typesIBM began work on a business version of FORTRAN called COMTRAN but COBOL would be implemented insteadCOBOL would supportOpening and closing of data filesTransfer of recordsFormatted I/OEasy to use (even at the expense of being less powerful)Read like EnglishCOBOL would alsoHave a construct for MacrosHierarchical data structures (e.g., nested structs/records)Variable names of up to 30 characters (using – to connect words as in FIRST-NAME)
8 COBOL programs Were divided into 2 sections Data division (program name, I/O files, variables)Procedure division (procedures/code)the data vision is the stronger part of COBOLevery variable was defined in terms of how it would be formatted for I/O and files accessCode was written using paragraphs and sentencesA sentence is equal to one instructionA paragraph is a group of instructions placed into one “block”procedure or block of code inside a loop or selection statementthese blocks were usually small and modularCOBOL also permitted nested selection (if) statementsCOBOL lacked parameter passing prior to 1974COBOL paragraphs are very much like parameterless functions. You will see in the example in a couple of slides how
9 COBOL Example IDENTIFICATION DIVISION. PROGRAM-ID. PRODUCE-REORDER-LISTING.ENVIRONMENT DIVISION.CONFIGURATION SECTION. SOURCE-COMPUTER. DEC-VAX.OBJECT-COMPUTER. DEC-VAX.INPUT-OUTPUT SECTION.FILE-CONTROL.SELECT BAL-FWD-FILE ASSIGN TO READER.SELECT REORDER-LISTING ASSIGN TO LOCAL-PRINTER.DATA DIVISION.FILE SECTION.FD BAL-FWD-FILELABEL RECORDS ARE STANDARDRECORD CONTAINS 80 CHARACTERS.01 BAL-FWD-CARD.02 BAL-ITEM-NO PICTURE IS 9(5).02 BAL-ITEM-DESC PICTURE IS X(20).02 FILLER PICTURE IS X(5).02 BAL-UNIT-PRICE PICTURE IS 999V99.02 BAL-REORDER-POINT PICTURE IS 9(5).02 BAL-ON-HAND PICTURE IS 9(5).02 BAL-ON-ORDER PICTURE IS 9(5).02 FILLER PICTURE IS X(30).COBOL ExampleNotice that these variables (e.g., BAL-FWD-CARD) combine formatting (filler, size of fields, types of data – 9 means numeric, X means character, V means decimal point) and struct-like grouping. A simple READ statement will input a row from input file and move each item found into its corresponding member in the record (for instance, the first 5 digits are moved into BAL-ITEM-NO, the next 20 are moved into BAL-ITEM-DESC, etc)
10 Example Continued FD REORDER-LISTING LABEL RECORDS ARE STANDARD RECORD CONTAINS 132 CHARACTERS.01 REORDER-LINE.02 RL-ITEM-NO PICTURE IS Z(5).02 FILLER PICTURE IS X(5).02 RL-ITEM-DESC PICTURE IS X(20).02 RL-UNIT-PRICE PICTURE IS ZZZ.99.02 RL-AVAILABLE-STOCK PICTURE IS Z(5).02 RL-REORDER-POINT PICTURE IS Z(5).02 FILLER PICTURE IS X(71).WORKING-STORAGE SECTION.01 SWITCHES.02 CARD-EOF-SWITCH PICTURE IS X.01 WORK-FIELDS02 AVAILABLE-STOCK PICTURE IS 9(5).Example ContinuedZ, as used in RL-UNIT-PRICE means zero, that is, will force a 0 to appear even if the number is (rather than just ..31 or 0.31)CARD-EOF-SWITCH is in effect a boolean and will store Y or N.
11 Example Continued PROCEDURE DIVISION. 000-PRODUCE-REORDER-LISTING. OPEN INPUT BAL-FWD-FILE.OPEN OUTPUT REORDER-LISTING.MOVE “N” TO CARD-EOF-SWITCH.PERFORM 100-PRODUCE-REORDER-LINEUNTIL CARD-EOF-SWITCH ISEQUAL TO “Y”.CLOSE BAL-FWD-FILE.CLOSE REORDER-LISTING.STOP RUN.100-PRODUCE-REORDER-LINE.PERFORM 110-READ-INVENTORY-RECORD.IF CARD-EOF-SWITCH IS NOT EQUAL TO “Y”PERFORM120-CALCULATE-AVAILABLE-STOCK.IF AVAILABLE-STOCK IS LESS THANBAL-REORDER-POINT PERFORM130-PRINT-REORDER-LINE.110-READ-INVESTORY-RECORD.READ BAL-FWD-FILE RECORDAT END MOVE “Y” TO CARD-EOF-SWITCH.120-CALCULATE-AVAILABLE-STOCK.ADD BAL-ON-HAND BAL-ON-ORDERGIVING AVAILABLE-STOCK.130-PRINT-REORDER-LINE.MOVE SPACE TO REORDER-LINE.MOVE BAL-ITEM-NO TO RL-ITEM-NO.MOVE BAL-ITEM-DESC TORL-ITEM-DESC.MOVE BAL-UNIT-PRICE TORL-UNIT-PRICE.MOVE AVAILABLE-STOCK TORL-AVAILABLE-STOCK.MOVE BAL-REORDER-POINT TORL-REORDER-POINT.WRITE REORDER-LINE.A statement like PERFORM 100-… is a function call. After that “function” (paragraph) executes, control returns to the next instruction in The numbers preceding the paragraph names are not necessary but useful for seeing the program’s layout.Notice that most of whats going on in this COBOL program is data movement from input to output files with some minimal calculations in between. COBOL primarily was used for File I/O and sorting. Programs requiring a lot of computation were often done in FORTRAN.
12 Conclusions on FORTRAN & COBOL FORTRAN was an important step because it showed that compiling could be done efficientlyFORTRAN was very primitive (no strings, no logical if statements, only a post-loop iterative statement)Extensive use of GOTO statements led to spaghetti codeCOBOL became extremely successful becauseIt contained many I/O and record-keeping features that other early languages did not haveAs better languages were developed, businesses had the option to either re-implement their software in the newer languages and implement all new programs in the newer languages, or hold onto COBOLin many cases, businesses held onto COBOLBoth languages continue to be used merely because of the amount of legacy software implemented in these languagesIn the late 90s as programmers worked through legacy code to prevent Y2K from being a problem, it was estimated that 800 million lines of COBOL code existed on the island of Manhatten alone!FORTRAN really relied on GO TO statements. COBOL less so, but the parameter-less function calls are very weak. So both languages promoted the creation of spaghetti code (trying to trace through the code made your program look like a pile of spaghetti). This was a lesson that really wasn’t learned of programmers until the 1970s when languages were developed that either did not have a GO TO statement, or that discouraged its use by having a variety of better control statements.COBOL much more than FORTRAN led to legacy software (much of which is still in use). Up until the early 90s, most businesses continued to use COBOL. Visual BASIC has changed that somewhat. Most scientific software was developed in C and later languages started in the 1970s or 1980s so there is far less FORTRAN legacy code out there.
13 ALGOL ALGOL was an attempt to create a “universal” language Driven by international interestsOriginal version of ALGOL in 1958 had these design goalsclose to a standard mathematical notationusable for algorithmic descriptionmachine independent yet capable of compiling into machine languageALGOL 58 was designed as a generalized version of FORTRAN (a descendant) with added featuresidentifiers of any lengthformalized data type to construct data structuresexplicit type declarations (except fl pt)machine independenceI/O routines would have to be written for every machine, and so this was typically left up to the programmerarrays of any dimension with bounds being user declared (including lower bound)nested if statementsfor loopsALGOL’s for loop was very expressive. We will examine it in chapter 7. It led to C’s for loop as well as the foreach or forall type of loops later seen in FORTRAN 90 and C#.
14 ALGOL 60Aside from bug fixes, ALGOL 60 contained ideas that would become the foundation for most languages to followALGOL 60 introduced the notion of the block structurebegin and end to delimit the blocklocal variable declarations within a blockthis introduced the concept of scopeIn addition, ALGOL 60 introducedparameter passing to subroutinesusing pass by value, which is common, and pass by name, very rare and oddrecursionstack dynamic arrays so that the size of the array is determined at run-time when the subroutine is invokedNearly all languages since ALGOL 60 include the notion of a block, local variables, and static scope (we cover scope issues later in the semester). COBOL largely just had global variables and FORTRAN had no blocks so variables were global or limited to the subroutine that declared them.
15 ALGOL 60 Example begin integer array intlist [1:99]; integer listlen, counter, sum, average, result;sum := 0;result :=0;readint (listlen);if(listlen > 0) ^ (listlen < 100) thenfor counter := 1 step 1 until listlen doreadint (intlist[counter]);sum := sum + intlist[counter]end;average := sum / listlen;if intlist[counter] > averagethen result := result + 1;printstring(“The number of values > average is: ”);printint(result)endelse printstring(“Error – input list length is not legal.”);ALGOL 60 ExampleNotice the begin and end statements which allowed for if-else statements and nested logic. The notation [1:99] was used to indicate the legal array subscripts. FORTRAN required all arrays start at 1, so INTEGER X(99) would mean that the array references would range from 1 to 99, just as C and Java start at 0. Pascal and similar languages allow the programmer to specify the legal subscripts, for instance [-10:10] for a 21 item array or [100:199].
16 Conclusions on ALGOLALGOL in retrospect is a huge success in spite of the language itself not being widely usedstructured programming ideas were adopted from ALGOL 60’s block structurenearly all languages since the late 1960s have used some form of block structureALGOL was the first language to offer recursion in a static binding way (as opposed to LISP)BNF grammar notation was created to describe ALGOL and has become the universal way of describing language syntaxALGOL had some major failingslack of implemented input/output made ALGOL difficult to uselack of widespread acceptance was in part based on a lack of ALGOL compilers being available for IBM mainframesALGOL’s pass-by-name was a naïve approach to parameter passing that would be dismissed as a bad idea and be adopted by only one or two other languagesThe idea behind ALGOL was that it would compile for any machine. I/O operations were of course machine specific, so that portion was left out of any compiler and therefore the programmer had to write their own I/O routines for the specific hardware. Given this difficulty combined with the fact that the language was not promoted very well outside of Europe and you can see why it never achieved wide-spread use, unlike FORTRAN, COBOL and PL/I which were all IBM products/projects or promoted by IBM.
17 Functional Programming AI research has needs that FORTRAN and COBOL (and ALGOL) did not supportList and symbolic processingDynamic memory allocationRecursionNewell and Simon developed IPL-I (Information Processing Language) in 1956 and implemented in 1960this language never caught on because the compiler was developed for an obscure computerMcCarthy instead developed LISP in 1958symbolic computing rather than algebraiclist processing (creation/destruction of lists using dynamic alloc.)string manipulationrecursionconditionals (recall early FORTRAN did not have a true if statement)The need for recursion led to the development of LISP as a functional language rather than an imperative languageall constructs are functions that return a valueunlike FORTRAN in which subroutines did not necessarily return values
18 More on LISP Both data and code are stored as lists leads to an easy mechanism whereby code can generate codeAll instructions are function callsthe return from one function can be used as a parameter to another function causing code to have nested function callsBecause of recursion, original LISP did not allow for local variables (only parameters)this led to some interesting codeLISP is typelessBecause of the heavy use of dynamic memory, extensive garbage collection is neededOriginal LISP was interpreted so that code could be “built up” over timeLISP dialects today can run interpreted or be compiledexample code on page 52-53We will cover LISP in detail next week, so for now, we skip any real examination. LISP itself had many failings so more recent dialects are both better and more complex. These include Scheme and Common Lisp.
19 PL/IAs scientist began to need file-handling capabilities and business people wanted regression analysis and array capabilities in their languages:IBM decided to try to build a new language that captured the best of all previous languages for use by anyone, PL/I (designed for the IBM 360 mainframe)Earliest release called FORTRAN VI in February 64 as an extension to FORTRAN IV, but the language became PL/I in 1965 and had these featuresrecursion and block structures of ALGOLseparate compilation and parameter passing of FORTRANadvanced data types and I/O handling capabilities of COBOLconcurrency (new feature)exception handling (new feature)pointers as an explicit data type (new feature)slices of arrays of FORTRANlarge number of built-in data structures (trees, heaps, graphs, etc)PL/I was deemed overly complex and somewhat unsafeit was somewhat successful during the 1970s but not since thensee the sample code on page 72-73PL/I can be a fun language. Imagine for instance being able to declare a variable to be of type BinaryTree and not have to implement any of the operations like insert or preorder traversal. Other built-in data types include hash tables, graphs, linked lists, etc. What PL/I did not have was a facility for the programmer to build his or her own data structures. ALGOL 68 (which we examine shortly) took the opposite approach: few built in data types but the facility to build your own based on the built in types.
20 Early Dynamic Languages APL and SNOBOL are very different languages but both have dynamic type binding/dynamic storage allocationAside from LISP, these languages highly differ from nearly all other predecessorsDynamic type binding means that a variable is only bound to its type when it is in use, thus a variable is not declared initiallySince a variable is initially untyped, storage can only be allocated when the variable is assignedthe compiler doesn’t know how much memory to set aside so we must use dynamic storage allocationAPL has many powerful array operationsSNOBOL has strong character string manipulation and pattern matching operationsneither language was widely used even though both languages are still around today
21 SIMULA 67 Intended for simulation purposes Extension to ALGOL 60Added coroutines and ability to restart a routine in its middleIntroduced a construct for encapsulation of code and data structures: the classsince the class was a definition of a data structure, not a declaration, SIMULA 67 introduced the distinction between class and instanceclasses could define code that would execute when the object was created (e.g., a constructor)the class construct offered inheritanceunlike modern OOPLs, SIMULA 67 had no mechanisms for polymorphism or information hidingSIMULA is not a true object-oriented programming language, but was the first to offer a facility for data abstractionSIMULA would be used as a starting point for Smalltalk
22 ALGOL 68Dramatically different from ALGOL 60 but still promoted block structures and a variety of control constructsThe main focus of the language is on orthogonalityrather than having a variety of built-in data types like PL/I, ALGOL 68 permitted user-defined data types out of the primitive types via arrays, pointers, records and the primitive typesdynamic Arrays were available so that an array could change sizes at run-timeALGOL 68 was not very popularin part because the authors of the language published it using new terminology and hard-to-understand grammarBut it would be the basis for many very popular future languages…Descendant languages include Pascal, C, BASIC, and their descendants which includePascal: Modula-2, -3, Oberon, Ada, DelphiC: C++, Java, C#, PerlBASIC: all of the BASIC dialetcs
23 BASIC BASIC: Beginner’s All-purpose Symbolic Instruction Code Developed in 1971, designed for introductory programmingfor liberal arts majorsThe language should beeasy to learn and use, be pleasant and friendly (!)and provide fast turnaround time, consider user time more important than computer timeOriginally, BASIC had only 14 instructions (all FP operations)and had no means of getting input from the terminalprograms would have to be compiled to access data filesLater versions of BASIC grew in many waysANSI dictated a minimal BASIC in 1978there have been many different dialects of BASIC and today it is popular because of Visual BASIChas been used primarily for PC programming, but also used to implement time sharing applications because it is an interpreted languageexample code on page 67
24 Pascal Wirth and Hoare created ALGOL-W which evolved into Pascal named after Mathematician Blaise PascalDirect descendent of ALGOL 68intended for instructional uselacked some important language qualities like semi-dynamic arrays and separate compilation of modulesincluded CASE statementan easier to use construct than C’s switch because, when a selection is made, the instruction is exited (without the need for break statements)removed pass-by-name as a parameter passing method and replaced it with pass-by-value-resulta very SAFE language due to static nature of most of its constructs and type checkingexample code on page 78-79Pascal, being designed specifically to teach structured programming to college students, is one of the best languages to learn from. However, during the 1990s, employers and students questioned the value of teaching a language that was not used in industry. This led to a change away from Pascal and toC/C++ or Java as an introductory language. This is somewhat unfortunate because the C languages do not permit nested subroutines and in the case of C++ and Java, the overhead of objects makes them more awkward to teach. Today, almost no one teaches or uses Pascal. Some languages similar to Pascal, Modula, Ada, Oberon, and Delphi, are still in use.
25 Modula-2, Modula-3, Oberon Three direct descendants of PascalNo compiler for Modula was ever releasedModula-2 gained widespread use in the late 1980s as a teaching language, usually supplanting PascalModula-3 developed in the late 80’s adds objects/classes, exception handling, garbage collection and concurrencyOberon is loosely based on Modula-2 but removed numerous features from Modula-2 to make the language simpler and saferAll 3 languages used the module as the basic data structure – the module would encapsulate data structure and procedure to form ADTsUnlike Pascal, modules in these languages could be separately compiled allowing these languages to be much more useful
26 C – for systems work Evolved from ALGOL 68, CPL (63), B slowly evolved from 1972 through 1988C++ developed in mid 80’sSimilar to Pascal in its available control statements, data structures but:lacks complete typechecking especially for functions/proceduresAdditionally, while C introduced a switch statement, it has a very flexible for-loop, more so than ALGOL or any other languageC was used to develop UNIX and has been used extensively to create UNIX-based systems and applications softwareC did not become standardized until ANSI C in 1989, a newer standard version of C is often called C99
27 PROLOG Nonprocedural language based on logic Using Prolog, you didn’t really write a program as much as you listed statements (facts, rules) and asked questionsFacts represented as predicates and propositions:dog(spot)mom(june,fred)Inference rules represented as Horn clausesgrandparent(x,z) :- parent(x,y), parent(y,z)PROLOG processes were based on two logic algorithms: resolution and unificationUsed by some AI researchersResolution is inefficient (intractable)We will look at Prolog in detail in chapter 16A very different language.
28 ADABy 1974, much of the DoD software was writting using 450 different languages!DoD contracted out to have a language designed especially for their internal use which entailed a study of 26 programming languages producing 2800 pages of analysisReleased in 1980 and introducedpackages (encapsulated data types, objects, procedures)exception handling for a wide variety of run-time errorsgeneric procedures which can operate on different data typesprovisions for concurrencyADA 95 improved Ada by includinggraphical user interfaceobject-oriented programmingmore flexible librariesbetter control mechanisms for shared dataAda 95 and C++ are roughly equivalent in terms of size and scopeexample code on page 86-87Ada is really like a souped up Pascal, or taking Pascal’s simplicity and adding to it until its overbloated like C++!For over a decade, all government agencies and contractors were forced to write code in Ada (although there were a few exceptions). This forced Ada to be a language that was used but a substantial number of programmers whether they wanted to or not. C++ (and Java) are superior languages though in terms of writability and implementation. The government backed off on this demand in the late 1990s. Ada is still in use but by a shrinking population.
29 Smalltalk: OOP Descendant of Simula 67 In a 1969 ph.d. dissertation, Alan Kay developed the ideas that would go into Smalltalk and thus OOPSmalltalk would have a greater emphasis on data types than Simula 67All data are objects (including numbers, scalar variables, responses from objects, etc) – making Smalltalk the only true OOPL (all others have data that are not objects)Communication between objects by message passingDynamic binding of objectsInheritanceMain implementation captured in methodsLanguage promoted modularity via objectsKay used Smalltalk at XEROX PARC to develop the first windows environment (1980)We will study some Smalltalk later in the semester.
30 C++ Merger of C and Smalltalk evolved between 1984 and 1985 with first large distribution in 1985 with 2nd and 3rd versions released in 1989 and 1998In fact, C++’s implementation of objects differs greatly from Smalltalk, so the merger was more at a conceptual level: C plus ObjectsAlso, C++ cleaned up some of the awkward aspects of C, such as including a true pass by reference parameter passing method and easier to use pointersC++ continues to be the most used programming language in spite of increasing popularity of Java, Ruby, Python, VB and C#C++ has:Both pre-defined and user-defined classes and allows multiple inheritance, user-defined control over what would be inheritedOverloaded operatorsDynamic type bindingTemplated functions and classes, abstract classesException Handling
31 Related Languages to C++ DelphiDerived from Pascal, it is an object-oriented language, so like C++, is another hybridWhereas C++ has many unsafe featuresbeing based on Pascal, Delphi attempts to be safe and elegant and is less complex than C++Delphi does not allowoperator overloadinggeneric subprogramsparameterized classesDelphi does have an easy way to build GUI componentslike Visual BASICEiffelAnother hybrid imperative + OO languageSupportsabstract data typesinheritancedynamic bindingIncludes the idea of “assertions”to enforce assumptions between a calling method and a called methodEiffel is smaller, simpler and thus of less use than C++
32 JavaOriginal intention was for device programming (e.g., toasters, tvs)Java is very much like C/C++ in syntax and like C++ in that it is object-oriented but has substantial differences:implicit pointers (called references) instead of explicit pointers and no deallocationgarbage collection insteaddirect support for network securityno struct or functions, only classes/objects and methodsno stand-alone objects, only single inheritanceBuilt-in classes forstrings, arrays, exceptionsgraphical classes (swing classes, available since Java 2.0)concurrency (via threads)network communicationOverall, Java is a much safer language to use than C++ but not necessarily any easier to useJava is often considered slower than C++ because of the need for garbage collection and the extensive use of dynamic memory
33 Scripting LanguagesEarly scripting languages were simply a list of commands in a file that were then interpreted by another piece of softwareThese included shell languages for Unix and report-generating languages like awk and tclPerl is a scripting language that can be compiled so it is somewhat more like C on which it is partially basedPerl featuresvariables are statically typed and implicitly declared based on their first character$ means a scalar means an array, % means a variable to be stored in a hash table (known as an associative array)Perl has a number of implicit variables such as a variables used as default parameters passed to built-in functionsarrays have dynamic lengths and can be sparse (controlled by the foreach instruction)example code on page 98-99
36 C# and .NetThe .Net platform is a combination of languages that can produce code that call upon objects developed in these different languages (C#, C++, J#, VB, Jscript, ASP)The languages use a common type system which provides a common class libraryAll languages are compiled into intermediate ByteCode and use a Just-In-Time compiler immediately prior to executionC# itself is based on both C++ and Java but includes ideas from Delphi and Visual BASICC# supports many features from C++ (pointers, structs, enum types, operator overloading, goto, variable number of parameters for parameter passing)But C# objects are based on Java (e.g., single inheritance)C# adds the foreach instructionimproves the switch statement by requiring each clause end with break to ensure that at most, one clause will executeExample code on page
Your consent to our cookies if you continue to use this website.