Download presentation
Presentation is loading. Please wait.
1
This figure denotes the significant languages as
they were introduced and enhanced over the years Notice how some languages are ancestors of others FORTRAN led to ALGOL ALGOL led to C, Pascal Pascal led to Ada C led to C++ C++ led to Java and C# Now look at Prolog, APL, and Lua In this chapter, we touch on some of the significant developments in the progression of high level programming languages, concentrating on when new/novel features were pioneered. We also look at some of the oddities of early language implementation. Although there is probably not a lot of value in learning the history of programming languages, we can learn something valuable from early mistakes and see why a lot of language features and implementations are as they are today. This chapter is probably more interesting than it is valuable but hopefully you will enjoy it.
2
Toward High Level Languages
Machine language was difficult Floating point hardware not yet available (1950s) FP operations were performed as a series of integer operations Pseudocode short cuts were developed single FP operation would be translated by the interpreter at run-time into integer machine operations saving the programmer from having to write the int operations Short codes developed on some architectures as simple substitutions for machine code Led to assembly language as the next logical step The idea of translating from a short code, pseudocode or mnemonic into machine code gives rise to the next idea: compiling One early short code was Plankalkul, developed in 1945! 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 44)
3
Birth of FORTRAN IBM 704 had built-in FP operations
combined with the success of pseudocodes, some programmers believed they could have even greater amounts of translation to ease the programming task FORTRAN – FORmula TRANslator plans announced in 1954 compiler would translate mathematical formulas (assignment statements) into machine language along with simple control and I/O statements language would operate on integer and floating point 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 published 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
FORTRAN I Released April 57 Features 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, arrays explicitly declared three forms of control constructs user-defined subroutines early IF stmt: IF <expr> N1, N2, N3 semantics: if <expr> > 0 go to N1, if <expr> = 0, go to N2, if <expr> = 0, go to N3 iterative stmt: Do N1 var = first, last post-test loop only N1 is a line number indicating the last line in the loop number of iterations computed at run-time before loop commences, so if last changes in the loop, it has no affect on number of iterations! 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
5
FORTRAN II - IV FORTRAN II released Spring 58 FORTRAN IV released 1962
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 type declarations can be made explicitly to override the I..N integers logical if stmt introduced (no if-else) passing subroutine names as parameters 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
6
FORTRAN 77 - 08 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 2003 OOP support parameterized data types procedure pointers interoperability with C FORTRAN 2008 blocks with local scope co-arrays for concurrency 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.
7
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
8
COBOL Dept. of Defense promoted non-mathematical language for business use, more “English-like” FORTRAN was not suitable for business because variables names too short 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, would read like English 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
9
COBOL programs Were divided into 2 sections
Data division program name I/O files variables defined (and formatted) this is the real strength of COBOL, having precise definition of data storage which also doubles as I/O formatting Procedure division the code section, which is weak when compared to FORTRAN Code was written using paragraphs and sentences sentence is equal to one instruction, paragraph is a block paragraph could serve as a subroutine or the code to be executed in a loop or selection statement COBOL permitted nested selection (if) statements (absent from early FORTRANs) 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
10
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-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)
11
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-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
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-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. 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. 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.
13
Conclusions on FORTRAN & COBOL
important first step showing compilation could be done efficiently very primitive, lacking features we find in most languages developed since the mid to late 1960s extensive use of GOTO statements led to spaghetti code COBOL became extremely successful because many businesses adopted it powerful I/O (easy file handling, easy formatting) and record-based data structures were very useful but COBOL also led to legacy software and Y2K as most businesses stuck with COBOL rather than re-implementing their software in better languages when those languages were introduced in the late 90s, 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.
14
ALGOL Attempt to create a “universal” language (driven by international interests) most of the implementors were from European countries Original version dates back to1958 with these design goals close to a standard mathematical notation usable for algorithmic description machine independent yet capable of compiling into machine language designed as a generalized version (descendant) of FORTRAN By the late 1950s, most programmers in the US were involved in FORTRAN or COBOL development or used one of them. This was partially because of the predominance of IBM mainframes. In Europe, there were less IBM mainframes and so less FORTRAN and COBOL usage. Programming language developers in Europe wanted to build their own language.
15
ALGOL Features As ALGOL was based somewhat on FORTRAN, it added many features that FORTRAN lacked 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) any dimension for arrays, user-declared bounds FORTRAN arrays were initially limited to 3 dimensions and later 7 indices always started at 1 nested if statements, complex for loop Among the innovations that came from ALGOL was a syntax-free way of describing a language: BNF (Backus Naur Form) which we still use today when describing syntax, for instance: <if_statement> if (<condition>) <statement>; | { <block>} [ else <statement>; | else { <block> } ] Two immediate improvements of ALGOL over FORTRAN & COBOL were its for loop which was very expressive. It led to C’s for loop as well as the foreach or forall type of loops later seen in FORTRAN 90 and C# its use of blocks to permit more than 1 instruction as a clause in an if statement leading to if-then-else and nested if statements
16
ALGOL 60 Fixed bugs Introduced block structure
begin and end to delimit the block local variable declarations within a block this introduced the concept of scope ALGOL 60 also introduced parameter passing to subroutines pass by value and an odd one known as pass by name 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.
17
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].
18
Conclusions on ALGOL ALGOL although not popular was hugely successful in terms of influence introduced structured programming concepts that nearly all languages since the late 1960s would contain 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.
19
LISP AI research had needs FORTRAN, COBOL, ALGOL did not support such as list processing, dynamic memory allocation and, aside from ALGOL, recursion Newell and Simon developed IPL-I (Information Processing Language) in 1956, 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 memory allocation) string manipulation recursion conditionals (recall early FORTRAN did not have a true if statement) LISP was developed as a functional language with little to no local variables processing through function calls and parameter passing Early AI research largely revolved around games and natural language understanding. One NLU program, SHRDLU, implemented a “blocks world”. In this world, objects would be available for a robotic arm to implement. Users would enter commands in English such as “Move the red block onto the blue block” or “What color block is on the yellow block?” or “Can the green block be placed on the blue block?” Thus, SHRDLU was not only an NLU system but a planning system. What games, NLU and planning all have in common are: Need for recursion Need for processing symbols rather than numbers or strings (red-block is treated as a symbol representing an object, not a string, similarly noun is a symbol which itself contains items like dog, block, arm, etc) Need for dynamically allocating memory space to add and remove items from lists (thus, list processing)
20
PL/I Scientist began to need file-handling capabilities
Business people wanted regression analysis and array capabilities IBM decided to try to build a new language that captured the best of all previous languages for use by anyone Earliest release of PL/I was called FORTRAN VI (February 64) and was an extension to FORTRAN IV released in 1965 designed specifically for the IBM 360 mainframe PL/I was deemed overly complex and somewhat unsafe it was somewhat successful during the 1970s but not since then we will visit many PL/I features early in the semester, you can find sample code on the course website
21
PL/I Features Although based loosely on FORTRAN IV, PL/I took features from ALGOL and COBOL and added many new features recursion and block structures (ALGOL) separate compilation of subroutines and parameter passing (FORTRAN) defining data types via formatting (COBOL) I/O handling capabilities (COBOL) concurrency (new feature) exception handling (new feature) pointers as an explicit data type (new feature) slices of arrays (FORTRAN) large number of built-in data structures (trees, heaps, graphs, etc) (new feature) 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.
22
Early Dynamic Languages
APL and SNOBOL are very different languages but both have dynamic type binding/dynamic storage allocation these languages differ significantly from nearly all other predecessors (except for LISP) dynamic type binding variable is only bound to its type when it is in use variable is not declared and its type changes as it is used storage can only be allocated when the variable is assigned 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 The AWK tool in Unix/Linux and the Perl programming language adopted many of SNOBOL’s pattern matching features to develop what we often use today for regular expression matching.
23
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
24
ALGOL 68 Dramatically different from ALGOL 60 but still promoted block structures and a variety of control constructs main focus was on orthogonality data structures would be built through definitions using a few basic structure types like arrays, pointers, records and primitive types (chars, ints, floats) – this differed dramatically from the PL/I ideology 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
25
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 CASE statement (similar to C’s switch but easier to use because you don’t need to add break statements) used pass-by-copy and pass-by-value-result, removing the confusing pass-by-name very SAFE language due to static nature of most of its constructs and type checking sample code in notes page {Pascal Example Program Input: An integer, listlen, where listlen is less than 100, followed by listlen-integer values Output: The number of input values that are greater than the average of all input values } program pasex (input, output); type intlisttype = array [1..99] of integer; var intlist : intlisttype; listlen, counter, sum, average, result : integer; begin result := 0; sum := 0; readln (listlen); if ((listlen > 0) and (listlen < 100)) then begin { Read input into an array and compute the sum } for counter := 1 to listlen do readln (intlist[counter]); sum := sum + intlist[counter] end; { Compute the average } average := sum / listlen; { Count the number of input values that are > average } for counter := 1 to listlen do if (intlist[counter] > average) then result := result + 1; { Print the result } writeln ('The number of values > average is:', result) end { of the then clause of if (( listlen > } else writeln ('Error-input list length is not legal') end.
26
C – for systems work Evolved from ALGOL 68, CPL (63), B
slowly evolved from 1972 through 1988 Similar to Pascal in its available control statements, data structures but lacks complete typechecking especially for functions/procedures lacks safety with pointer arithmetic and explicit casting C introduced a switch statement and has a very flexible for-loop C was developed itself to implement UNIX has been used extensively to create UNIX-based systems and applications software, and it and C++ are the primary languages used in open source software development C did not become standardized until ANSI C in 1989, a newer standard version of C is often called C99
27
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, supplanting Pascal Modula-3 developed in the late 80’s added 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 use the module as the basic data structure the module would encapsulate data structure and procedure to form ADTs unlike Pascal, modules could be separately compiled allowing these languages to be much more useful
28
BASIC BASIC: Beginner’s All-purpose Symbolic Instruction Code
Developed in 1971 designed for introductory programming for liberal arts majors goals: easy to learn and use, be pleasant and friendly (!) 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 many different dialects of BASIC obviously Visual BASIC is the most popular was the choice of the “built-in” programming language for most PCs example code in the notes page Example BASIC program (this is a more recent version of BASIC without line numbers and GO TO statement) REM Basic Example Program REM Input: An integer, listlen, where listlen is less REM than 100, followed by listlen-integer values REM Output: The number of input values that are greater REM than the average of all input values DIM intlist(99) result = 0 sum = 0 INPUT listlen IF listlen > 0 AND listlen < 100 THEN REM Read input into an array and compute the sum FOR counter = 1 TO listlen INPUT intlist(counter) sum = sum + intlist(counter) NEXT counter REM Compute the average average = sum / listlen REM Count the number of input values that are > average FOR counter = 1 TO listlen IF intlist(counter) > average THEN result = result + 1 REM Print the result PRINT "The number of values that are > average is:"; result ELSE PRINT "Error-input list length is not legal" END IF END
29
PROLOG Nonprocedural language based on logic
you don’t really write a program as much as list statements of fact and rules and ask questions in which the system answers for you 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 based on two built-in algorithms resolution unification both are inefficient (intractable) used by some AI researchers A very different language.
30
ADA By 1974, DoD software written in over 450 different languages!
DoD contracted out to have a language designed specifically for all government work led to a study of 26 programming languages, 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 GUI programming, OOP, flexible libraries, control mechanisms for shared data Ada 95 and C++ are roughly equivalent in terms of size and scope sample code in notes page Ada is really like a souped up Pascal, or taking Pascal’s simplicity and adding to it until its overbloated like C++! -- Ada Example Program -- Input: An integer, List_Len, where List_Len is less -- than 100, followed by List_Len-integer values -- Output: The number of input values that are greater -- than the average of all input values with Ada.Text_IO, Ada.Integer.Text_IO; use Ada.Text_IO, Ada.Integer.Text_IO; procedure Ada_Ex is type Int_List_Type is array (1..99) of Integer; Int_List : Int_List_Type; List_Len, Sum, Average, Result : Integer; begin Result:= 0; Sum := 0; Get (List_Len); if (List_Len > 0) and (List_Len < 100) then -- Read input data into an array and compute the sum for Counter := 1 .. List_Len loop Get (Int_List(Counter)); Sum := Sum + Int_List(Counter); end loop; -- Compute the average Average := Sum / List_Len; -- Count the number of values that are > average for Counter := 1 .. List_Len loop if Int_List(Counter) > Average then Result:= Result+ 1; end if; end loop; -- Print result Put ("The number of values > average is:"); Put (Result); New_Line; else Put_Line ("Error-input list length is not legal"); end if; end Ada_Ex;
31
Smalltalk: OOP Roughly a descendant of Simula 67 based on a PhD dissertation from 1969 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 all communication between objects by message passing all objects dynamically bound inheritance subroutines called methods language promoted modularity via objects Kay used Smalltalk at XEROX PARC to develop the first windows environment (1980) see separate notes about Smalltalk
32
C++ C with objects/classes C++ introduced features of
evolved between 1984 and 1985 first large distribution in 1985 2nd and 3rd versions released in 1989 and 1998 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++ introduced features of pre-defined and user-defined classes multiple inheritance and user-defined control over what would be inherited overloaded operators dynamic type binding templated functions and classes, abstract classes C++ also implemented a limited version of exception handling C++ was for many years the most popular language but now has been challenged by Java, Ruby, Python, VB, C# among others
33
Related Languages to C++
Eiffel 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, another hybrid imperative + OO based on Pascal it attempts to be both safe and elegant 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
34
Java Original intention was for device programming (e.g., toasters, tvs) Much like C/C++ in syntax but has many 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 GUI components threads network communication Much safer language than C++ but not necessarily any easier to use Early concern was that Java would be less efficient due to extensive use of dynamic memory and garbage collection, and its interpreted nature
35
Scripting Languages Early scripting languages were simply a list of commands in a file that were then interpreted by another piece of software shell languages for Unix report-generating languages like awk and tcl Many scripting languages can now be compiled, such as Perl, which includes interesting 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) a number of implicit variables such as default parameters passed to built-in functions arrays have dynamic lengths and can be sparse (controlled by the foreach instruction) example code in the notes section Many scripting languages support the web (client-side scripting like JavaScript and server-side like PHP) Example Perl script # Perl Example Program # Input: An integer, $listlen, where $listlen is less # than 100, followed by $listlen-integer values. # Output: The number of input values that are greater than # the average of all input values. ($sum, $result) = (0, 0); $listlen = <STDIN>; if (($listlen > 0) && ($listlen < 100)) { # Read input into an array and compute the sum for ($counter = 0; $counter < $listlen; $counter++) { $intlist[$counter] = <STDIN>; } #- end of for (counter ... # Compute the average $average = $sum / $listlen; # Count the input values that are > average foreach $num { if ($num > $average) { $result++; } } #- end of foreach $num ... # Print result print "Number of values > average is: $result \n"; } #- end of if (($listlen ... else { print "Error--input list length is not legal \n"; }
36
Python and Ruby Both languages have grown out of dissatisfaction with earlier scripting languages (Perl, JavaScript) open source interpreted Python can be compiled Ruby is compiled into an independent ByteCode (like Java) OOP (Ruby is a pure OOPL) Python uses indentation for blocks variables implicitly declared at run-time so there is no compile-time type checking data structures include primitives, objects and tuples rather than arrays pattern-matching facilities like Perl exception handling Ruby is somewhat 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)
37
.Net Combination of languages that can produce code that call upon objects developed in other .Net languages languages include C#, C++, J#, VB, Jscript, ASP) languages use a common type system which provides a common class library 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 from C++, C# obtains pointers, structs, enum types, operator overloading, goto, variable number of parameters for parameter passing objects are more similar to Java adds the foreach instruction improves the switch statement by requiring each clause end with break to ensure that at most, one clause will execute sample code in the notes section // C# Example Program // Input: An integer, listlen, where listlen is less than // , followed by listlen-integer values. // Output: The number of input values that are greater // than the average of all input values. using System; public class Ch2example { static void Main() { int[] intlist; int listlen, counter, sum = 0, average, result = 0; intList = new int[99]; listlen = Int32.Parse(Console.readLine()); if ((listlen > 0) && (listlen < 100)) { // Read input into an array and compute the sum for (counter = 0; counter < listlen; counter++) { intList[counter] = Int32.Parse(Console.readLine()); sum += intList[counter]; } //- end of for (counter ... // Compute the average average = sum / listlen; // Count the input values that are > average foreach (int num in intList) if (num > average) result++; // Print result Console.WriteLine( "Number of values > average is:" + result); } //- end of if ((listlen ... else "Error--input list length is not legal"); } //- end of method Main } //- end of class Ch2example
38
Summary Early development of high level languages dedicated a language to a problem type (e.g., mathematical, list processing, file intensive) Later, features become available so that a particular language could be suitable for any problem (within reason) but where some languages had more convenient or efficient implementation of features for instance, how efficient or easy is it to use pointers? safety has also become a factor (Java is much safer than C++) Today, new languages are developed because of newer features or better implementation/ease of use for features most languages today are OOP, many are scripting/interpreted there are literally thousands of high level languages with new ones being introduced every year
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.