170 likes | 181 Views
Understand why there are so many programming languages, their differences, and how each one meets specific needs. Explore procedural languages like Fortran and COBOL, as well as object-oriented programming and special-purpose languages.
E N D
Chapter 8 The Tower of Babel
Chapter Outline • Procedural languages • Fortran, COBOL, PASCAL, C, Ada • Object-oriented programming • Special-purpose languages • SEL, Perl, HTML, XML • Alternative programming paradigms • Functional programming
Why Babel? • Why are there so many different programming languages? • Each programming language was designed to meet specific needs. • One program may be better suited than others for writing certain kinds of programs. • Similar to automobile market
Example • C++ was not designed with engineering applications in mind • For example, there is no operator for exponentiation (exp, power are all defined in math.h> • Report writing with columns of figures and blocks of information is better handled by COBOL. • Database query, Web page construction…
Procedural Languages • Also known as imperative languages • A program written in a procedural language consists of sequences of statements that manipulate data items. • Programmers devise the appropriate step-by-step sequence of “imperative commands”– instructions in the programming language– that will accomplish the desired task. • Follow directly from the Von Neumann architecture described in Chapter 5.
Examples • FORTRAN, COBOL, Pascal, C, Ada. • Differ in: • how the statements must be arranged on a line • how variables can be named • how a new value is assigned to a variable • how the flow control is handled • I/O statements • how to break programs into modules and how modules share information • We will NOT study the syntactical differences among these languages. • Will focus on the history and “intent” of each one.
FORTRAN • FORmula TRANslation • Affiliation with formulas or engineering-type applications • Developed in the mid-1950s by IBM. First released in 1957. • The first high-level programming language • Exponentiation, extend-precision arithmetic, complex number system • FORTRAN II, FORTRAN IV, FORTRAN 77, FORTRAN 90, High performance FORTRAN
Example 10 IF (NUMBER .LT. 0) GO TO 20 . . READ (*,*) NUMBER GO TO 10 20 …
Flow Control with GO TO • There is no while statement in FORTRAN. Use GO TO to implement looping. • Excessive and careless use of GO TOs can make a program very difficult to read. • Spaghetti code
Features • Designed to support numerical computations • Optimize the resulting object code • A large and well-tested FORTRAN library exists. • Old dog, new tricks
COBOL • COmmon Business-Oriented Language • Developed in 1959-1960 by Grace Hopper of U.S. Navy. • Designed to serve business needs such as managing inventories and payrolls. • Processing in the business world concerns updating “master files” with changes from “transaction files”. • Summary reports are most important output products.
Features of COBOL • More adept in handling file input than keyboard input. • Attention was paid to input/output formatting • English-like statements • Sum = a+ b ; (C++) • ADD A TO B GIVING SUM. (COBOL) • Y2K problem • http://www.cobol.org
Pascal • Named after Blaise Pascal • Developed by Niklaus Wirth in 1970s. • Easy to learn and help enforce good programming techniques. • Designed for teaching programming • Similar to pseudo-code. • Delphi uses Pascal as its language core.
C • Developed in the 1970s by Dennis Ritchie at AT&T Bell lab. • Originally designed for systems programming – UNIX OS. • C has become a popular general-purpose language for two main reasons: • Relationship between C and UNIX • Efficiency • Low-level memory manipulation by pointer • Device-driver
Ada • Common high-level language for use by defense contractors. • Started in mid 1970s. • Requirements on efficiency, reliability, readability and maintainability. • Ada, Ada 9X, Ada 95. • Multi-processing capability, OO • http://www.adahome.com
Ada Example with Text_IO; use Text_IO; procedure Forever is begin loop Put_Line("Hello again!"); end loop; end Forever;
The PIE of OOP Inheritance Polymorphism Encapsulation