Chapter 2 Preview Evolution of the Major Programming Languages The Beginnings of Data Abstraction: SIMULA 67 Orthogonal Design: ALGOL 68 Some Early Descendants of the ALGOLs Programming Based on Logic: Prolog History's Largest Design Effort: Ada Object-Oriented Programming: Smalltalk Combining Imperative ad Object-Oriented Features: C++ An Imperative-Based Object-Oriented Language: Java Scripting Languages The Flagship.NET Language: C# Markup/Programming Hybrid Languages 1 Preview Toward High-level Languages Problem of Scale s 2 The First Generation Computer(1945 ~ 1955) vacuum tubes and plugboards Use vacuum tubes to build calculating engines All programs were done by machine language written by plugboards to control the machine s basic functions. The Second Generation (1955 ~ 1965) Transistors and Batch system Transistor was invented in the mid 1950s. Computer become more reliable since vacuum tubes are replaced by transistors mainframes FORTRAN (Formula Translation) 1957 for scientific calculation (no module, only spaghetti code.) The 1950 s Programming Languages FORTRAN: the first higher level programming language FORTRAN I, II, IV, 77, 90, 95, 2003, 2008 COBOL: the first business oriented language Algol: one of the most influential programming languages ever designed LISP: the first language outside the von Neumann model (Dominant in AI) APL: A Programming Language 3 4 The 1960 s Programming Language - The development of hundreds of programming languages PL/1 designed in 1963-4 supposed to be all purpose combined features of FORTRAN, COBOL and Algol60 and more! translators were slow, huge and unreliable some say it was ahead of its time... Algol68 SNOBOL Simula BASIC The 1970 s Programming Languages Simplicity, Abstraction Algol-W - Nicklaus Wirth and C.A.R.Hoare reaction against 1960s simplicity Pascal small, simple, efficient structures for teaching program C - 1972 - Dennis Ritchie aims for simplicity by reducing restrictions of the type system allows access to underlying system interface with O/S - UNIX 5 6 1
The 1980 s Programming Languages new programming paradigm Ada US Department of Defense European team lead by Jean Ichbiah Functional programming Scheme, ML, Haskell Logic programming Prolog Object-oriented programming Smalltalk, C++, Eiffel The 1990 s and present Programming Languages Internet and web During the 90 s, Object-oriented languages (mostly C++) became widely used in practical applications The Internet and Web drove several phenomena: Adding concurrency and threads to existing languages Increased use of scripting languages such as Perl and Tcl/Tk Java, C# PHP, Ruby, Python,.. 7 8 Programming languages must be designed 1. Higher level independent of the underline machine. 2. General purpose can be applied to a wide range of problems. 9 10 High-level programming Languages Ex) High Level Language C++ Programmer does not need to know the architecture of a specific machine. Machine independent Ex) C++, C, Java, FORTRAN, LISP This code can be recognized by standard C++ compiler which is located in a machine Standard C++ Source code C++ Compiler in any machine Executable Code A programmer does not need to know the structure of a machine!!!! 11 12 2
Standard C++ Source code High Level Languages are potable Advantages of higher-level languages Reduce development time Readable No detailed low level computation Reusable code in program libraries Machine independence (portability) Consistency checks during implementation that can detect errors. Disadvantages of higher-level languages Slower than lower-level language code 13 14 Low-level programming languages A programmer need to know the structure of specific machine. Machine dependent Ex) An assembly languages for a machine This code can be recognized only by Intel Assembler Intel 80X86 Assembly Source code 15 16 Intel 80X86 Assembly Source code Low Level Languages are not potable Advantages of low-level languages Execution is faster than a higher-level language code since a programmer can optimize code. Readable than machine code ex.) The following code is a single operation in machine language. 0001110010000110 The following code is an assembly code ADD R6,R2,R6 ; Add $R2 to $R6 17 18 3
Programming language help programmers to develop software. But small error (logical) can lead entire program result to disaster. Not because of programming language itself but because the human error factor. Ex) The rocket for Mariner (July 22, 1962) destroyed 290 seconds after launch by human error!! If in radar contact with the rocket then do not correct its flight path 19 20 If in radar contact with the rocket then do correct its flight path If in radar contact with the rocket then do not correct its flight path 21 22 (Imperative Programming) Imperative programming action oriented- a computation is viewed as a sequence of actions (instructions). Imperative Commend Sharp distinction between data and program. Supported languages: Fortran, Algol60, Pascal, C (UNIX), COBOL. (Object-Oriented Programming) In object-oriented paradigm, individual data objects are defined by modules of code, called class, which encapsulate data declarations and functionalities (algorithms) for the operation. Supported languages Simula, C++, Java, C# 23 24 4
(Object-Oriented Programming) The characteristics of OO programming 1. Information hiding 2. Data abstraction 3. Message passing 4. Dynamic binding 5. Inheritance (Functional Programming) A computation is specified by a call to defined functions (Preliminary functions). The definition of those functions is intern specified by calls to functions. Those calls may be recursive calls to the function itself or to other defined functions. The chain of junction definitions bottoms out in calls to system Supported Languages LISP, ISWIM, ML, Scheme 25 26 (Functional Programming) Ex) LISP car- returns the first element of its argument list. cdr- returns the rest of the elements minus the first of its arument list car and cdr are the primitive functions in the LISP. If a list L is bound to (c d e f g), (car L) => c; (cdr L) =>(d e f g) From two primitive functions we can build a function second which returns the second element of its argument list as following way: (defun second (L) (car (cdr L))) Based on a subset of the predicate logic (firstorder logic) calculus. The predicate calculus provides axioms(facts) and rules so that one can deduce new facts from other known facts. Logic based program consist of a series of axioms (facts), rules of inference, and a theorem or query to be proved. Supported program Prolog, Fril 27 28 Ex) predicate logic Facts: Phillip, Charles, Andrew, Edward, Mark, William and Harry are male. Elizabeth, Anne, Diana and Sarah are female. Elizabeth and Philip are parents of Charles, Anne, Andrew and Edward. Diana and Charles are parents of William and Harry. Rules: X is Y s brother if X is male and X and Y has same parents. X is Y s sister if X is female and X and Y has same parents. Facts Phillip, Charles, Andrew, Edward, Mark, William and Harry are male. male(philip) male(charles) male(andrew) male(edward) male(mark) male(william) male(harry) Elizabeth, Anne, Diana and Sarah are female female(elizabeth). female(diana). female(anne). female(sarah). 29 30 5
Elizabeth and Philip are parents of Charles, Anne, Andrew and Edward. parents(charles, elizabeth, philip) parents(anne, elizabeth, philip) parents(andrew, elizabeth, philip) parents(edward, elizabeth, philip) Diana and Charles are parents of William and Harry. parrents(william, diana, charles) parrents(harry, diana, charles) Rules: X is Y s brother if X is male and X and Y has same parents. brother(x, y) :- male(x), parents(x, m, f), parents(y, m, f). X is Y s sister if X is female and X and Y has same parents. sister(x, y) :- female(x), parents(x, m, f), parents(y, m, f). 31 32 Query: Are Dianna and Charles parents of William??- parents(william, diana, charles). Is Edward Anne s brother??- brother(edward, anne). Who is Andrew s sister??- sister(x, andrew). 33 6