Upload
susan-higgins
View
217
Download
2
Tags:
Embed Size (px)
Citation preview
Invitation to Computer Science 5th 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
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
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
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
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
Invitation to Computer Science, 5th Edition 7
Figure 9.1 Transitions of a High-Level Language Program
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
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)
Invitation to Computer Science, 5th Edition 10
Figure 9.2 Pseudocode Algorithm for Favorite Number
Invitation to Computer Science, 5th Edition 11
Figure 9.3 Ada Program for Favorite Number
Invitation to Computer Science, 5th Edition 12
Figure 9.4 C++ Program for Favorite Number
Invitation to Computer Science, 5th Edition 13
Figure 9.5 C# Program for Favorite Number
Invitation to Computer Science, 5th Edition 14
Figure 9.6 Java Program for Favorite Number
Invitation to Computer Science, 5th Edition 15
Figure 9.6 Java Program for Favorite Number (continued)
Invitation to Computer Science, 5th Edition 16
Figure 9.7 Python Program for Favorite Number
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
Invitation to Computer Science, 5th Edition 18
Figure 9.8 The Converging-Pointers Algorithm for Data Cleanup
Invitation to Computer Science, 5th Edition 19
Figure 9.9 Ada Converging-Pointers Algorithm
Invitation to Computer Science, 5th Edition 20
Figure 9.9 Ada Converging-Pointers Algorithm (continued)
Invitation to Computer Science, 5th Edition 21
Figure 9.10 C++ Converging-Pointers Algorithm
Invitation to Computer Science, 5th Edition 22
Figure 9.10 C++ Converging-Pointers Algorithm (continued)
Invitation to Computer Science, 5th Edition 23
Figure 9.11 C# Converging-Pointers Algorithm
Invitation to Computer Science, 5th Edition 24
Figure 9.11 C# Converging-Pointers Algorithm (continued)
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
Invitation to Computer Science, 5th Edition 26
Figure 9.15 Feature Analysis of Five High-Level Languages
Invitation to Computer Science, 5th Edition 27
Figure 9.15 Feature Analysis of Five High-Level Languages (continued)
Invitation to Computer Science, 5th Edition 28
Figure 9.15 Feature Analysis of Five High-Level Languages (continued)
Invitation to Computer Science, 5th Edition 29
Figure 9.15 Feature Analysis of Five High-Level Languages (continued)
Invitation to Computer Science, 5th Edition 30
Figure 9.15 Feature Analysis of Five High-Level Languages (continued)
Invitation to Computer Science, 5th Edition 31
Figure 9.15 Feature Analysis of Five High-Level Languages (continued)
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
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
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
Invitation to Computer Science, 5th Edition 35
Figure 9.16 Steps in the Software Development Life Cycle
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
Invitation to Computer Science, 5th Edition 37
Figure 9.17 Size Categories of Software Products
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
Invitation to Computer Science, 5th Edition 39
The Software Development Life Cycle (continued)
• Debugging
• Testing, verification, and benchmarking
• Documentation
• Maintenance
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
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
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