invitation to computer science 5 th edition chapter 10 the tower of babel

44
Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Upload: dominic-houston

Post on 04-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science 5th Edition

Chapter 10

The Tower of Babel

Page 2: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 2

Objectives

In this chapter, you will learn about:

• The reason for the proliferation of programming languages (Why Babel?)

• Procedural languages

• Special-purpose languages

• Alternative programming paradigms

Page 3: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Why Babel?

• Reasons for the proliferation of programming languages – Proliferation of programming tasks– Different philosophies have developed about how

people should think when they are writing programs

Invitation to Computer Science, 5th Edition 33

Page 4: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Procedural Languages

• Procedural language programs – Tell the computer in a step-by-step fashion how to

manipulate the contents of memory locations

Invitation to Computer Science, 5th Edition 44

Page 5: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 5

Plankalkül

• Programming language designed by Konrad Zus

• Never widely used

• Manuscript describing this programming language – Completed in 1945, but not published until 1972

Page 6: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 6

FORTRAN

• Name derives from FORmula TRANslation

• First high-level programming language

• Designed to support numerical computations

• Allows external libraries of well-written, efficient, and thoroughly tested code modules

Page 7: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 7

COBOL

• Name derives from COmmon Business-Oriented Language

• Developed in 1959 and 1960 – By group headed by Grace Hopper of the U.S. Navy

• Designed to serve business needs such as managing inventories and payrolls

• Programs use natural language phrases

Page 8: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 8

COBOL (continued)

• COBOL programs – Highly portable across many different COBOL

compilers– Quite easy to read– Very well-suited to manipulating large data files

Page 9: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 9

C / C++

• C– Developed in early 1970s by Dennis Ritchie at AT&T

Labs– Originally designed for systems programming, in

particular for writing the operating system UNIX

• Reasons for popularity– Close relationship between C and UNIX– Efficiency

Page 10: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 10

Figure 10.1 User Hardware Interface and Programming Languages

Page 11: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 11

Figure 10.2 C Allows Access to a MemoryCell Address as well as to its Content

Page 12: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 12

C / C++ (continued)

• C includes a data type called pointer

• Variables of pointer type – Contain memory addresses

• Device driver– Program that interacts with an I/O device

• C is the most widely used language for writing system software

Page 13: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 13

C / C++ (continued)

• C++– Developed in the early 1980s by Bjarne Stroustrup,

at AT&T Labs– Provides ability to do object-oriented programming– Commercially released by AT&T in 1985

Page 14: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 14

Figure 10.3 Storing a Value in a Specific Memory Location Using C

Page 15: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Ada

• Named after Ada Augusta Byron Lovelace, daughter of the poet Lord Byron and wife of Lord Lovelace

• Current Ada 2005 standard– Amended version of the Ada 95 standard

• Accepted in:– The defense industry– Other technological applications– As a general-purpose language

Invitation to Computer Science, 5th Edition 15

Page 16: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 16

Java

• Applications– Standalone programs that reside and run on a self-

contained computer

• Applets– Programs designed to run from Web pages– Embedded in Web pages on central servers

• Bytecode – Can be easily translated into any specific machine

language

Page 17: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 17

Python

• Originally created in the early 1990s by Guido van Rossum at Stichting Mathematisch Centrum

• An interpreted language

• Originally used for system administration tasks and as a Web interface language

Page 18: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 18

C# and .NET

• Garbage collection– Reclaiming memory no longer needed by the

program

• Microsoft .NET Framework– Essentially a giant collection of tools for software

development– Handles garbage collection for a C# program

• All .NET programs are compiled into Microsoft Intermediate Language (MSIL) code

Page 19: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 19

C# and .NET (continued)

• Difference between the Java approach and the .NET approach– Java bytecode translator is an interpreter

• More than 40 programming languages:– Have been adapted to fit into the .NET Framework

• April 2003– C# and the CLI were adopted as ISO standards

Page 20: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 20

Special-Purpose Languages

• SQL (Structured Query Language)– Designed to be used with databases– Language used to frame database queries– Developed by IBM– Adopted by ANSI, in 1986, as the standard query

language in the United States

• Databases– Collections of related facts and information– Can be queried

Page 21: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 21

