Presentation is loading. Please wait.

Presentation is loading. Please wait.

Evolution of PLs We can extend this timeline as follows:

Similar presentations

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 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 You 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 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 Most 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 of Input statements Mathematical formulae (to compute values) Output statements Along with some rudimentary control to have loops and selections So 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 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 One 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 statement IF <expr> N1, N2, N3 This 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 clause IF 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 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) 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 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 If (Int_List(Counter) > Average) Then Result = Result + 1 End If Print *, ‘Values > Average is: ’, Result Else Print *, ‘List length value not legal’ 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 COBOL paragraphs are very much like parameterless functions. You will see in the example in a couple of slides how

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 Notice 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)

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-FIELDS 02 AVAILABLE-STOCK PICTURE IS 9(5). Example Continued Z, 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.


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! 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 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 ALGOL’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 60 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 Nearly 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) then for counter := 1 step 1 until listlen do readint (intlist[counter]); sum := sum + intlist[counter] end; average := sum / listlen; 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.”); ALGOL 60 Example Notice 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 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 The 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 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 More on LISP 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 We 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/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 PL/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 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… Descendant languages include Pascal, C, BASIC, and their descendants which include Pascal: Modula-2, -3, Oberon, Ada, Delphi C: C++, Java, C#, Perl BASIC: all of the BASIC dialetcs

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 Pascal, 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 to C/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 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 A very different language.

28 ADA 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 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 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) 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 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

31 Related Languages to 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 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++

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 Scripting Languages 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 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

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 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

Download ppt "Evolution of PLs We can extend this timeline as follows:"

Similar presentations

Ads by Google