1 chapter 1 programming languages evolution of programming languages to run a java program: java...

12
1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate language called bytecode Then the bytecode is interpreted into a particular machine language Java Programming from Thomson Course Tech, adopted by kcluk

Upload: bertina-montgomery

Post on 19-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

1

Chapter 1 Programming Languages

Evolution of Programming Languages

To run a Java program:Java instructions need to be translated into an intermediate language called bytecode

Then the bytecode is interpreted into a particular machine language

Java Programming from Thomson Course Tech, adopted by kclukJava Programming from Thomson Course Tech, adopted by kcluk

Page 2: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

2

Evolution of Programming Languages

• Compiler: A program that translates a program written in a high-level language into the equivalent machine language. (In the case of Java, this machine language is the bytecode.)

• Java Virtual Machine (JVM) - hypothetical computer developed to make Java programs machine independent

Page 3: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

3

Processing a Java Program

• Two types of Java programs: applications and applets

• Source program: Written in a high-level language

• Linker: Combines bytecode with other programs provided by the SDK and creates executable code

• Loader: transfers executable code into main memory

• Interpreter: reads and translates each bytecode instruction into machine language and then executes it

Page 4: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

4

Processing a Java Program

Page 5: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

5

Problem-Analysis-Coding-Execution Cycle

• Algorithm: A step-by-step problem-solving process in which a solution is arrived at in a finite amount of time

Page 6: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

6

Problem-Solving Process

1. Analyze the problem: outline solution requirements and design an algorithm

2. Implement the algorithm in a programming language (Java) and verify that the algorithm works

3. Maintain the program: use and modify if the problem domain changes

Page 7: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

7

Problem-Analysis-Coding-Execution Cycle

Page 8: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

8

Programming Methodologies

• Two basic approaches to programming design:– Structured design – Object-oriented design

Page 9: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

9

Structured Design

1. A problem is divided into smaller subproblems

2. Each subproblem is solved

3. The solutions of all subproblems are then combined to solve the problem

Page 10: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

10

Object-Oriented Design (OOD)

• In OOD, a program is a collection of interacting objects

• An object consists of data and operations

• Steps in OOD:1. Identify objects

2. Form the basis of the solution

3. Determine how these objects interact

Page 11: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

11

Chapter Summary

• Computers understand machine language; it is easiest for programmers to write in high-level languages

• A compiler translates high-level language into machine language

• High-level language steps to execute a program: edit, compile, link, load, and execute

Page 12: 1 Chapter 1 Programming Languages Evolution of Programming Languages To run a Java program: Java instructions need to be translated into an intermediate

12

Chapter Summary

• Algorithm: step-by-step problem-solving process in which a solution is arrived at in a finite amount of time

• Three steps to problem solving: analyze the problem and design an algorithm, implement the algorithm in a programming language, and maintain the program

• Two basic approaches to programming design: structured and object-oriented