HTML

• HTML document – Consists of the text to be displayed on the Web

page, together with a number of special characters called tags

• HTML tags – Enclosed in angle brackets (< >) and often come in

pairs

Page 22: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 22

Figure 10.4 HTML Code for a Web Page

Page 23: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 23

Figure 10.5 Body of the Web Page Generated by Figure 10.4

Page 24: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 24

Figure 10.6 Some HTML Tags

Page 25: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 25

JavaScript

• Scripting language – “Lightweight” language that is interpreted

• HTTP POST message– Indicates that data is to be passed to the server

• JavaScript function ValidateName() – Placed within <script></script> tags to alert the

browser that these statements are to be interpreted as JavaScript commands

Page 26: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 26

Figure 10.7 An Example of the HTML <form> Tag

Page 27: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 27

Figure 10.8 JavaScript Embedded in an HTML Page

Page 28: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 28

Alternative Programming Paradigms

• Paradigm– Model or mental framework for representing or

thinking about something

• Alternative paradigms for programming languages include viewing a program’s actions as:– A combination of various transformations on items– A series of logical deductions from known facts– Multiple copies of the same subtask

Page 29: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 29

Functional Programming

• Functional programming language – Views every task in terms of functions

• In a functional programming language:– Primitive functions are defined as part of the

language

• Functions– Once defined, can be used in the definition of other

functions

Page 30: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 30

Functional Programming (continued)

• list function– Creates a list out of arguments

• car function – Takes a nonempty list as its argument and produces

as a result the first element in that list

• cdr function – Takes a nonempty list as its argument and produces

as a result the list that remains after the first element has been removed

Page 31: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 31

Functional Programming (continued)

• null?– Has a single list as its argument – Evaluates to true if the list is nil (empty) and to false

if the list is nonempty

• Recursive– Something that is defined in terms of “smaller

versions” of itself

• Side effect – Occurs when a function changes other values that it

has no business changing

Page 32: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 32

Figure 10.9 Scheme Program to Add Nonnegative Integers

Page 33: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 33

Logic Programming

• In logic programming:– Various facts are asserted to be true, and on the

basis of these facts, a logic program can infer or deduce other facts

• Logic programming– Has been used to write expert systems

• Fact – Expresses a property about a single object or a

relationship among several objects

Page 34: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 34

Logic Programming (continued)

• Prolog rule – Declaration of an “if A then B” form, which means

that if A is true (A is a fact), then B is also true (B is a fact)

• Inference engine – Piece of software that is supplied as part of the

language itself

Page 35: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 35

Figure 10.10 A Prolog Program

Page 36: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 36

Figure 10.11 The Logic Programming Paradigm

Page 37: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 37

Parallel Programming

• Parallel processing – Catchall term for a variety of approaches to

computing architectures and algorithm design

• SIMD– Single control unit broadcasts a single program

instruction to multiple ALUs

• MIMD– Interconnected processors independently execute

their own program on their own data

Page 38: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 38

Figure 10.12 “Grand Challenge” Computing Problems

Page 39: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 39

Figure 10.13(a) Model of SIMD Processing

Page 40: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 40

Figure 10.13(b) Model of MIMD Processing

Page 41: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 41

Parallel Programming (continued)

• Message passing primitives– SEND/RECEIVE commands used to exchange

information

• Divide-and-conquer model– Problem is successively partitioned into smaller and

smaller parts and sent off to other processors until each one has only a trivial job to perform

Page 42: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 42

Figure 10.14 A Divide-and-Conquer Approach Using Multiple Processors

Page 43: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 43

Summary

• Each programming language was designed to meet specific needs

• Procedural programming language: FORTRAN

• Object-oriented languages: Ada, Java, C++, C#

• Special-purpose languages: SQL, HTML, JavaScript

• A functional programming language views every task in terms of functions

Page 44: Invitation to Computer Science 5 th Edition Chapter 10 The Tower of Babel

Invitation to Computer Science, 5th Edition 44

Summary (continued)

• Logic programming: various facts are asserted to be true, based on whether the program infers or deduces other facts– Parallel programming– SIMD (single instruction stream/multiple data

stream) – MIMD (multiple instruction stream/multiple data

stream)