1 / 36

Evolution of PLs

Evolution of PLs. Machine language was difficult Floating point hardware was not yet available (1950s) FP operations were performed as a series of integer operations time consuming Pseudocode short cuts were developed

olin
Download Presentation

Evolution of PLs

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Evolution of PLs

  2. Machine language was difficult Floating point hardware was not yet available (1950s) FP operations were performed as a series of integer operations time consuming Pseudocode short cuts were developed A 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 operations Similarly, short codes developed on some architectures Assembly language was the next logical step in the mid 1950s The idea of translating from a short code, pseudocode or mnemonic into machine code gives rise to the next idea: compiling Toward High Level Languages

  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 easier • FORTRAN – FORmula TRANslator was developed • Plans announced in 1954 • Compiler would translate mathematical formulas (assignment statements) into machine language • there would also be simple control and I/O statements • The language would operate on Integer and Floating Pt data • compiler 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 them • FORTRAN 0 was published to report on the language, but never implemented

  4. Early FORTRAN Implementations • FORTRAN I released April 57, included: • I/O Formatting • Variable name lengths up to 6 characters • implicit data typing by variable name (I..N names are ints, all others are floating point) • Control constructs • user-defined subroutines • early IF stmt: IF <expr> N1, N2, N3 • iterative stmt: Do N1 var = first, last (post-test loop) • FORTRAN II released Spring 58 • Fixed many of the bugs from FORTRAN I • Added independent compilation of subroutines • without 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 routines • FORTRAN IV released 1962 • One of the most popular programming languages up until FORTRAN 77 • Explicit and implicit type declarations • Logical If stmt • Passing subroutine names as parameters

  5. FORTRAN 77 - 95 • FORTRAN 77 (1977-1990) • Character string handling • Logical loops • If-then-else • FORTRAN 90 • Built-in array operations and dynamic arrays • Records • Pointers • Modules for data structure encapsulation and information hiding • Recursive subprograms and keyword parameters • Type checking of parameters • CASE stmt, EXIT statement, CYCLE statement • FORTRAN 95 • Forall statement • FORTRAN 95 removed many old items (assigned and compute GOTO statements, arithmetic IF statement)

  6. FORTRAN I and 90 Examples Program Example Implicit none Integer :: Int_List(99) Integer :: List_Len, Counter, Sum, Average, Result Result = 0 Sum = 0 Read *, List_Len If ((List_Len > 0) .AND. (List_Len < 100)) Then Do Counter = 1, List_Len Read *, Int_List(Counter) Sum = Sum + Int_List(Counter) End Do Average = Sum / List_Len Do Counter = 1, List_Len If (Int_List(Counter) > Average) Then Result = Result + 1 End If End Do Print *, ‘Values > Average is: ’, Result Else Print *, ‘List length value not legal’ End If End Program Example INTEGER LIST(99) ISUM = 0 IRES = 0 IAVG = 0 Read *, ILEN If (ILEN) 50, 50, 10 10 If (ILEN – 100) 20, 50, 50 20 Do 30 I = 1, ILEN Read *, LIST(I) ISUM = ISUM + LIST(I) 30 Continue IAVG = ISUM / ILEN Do 40 I = 1, ILEN If (LIST (I) .GT. IAVG) Then IRES = IRES + 1 End If 40 Continue Print *, ‘Values > Average is: ’, IRES GO TO 60 50 Print *, ‘List length value not legal’ 60 Continue End

  7. COBOL • Dept. 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 types • IBM began work on a business version of FORTRAN called COMTRAN but COBOL would be implemented instead • COBOL would support • Opening and closing of data files • Transfer of records • Formatted I/O • Easy to use (even at the expense of being less powerful) • Read like English • COBOL would also • Have a construct for Macros • Hierarchical 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 COBOL • every variable was defined in terms of how it would be formatted for I/O and files access • Code was written using paragraphs and sentences • A sentence is equal to one instruction • A paragraph is a group of instructions placed into one “block” • procedure or block of code inside a loop or selection statement • these blocks were usually small and modular • COBOL also permitted nested selection (if) statements • COBOL lacked parameter passing prior to 1974

  9. 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-FILE LABEL RECORDS ARE STANDARD RECORD 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 Example

  10. 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 FILLER PICTURE IS X(5). 02 RL-UNIT-PRICE PICTURE IS ZZZ.99. 02 FILLER PICTURE IS X(5). 02 RL-AVAILABLE-STOCK PICTURE IS Z(5). 02 FILLER PICTURE IS X(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-FIELDS 02 AVAILABLE-STOCK PICTURE IS 9(5). Example Continued

  11. 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-LINE UNTIL CARD-EOF-SWITCH IS EQUAL 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” PERFORM 120-CALCULATE-AVAILABLE-STOCK. IF AVAILABLE-STOCK IS LESS THAN BAL-REORDER-POINT PERFORM 130-PRINT-REORDER-LINE. 110-READ-INVESTORY-RECORD. READ BAL-FWD-FILE RECORD AT END MOVE “Y” TO CARD-EOF-SWITCH. Example Continued 120-CALCULATE-AVAILABLE-STOCK. ADD BAL-ON-HAND BAL-ON-ORDER GIVING AVAILABLE-STOCK. 130-PRINT-REORDER-LINE. MOVE SPACE TO REORDER-LINE. MOVE BAL-ITEM-NO TO RL-ITEM-NO. MOVE BAL-ITEM-DESC TO RL-ITEM-DESC. MOVE BAL-UNIT-PRICE TO RL-UNIT-PRICE. MOVE AVAILABLE-STOCK TO RL-AVAILABLE-STOCK. MOVE BAL-REORDER-POINT TO RL-REORDER-POINT. WRITE REORDER-LINE.

  12. Conclusions on FORTRAN & COBOL • FORTRAN was an important step because it showed that compiling could be done efficiently • FORTRAN was very primitive (no strings, no logical if statements, only a post-loop iterative statement) • Extensive use of GOTO statements led to spaghetti code • COBOL became extremely successful because • It contained many I/O and record-keeping features that other early languages did not have • As 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 COBOL • in many cases, businesses held onto COBOL • Both languages continue to be used merely because of the amount of legacy software implemented in these languages • In 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!

  13. ALGOL • ALGOL was an attempt to create a “universal” language • Driven by international interests • Original version of ALGOL in 1958 had these design goals • close to a standard mathematical notation • usable for algorithmic description • machine independent yet capable of compiling into machine language • ALGOL 58 was designed as a generalized version of FORTRAN (a descendant) with added features • identifiers of any length • formalized data type to construct data structures • explicit type declarations (except fl pt) • machine independence • I/O routines would have to be written for every machine, and so this was typically left up to the programmer • arrays of any dimension with bounds being user declared (including lower bound) • nested if statements • for loops

  14. Aside from bug fixes, ALGOL 60 contained ideas that would become the foundation for most languages to follow ALGOL 60 introduced the notion of the block structure begin and end to delimit the block local variable declarations within a block this introduced the concept of scope In addition, ALGOL 60 introduced parameter passing to subroutines using pass by value, which is common, and pass by name, very rare and odd recursion stack dynamic arrays so that the size of the array is determined at run-time when the subroutine is invoked ALGOL 60

  15. begin integer array intlist [1:99]; integer listlen, counter, sum, average, result; sum := 0; result :=0; readint (listlen); if(listlen > 0) ^ (listlen < 100) then begin for counter := 1 step 1 until listlen do begin readint (intlist[counter]); sum := sum + intlist[counter] end; average := sum / listlen; for counter := 1 step 1 until listlen do if intlist[counter] > average then result := result + 1; printstring(“The number of values > average is: ”); printint(result) end else printstring(“Error – input list length is not legal.”); end ALGOL 60 Example

  16. Conclusions on ALGOL • ALGOL in retrospect is a huge success in spite of the language itself not being widely used • structured programming ideas were adopted from ALGOL 60’s block structure • nearly all languages since the late 1960s have used some form of block structure • ALGOL 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 syntax • ALGOL had some major failings • lack of implemented input/output made ALGOL difficult to use • lack of widespread acceptance was in part based on a lack of ALGOL compilers being available for IBM mainframes • ALGOL’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 languages

  17. Functional Programming • AI research has needs that FORTRAN and COBOL (and ALGOL) did not support • List and symbolic processing • Dynamic memory allocation • Recursion • Newell and Simon developed IPL-I (Information Processing Language) in 1956 and implemented in 1960 • this language never caught on because the compiler was developed for an obscure computer • McCarthy instead developed LISP in 1958 • symbolic computing rather than algebraic • list processing (creation/destruction of lists using dynamic alloc.) • string manipulation • recursion • conditionals (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 language • all constructs are functions that return a value • unlike FORTRAN in which subroutines did not necessarily return values

  18. Both data and code are stored as lists leads to an easy mechanism whereby code can generate code All instructions are function calls the return from one function can be used as a parameter to another function causing code to have nested function calls Because of recursion, original LISP did not allow for local variables (only parameters) this led to some interesting code LISP is typeless Because of the heavy use of dynamic memory, extensive garbage collection is needed Original LISP was interpreted so that code could be “built up” over time LISP dialects today can run interpreted or be compiled example code on page 52-53 More on LISP

  19. PL/I • As 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 features • recursion and block structures of ALGOL • separate compilation and parameter passing of FORTRAN • advanced data types and I/O handling capabilities of COBOL • concurrency (new feature) • exception handling (new feature) • pointers as an explicit data type (new feature) • slices of arrays of FORTRAN • large number of built-in data structures (trees, heaps, graphs, etc) • PL/I was deemed overly complex and somewhat unsafe • it was somewhat successful during the 1970s but not since then • see the sample code on page 72-73

  20. Early Dynamic Languages • APL and SNOBOL are very different languages but both have dynamic type binding/dynamic storage allocation • Aside from LISP, these languages highly differ from nearly all other predecessors • Dynamic type binding means that a variable is only bound to its type when it is in use, thus a variable is not declared initially • Since a variable is initially untyped, storage can only be allocated when the variable is assigned • the compiler doesn’t know how much memory to set aside so we must use dynamic storage allocation • APL has many powerful array operations • SNOBOL has strong character string manipulation and pattern matching operations • neither language was widely used even though both languages are still around today

  21. SIMULA 67 • Intended for simulation purposes • Extension to ALGOL 60 • Added coroutines and ability to restart a routine in its middle • Introduced a construct for encapsulation of code and data structures: the class • since the class was a definition of a data structure, not a declaration, SIMULA 67 introduced the distinction between class and instance • classes could define code that would execute when the object was created (e.g., a constructor) • the class construct offered inheritance • unlike modern OOPLs, SIMULA 67 had no mechanisms for polymorphism or information hiding • SIMULA is not a true object-oriented programming language, but was the first to offer a facility for data abstraction • SIMULA would be used as a starting point for Smalltalk

  22. ALGOL 68 • Dramatically different from ALGOL 60 but still promoted block structures and a variety of control constructs • The main focus of the language is on orthogonality • rather 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 types • dynamic Arrays were available so that an array could change sizes at run-time • ALGOL 68 was not very popular • in part because the authors of the language published it using new terminology and hard-to-understand grammar • But it would be the basis for many very popular future languages…

  23. BASIC • BASIC: Beginner’s All-purpose Symbolic Instruction Code • Developed in 1971, designed for introductory programming • for liberal arts majors • The language should be • easy to learn and use, be pleasant and friendly (!) • and provide fast turnaround time, consider user time more important than computer time • Originally, BASIC had only 14 instructions (all FP operations) • and had no means of getting input from the terminal • programs would have to be compiled to access data files • Later versions of BASIC grew in many ways • ANSI dictated a minimal BASIC in 1978 • there have been many different dialects of BASIC and today it is popular because of Visual BASIC • has been used primarily for PC programming, but also used to implement time sharing applications because it is an interpreted language • example code on page 67

  24. Pascal • Wirth and Hoare created ALGOL-W which evolved into Pascal • named after Mathematician Blaise Pascal • Direct descendent of ALGOL 68 • intended for instructional use • lacked some important language qualities like semi-dynamic arrays and separate compilation of modules • included CASE statement • an 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-result • a very SAFE language due to static nature of most of its constructs and type checking • example code on page 78-79

  25. Modula-2, Modula-3, Oberon • Three direct descendants of Pascal • No compiler for Modula was ever released • Modula-2 gained widespread use in the late 1980s as a teaching language, usually supplanting Pascal • Modula-3 developed in the late 80’s adds objects/classes, exception handling, garbage collection and concurrency • Oberon is loosely based on Modula-2 but removed numerous features from Modula-2 to make the language simpler and safer • All 3 languages used the module as the basic data structure – the module would encapsulate data structure and procedure to form ADTs • Unlike 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 1988 • C++ developed in mid 80’s • Similar to Pascal in its available control statements, data structures but: • lacks complete typechecking especially for functions/procedures • Additionally, while C introduced a switch statement, it has a very flexible for-loop, more so than ALGOL or any other language • C was used to develop UNIX and has been used extensively to create UNIX-based systems and applications software • C 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 questions • Facts represented as predicates and propositions: • dog(spot) • mom(june,fred) • Inference rules represented as Horn clauses • grandparent(x,z) :- parent(x,y), parent(y,z) • PROLOG processes were based on two logic algorithms: resolution and unification • Used by some AI researchers • Resolution is inefficient (intractable) • We will look at Prolog in detail in chapter 16

  28. By 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 analysis Released in 1980 and introduced packages (encapsulated data types, objects, procedures) exception handling for a wide variety of run-time errors generic procedures which can operate on different data types provisions for concurrency ADA 95 improved Ada by including graphical user interface object-oriented programming more flexible libraries better control mechanisms for shared data Ada 95 and C++ are roughly equivalent in terms of size and scope example code on page 86-87 ADA

  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 OOP • Smalltalk would have a greater emphasis on data types than Simula 67 • All 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 passing • Dynamic binding of objects • Inheritance • Main implementation captured in methods • Language promoted modularity via objects • Kay used Smalltalk at XEROX PARC to develop the first windows environment (1980)

  30. 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 1998 In fact, C++’s implementation of objects differs greatly from Smalltalk, so the merger was more at a conceptual level: C plus Objects Also, 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 pointers C++ 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 inherited Overloaded operators Dynamic type binding Templated functions and classes, abstract classes Exception Handling C++

  31. Eiffel Another hybrid imperative + OO language Supports abstract data types inheritance dynamic binding Includes the idea of “assertions” to enforce assumptions between a calling method and a called method Eiffel is smaller, simpler and thus of less use than C++ Delphi Derived from Pascal, it is an object-oriented language, so like C++, is another hybrid Whereas C++ has many unsafe features being based on Pascal, Delphi attempts to be safe and elegant and is less complex than C++ Delphi does not allow operator overloading generic subprograms parameterized classes Delphi does have an easy way to build GUI components like Visual BASIC Related Languages to C++

  32. Java • Original 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 deallocation • garbage collection instead • direct support for network security • no struct or functions, only classes/objects and methods • no stand-alone objects, only single inheritance • Built-in classes for • strings, arrays, exceptions • graphical classes (swing classes, available since Java 2.0) • concurrency (via threads) • network communication • Overall, Java is a much safer language to use than C++ but not necessarily any easier to use • Java is often considered slower than C++ because of the need for garbage collection and the extensive use of dynamic memory

  33. Early scripting languages were simply a list of commands in a file that were then interpreted by another piece of software These included shell languages for Unix and report-generating languages like awk and tcl Perl is a scripting language that can be compiled so it is somewhat more like C on which it is partially based Perl features variables are statically typed and implicitly declared based on their first character $ means a scalar variable, @ 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 functions arrays have dynamic lengths and can be sparse (controlled by the foreach instruction) example code on page 98-99 Scripting Languages

  34. Scripting Languages to Support WWW • Many recent scripting languages are used to support client-side or server-side WWW applications: two very popular languages are JavaScript and PHP • JavaScript: client side support • allows a webpage to be dynamic in that the page, using JavaScript, can react to user actions with the mouse or with JavaScript objects • JavaScript is most commonly used as code embedded in html documents, but JavaScript could reside in other software as well (see the example on page 100) • While JavaScript looks like Java, the languages differ extensively as we will cover at different points throughout this course • PHP: server side support • used to dynamically generate new web pages upon demand • similar to JavaScript and is most commonly embedded in HTML code just like JavaScript • it also contains some Perl-like features such as the associative arrays

  35. Python and Ruby • Both languages have grown out of dissatisfaction with earlier scripting languages (Perl, JavaScript) • both languages are open source • both languages are interpreted although Python can be compiled and Ruby is compiled into an independent ByteCode (like Java) • both languages are OOP but Ruby is a pure OOPL (everything is an object and all operations are performed by message passing) • syntactically, Python is very different than other languages • instruction positioning indicates nested-ness • variables are implicitly declared at run-time so there is no compile-time type checking (like Lisp) • data structures include primitives, objects and typles rather than arrays • includes the pattern-matching facilities of Perl and exception handling • syntactically, Ruby is similar to Ada and Eiffel • variables are pointers to objects and are never declared • scope of a variable is based on its name (starting with @ means instance variable, $ means global scope)

  36. C# and .Net • The .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 library • All languages are compiled into intermediate ByteCode and use a Just-In-Time compiler immediately prior to execution • C# itself is based on both C++ and Java but includes ideas from Delphi and Visual BASIC • C# 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 instruction • improves the switch statement by requiring each clause end with break to ensure that at most, one clause will execute • Example code on page 105-106

More Related