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

Preview:

Citation preview

Invitation to Computer Science 5th 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

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

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

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

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

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

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

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

Invitation to Computer Science, 5th Edition 10

Figure 10.1 User Hardware Interface and Programming Languages

Invitation to Computer Science, 5th Edition 11

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

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

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

Invitation to Computer Science, 5th Edition 14

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

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

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

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

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

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

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

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

Invitation to Computer Science, 5th Edition 22

Figure 10.4 HTML Code for a Web Page

Invitation to Computer Science, 5th Edition 23

Figure 10.5 Body of the Web Page Generated by Figure 10.4

Invitation to Computer Science, 5th Edition 24

Figure 10.6 Some HTML Tags

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

Invitation to Computer Science, 5th Edition 26

Figure 10.7 An Example of the HTML <form> Tag

Invitation to Computer Science, 5th Edition 27

Figure 10.8 JavaScript Embedded in an HTML Page

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

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

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

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

Invitation to Computer Science, 5th Edition 32

Figure 10.9 Scheme Program to Add Nonnegative Integers

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

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

Invitation to Computer Science, 5th Edition 35

Figure 10.10 A Prolog Program

Invitation to Computer Science, 5th Edition 36

Figure 10.11 The Logic Programming Paradigm

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

Invitation to Computer Science, 5th Edition 38

Figure 10.12 “Grand Challenge” Computing Problems

Invitation to Computer Science, 5th Edition 39

Figure 10.13(a) Model of SIMD Processing

Invitation to Computer Science, 5th Edition 40

Figure 10.13(b) Model of MIMD Processing

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

Invitation to Computer Science, 5th Edition 42

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

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

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)