42
Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Embed Size (px)

Citation preview

Page 1: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science 5th Edition

Chapter 9

Introduction to High-Level Language Programming

Page 2: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 2

Objectives

In this chapter, you will learn about:

• The language progression

• A family of languages

• Two examples in five-part harmony

• Feature analysis

• Meeting expectations

• Software engineering

Page 3: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

The Language Progression

• Using computers to solve problems – Often involves writing programs in a high-level

programming language

Invitation to Computer Science, 5th Edition 33

Page 4: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Where Do We Stand and What Do We Want?

• Disadvantages of assembly language– Programmer must “manually” manage the

movement of data items – Programmer must take a microscopic view of a task,

breaking it down into tiny subtasks at the level of what is going on in individual memory locations

– Assembly language program is machine specific– Statements are not natural-language-like

Invitation to Computer Science, 5th Edition 44

Page 5: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Where Do We Stand and What Do We Want? (continued)

• Expectations of a program written in a high-level language– Programmer need not manage the details of the

movement of data items within memory– The programmer can take a macroscopic view of

tasks, thinking at a higher level of problem solving

Invitation to Computer Science, 5th Edition 5

Page 6: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 6

Getting Back to Binary

• Compiler– Converts high-level language instructions into

machine language instructions

• Linker– Inserts requested object code from code libraries

into the object code for the requesting program

Page 7: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 7

Figure 9.1 Transitions of a High-Level Language Program

Page 8: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 8

A Family of Languages

• Procedural languages– Program consists of sequences of statements that

manipulate data items– Follow directly from the Von Neumann computer

architecture– Random access memory stores and fetches values

to and from memory cells

Page 9: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 9

Two Examples in Five-Part Harmony

• Favorite number– Figure 9.2 shows pseudocode algorithm – Algorithm implemented in Ada (Figure 9.3), C++

(Figure 9.4), C# (Figure 9.5), Java (Figure 9.6), and Python (Figure 9.7)

Page 10: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 10

Figure 9.2 Pseudocode Algorithm for Favorite Number

Page 11: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 11

Figure 9.3 Ada Program for Favorite Number

Page 12: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 12

Figure 9.4 C++ Program for Favorite Number

Page 13: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 13

Figure 9.5 C# Program for Favorite Number

Page 14: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 14

Figure 9.6 Java Program for Favorite Number

Page 15: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 15

Figure 9.6 Java Program for Favorite Number (continued)

Page 16: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 16

Figure 9.7 Python Program for Favorite Number

Page 17: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 17

Data Cleanup (Again)

• In this problem:– Input is a set of integer data values that may contain

0s, and 0s are considered to be invalid data– Output is to be a clean data set where the 0s have

been eliminated

Page 18: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 18

Figure 9.8 The Converging-Pointers Algorithm for Data Cleanup

Page 19: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 19

Figure 9.9 Ada Converging-Pointers Algorithm

Page 20: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 20

Figure 9.9 Ada Converging-Pointers Algorithm (continued)

Page 21: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 21

Figure 9.10 C++ Converging-Pointers Algorithm

Page 22: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 22

Figure 9.10 C++ Converging-Pointers Algorithm (continued)

Page 23: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 23

Figure 9.11 C# Converging-Pointers Algorithm

Page 24: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 24

Figure 9.11 C# Converging-Pointers Algorithm (continued)

Page 25: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 25

Feature Analysis

• If you have studied one (or more) of the online chapters for Ada, C++, C#, Java, or Python:– Compare them with the features of the other

languages by scanning Figure 9.15

Page 26: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 26

Figure 9.15 Feature Analysis of Five High-Level Languages

Page 27: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 27

Figure 9.15 Feature Analysis of Five High-Level Languages (continued)

Page 28: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 28

Figure 9.15 Feature Analysis of Five High-Level Languages (continued)

Page 29: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 29

Figure 9.15 Feature Analysis of Five High-Level Languages (continued)

Page 30: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 30

Figure 9.15 Feature Analysis of Five High-Level Languages (continued)

Page 31: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 31

Figure 9.15 Feature Analysis of Five High-Level Languages (continued)

Page 32: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 32

Meeting Expectations

• Expectations for programs written in a high-level programming language– Programmer need not manage details of the

movement of data items within memory or pay any attention to exactly where those items are stored

– Programmer can take a macroscopic view of tasks, thinking at a higher level of problem solving

Page 33: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 33

Meeting Expectations (continued)

• Expectations for programs written in a high-level programming language (continued)– Programs written in a high-level language will be

portable rather than machine specific– Programming statements in a high-level language

will be closer to natural language and will use standard mathematical notation

Page 34: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 34

The Big Picture: Software Engineering

• Software development life cycle– Overall sequence of steps needed to complete a

large-scale software project

• Studies have shown that on big projects:– Initial implementation of the program may occupy

only 10–20% of the total time – 25–40% of time is spent on problem specification

and program design– 40–65% is spent on tasks that follow implementation

Page 35: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 35

Figure 9.16 Steps in the Software Development Life Cycle

Page 36: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 36

Scaling Up

• Figure 9.17 categorizes software products in terms of :– Size– Number of programmers needed for development– Duration of the development effort

• Software engineering – Large-scale software development

Page 37: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 37

Figure 9.17 Size Categories of Software Products

Page 38: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 38

The Software Development Life Cycle

• The feasibility study

• Problem specification

• Program design

• Algorithm selection or development, and analysis

• Coding

Page 39: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 39

The Software Development Life Cycle (continued)

• Debugging

• Testing, verification, and benchmarking

• Documentation

• Maintenance

Page 40: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 40

Modern Environments

• Integrated Development Environment– Lets programmer perform a number of tasks within

the shell of a single application program

• Rapid prototyping – Allows miscommunications between the user and

the programmer to be identified and corrected early in the development process

Page 41: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 41

Summary

• In a high-level language, the programmer:– Need not manage storage – Can think about the problem at a higher level– Can use more powerful program instructions that are

more like natural language– Can write a much more portable program

Page 42: Invitation to Computer Science 5 th Edition Chapter 9 Introduction to High-Level Language Programming

Invitation to Computer Science, 5th Edition 42

Summary (continued)

• Software development life cycle– Overall sequence of steps needed to complete a

large-scale software project