Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,

Slides:



Advertisements
Similar presentations
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Advertisements

Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Chapter 1: Introduction
Primitive Data Types There are a number of common objects we encounter and are treated specially by almost any programming language These are called basic.
High-Level Programming Languages
Chapter 8 High-Level Programming Languages Nell Dale John Lewis.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Data types and variables
11/1/06 1 Hofstra University, CSC005 Chapter 8 (Part 3) High Level Programming Languages.
Introduction to a Programming Environment
Chapter 2 Data Types, Declarations, and Displays
JavaScript, Third Edition
Chapter 1 Program Design
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
String Escape Sequences
Object-Oriented Design and High-Level Programming Languages
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Objectives You should be able to describe: Data Types
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Invitation to Computer Science 5th Edition
1 Variables, Constants, and Data Types Primitive Data Types Variables, Initialization, and Assignment Constants Characters Strings Reading for this class:
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
High-Level Programming Languages: C++
Chapter 8 High-Level Programming Languages. 2 Compilers High-level language A language that provides a richer (more English like) set of instructions.
Chapter 9 Object-Oriented Design and High-Level Programming Languages.
CIS Computer Programming Logic
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
Chapters 7, 8, & 9 Quiz 3 Review 1. 2 Algorithms Algorithm A set of unambiguous instructions for solving a problem or subproblem in a finite amount of.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Introduction to Computer Systems and the Java Programming Language.
Chapter 9 Programming Languages
CPS120: Introduction to Computer Science
Chapter 6 Programming Languages © 2007 Pearson Addison-Wesley. All rights reserved.
Property of Jack Wilson, Cerritos College1 CIS Computer Programming Logic Programming Concepts Overview prepared by Jack Wilson Cerritos College.
CPS120: Introduction to Computer Science Decision Making in Programs.
Course Title: Object Oriented Programming with C++ instructor ADEEL ANJUM Chapter No: 03 Conditional statement 1 BY ADEEL ANJUM (MSc-cs, CCNA,WEB DEVELOPER)
Chapter 6 Programming Languages (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Introduction to Java Java Translation Program Structure
Copyright © 2015 Pearson Education, Inc. Chapter 6: Programming Languages.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Chapter 8 High-Level Programming Languages. 2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Chapter 4 Software. Chapter 4: Software Generations of Languages Each computer is wired to perform certain operations in response to an instruction. An.
Programming in Java (COP 2250) Lecture 4 Chengyong Yang Fall, 2005.
Programming and Languages Dept. of Computer and Information Science IUPUI.
Chapter 9 ProgrammingLanguages.  Describe the evolution of programming languages from machine language to high-level languages.  Understand how a program.
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
CPS120: Introduction to Computer Science Variables and Constants.
Introducing Java Chapter 3 Review. Why Program in Java? Java, is an object-oriented programming language. OOP languages evolved out of the need to better.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
CPS120 Introduction to Computer Science High Level Language: Paradigms.
© 2004 Pearson Addison-Wesley. All rights reserved August 27, 2007 Primitive Data Types ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Primitive Data Types August 28, 2006 ComS 207: Programming I (in Java)
The Selection Structure
Building Java Programs Chapter 2
High Level Programming Languages
Chapter 6: Programming Languages
Low Level Programming Languages
Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.
Flow of Control.
The Data Element.
The Data Element.
3.0 - Design A software design specifies how a program will accomplish its requirements A design includes one or more algorithms to accomplish its goal.
Presentation transcript:

Chapter 8 High-Level Programming Languages

8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation, and execution Name four distinct programming paradigms and name a language characteristic of each Describe the following 4 constructs: sequential, selection (branching), looping, and subprograms Construct Boolean expressions and describe how they are used to alter the flow of control of an algorithm

8-3 Chapter Goals Define the concepts of a data type Explain the concept of a parameter

8-4 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions that makes the programmer’s life even easier

8-5 Compilers Figure 8.1 Compilation process

8-6 Interpreters Interpreter A translating program that translates and executes the statements in sequence –Unlike an assembler or compiler which produce machine code as output, which is then executed in a separate step –An interpreter translates a statement and then immediately executes the statement –Interpreters can be viewed as simulators

8-7 Java Introduced in 1996 and swept the computing community by storm Portability was of primary importance Java is compiled into a standard machine language called Bytecode A software interpreter called the JVM (Java Virtual Machine) takes the Bytecode program and executes it

8-8 Programming Language Paradigms What is a paradigm? A set of assumptions, concepts, values, and practices that constitute a way of viewing reality

8-9 Programming Language Paradigms Figure 8.2 Portability provided by standardized languages versus interpretation by Bytecode

8-10 Programming Language Paradigms Figure 8.2 Portability provided by standardized languages versus interpretation by Bytecode

8-11 Programming Language Paradigms Imperative or procedural –FORTRAN, COBOL, BASIC, C Functional model –LISP Logic programming –PROLOG Object-oriented –C++, Java

8-12 Structures in Algorithms or Programming Languages Sequence Executing statements in sequence until an instruction is encountered that changes this sequencing Selection Deciding which action to take Iteration (looping) Repeating an action Subprogram (Both selection and iteration require the use of a Boolean expression)

8-13 Boolean Expressions Boolean expression A sequence of identifiers, separated by compatible operators, that evaluates to true or false Boolean expression can be –A Boolean variable –An arithmetic expression followed by a relational operator followed by an arithmetic expression

8-14 Boolean Expressions Variable A location in memory that is referenced by an identifier that contains a data value Thus, a Boolean variable is a location in memory that can contain either true or false

8-15 Boolean Expressions A relational operator between two arithmetic expressions is asking if the relationship exists between the two expressions For example, xValue < yValue Page 233

8-16 Data Types Data type A description of the set of values and the basic set of operations that can be applied to values of the type

8-17 Some Data Types Integer numbers Real numbers Characters Boolean values Strings

8-18 Integers The range varies depending upon how many bytes are assigned to represent an integer value Some high-level languages provide several integer types of different sizes Use standard arithmetic and relational operations Usually stored in 2’s-complement form

8-19 Reals Like the integer data type, the range varies depending on the number of bytes assigned to represent a real number Many high-level languages have two sizes of real numbers The operations that can be applied to real numbers are the same as those that can be applied to integer numbers

8-20 Characters It takes one byte to represent characters in the ASCII character set Two bytes to represent characters in the Unicode character set Our English alphabet is represented in ASCII, which is a subset of Unicode

8-21 Characters Applying arithmetic operations to characters doesn’t make much sense Comparing characters does make sense, so the relational operators can be applied to characters The meaning of “less than” and “greater than” when applied to characters is “comes before” and “comes after” in the character set

8-22 Boolean The Boolean data type consists of two values: true and false

8-23 Strings A string is a sequence of characters considered as one data value For example: “This is a string.” –Containing 17 characters: one uppercase letter, 12 lowercase letters, three blanks, and a period The operations defined on strings vary from language to language –They include concatenation of strings and comparison of strings in terms of lexicographic order

8-24 Declarations Declaration A statement that associates an identifier with a variable, an action, or some other entity within the language that can be given a name so that the programmer can refer to that item by name

Declarations 8-26 In original BASIC this is not required. Variables that have a $ are strings, others are real. In languages like Java, one has to declare a variable’s type at the beginning of a program (strong typing)

8-26 Declarations Reserved word A word in a language that has special meaning Case-sensitive Uppercase and lowercase letters are considered the same

8-27 Assignment statement Assignment statement An action statement (not an equation) that says to evaluate the expression on the right-hand side of the symbol and store that value into the place named on the left-hand side Named constant A location in memory, referenced by an identifier, that contains a data value that cannot be changed

Assignment Statement Page In original BASIC 10 LET X = 2

8-29 Input/Output Structures In our pseudocode algorithms we have used the expressions Read and Write High-level languages view input data as a stream of characters divided into lines

8-30 Input/Output Structures We do not give examples of input/output statements because the syntax is often quite complex and differs so widely among high-level languages In original BASIC it’s not so tough: 20 PRINT X 30 PRINT “HELLO” 40 PRINT “X = “, X

8-31 Control Structures Control structure An instruction that determines the order in which other instructions in a program are executed Sequence, selection statements, looping statements, and subprogram statements are control structures

8-32 Selection (Branch) Statements Figure 8.3 Flow of control of if statement

8-33 Selection Statements The if statement allows the program to test the state of the program variables using a Boolean expression In original BASIC 20 IF T < 75 THEN PRINT “No jacket is necessary” 40 GOTO PRINT “A light jacket is appropriate” 60 END

8-34 Looping Statements The while statement is used to repeat a course of action Let’s look at two distinct types of repetitions

8-35 Looping Statements Count-controlled loops –Repeat a specified number of times –Use of a special variable called a loop control variable Figure 8.4 Flow of control of while statement

8-36 Looping Statements Count-controlled loops In original BASIC 10 FOR N = 1 to PRINT “HELLO” 30 NEXT N

8-37 Subprogram Statements We can give a section of code a name and use that name as a statement in another part of the program When the name is encountered, the processing in the other part of the program halts while the named code is executed

8-38 Subprogram Statements There are times when the calling unit needs to give information to the subprogram to use in its processing A parameter list is a list of the identifiers with which the subprogram is to work, along with the types of each identifier placed in parentheses beside the subprogram name

8-39 Subprogram Statements Figure 8.5 Subprogram flow of control

8-40 Subprogram Statements Figure 8.5 Subprogram flow of control

8-41 Subprogram Statements In original BASIC 10 GOSUB PRINT “Subroutine returns here 30 GOTO PRINT “Printed within subprogram” 50 RETURN 60 END