Chapter 6 Programming Languages (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
High-Level Programming Languages
Program Design and Development
CS 101 Course Summary December 5, Big Ideas Abstraction Problem solving Fundamentals of programming.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
COMP 14 Introduction to Programming Mr. Joshua Stough February 28, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
Chapter 8 High-Level Programming Languages Nell Dale John Lewis.
Introduction to a Programming Environment
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Chapter 1 Program Design
String Escape Sequences
Introduction to Programming (in C++) Introduction Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Programming Languages
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
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.
Simple Program Design Third Edition A Step-by-Step Approach
CIS Computer Programming Logic
Introduction Computer science is the discipline that seeks to build a scientific foundation for a variety of topics. Computer science provides the underpinnings.
Chapter 1. Introduction.
Levels of Architecture & Language CHAPTER 1 © copyright Bobby Hoggard / material may not be redistributed without permission.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Programming Languages: History & Traditional Concepts CSC 2001.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
1 Introduction Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Chapter 9 Programming Languages
Chapter 6 Programming Languages. © 2005 Pearson Addison-Wesley. All rights reserved 6-2 Chapter 6: Programming Languages 6.1 Historical Perspective 6.2.
CPS120: Introduction to Computer Science
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Computer Programs and Programming Languages What are low-level languages and high-level languages? High-level language Low-level language Machine-dependent.
Chapter 6 Programming Languages © 2007 Pearson Addison-Wesley. All rights reserved.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Copyright © 2015 Pearson Education, Inc. Chapter 6: Programming Languages.
Programming, an introduction to Pascal
Control Structures (B) Topics to cover here: Sequencing in C++ language.
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,
Programming Fundamentals. Overview of Previous Lecture Phases of C++ Environment Program statement Vs Preprocessor directive Whitespaces Comments.
Programming Languages
Chapter 9 ProgrammingLanguages.  Describe the evolution of programming languages from machine language to high-level languages.  Understand how a program.
CPS120: Introduction to Computer Science Variables and Constants.
C H A P T E R T H R E E Type Systems and Semantics Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
CPS120 Introduction to Computer Science High Level Language: Paradigms.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Information and Computer Sciences University of Hawaii, Manoa
Ch. 7 Programming Languages
Chapter 6: Programming Languages
High Level Programming Languages
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
Chapter 6: Programming Languages
Low Level Programming Languages
Overview of Programming Paradigms
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Presentation transcript:

Chapter 6 Programming Languages (1) Introduction to CS 1 st Semester, 2015 Sanghyun Park

Outline  Historical Perspective  Traditional Programming Concepts  Procedural Units(next file)  Language Implementation(next file)  Object-Oriented Programming(skip)  Programming Concurrent Activities(skip)  Declarative Programming(skip)

Programming Language History  ____________ languages(e.g., 5123)  ____________ languages(e.g., ADDI R1, R2, R3)  ____________ languages(e.g., sum = a + b)

First Generation Language  Machine code  Specific to the machine __________  _____ to write  Even harder to read

Second Generation Language  Assembly language  Usually a 1-1 _________ to machine code, e.g., ADDI R1, R2, R3 instead of 5123  ______ to read and write  Still specific to the machine architecture  Better, but not by much

Assemblers  Since assembly language is _____ to machine language, _________ can be done automatically ADDI R1,R2,R3Assembler5123

Third Generation Languages  High level, machine ___________  Much easier to read and write, e.g., money = bills + coins instead of ADDI R1, R2, R3  Fortran and ______ are early examples

Compilers and Interpreters  High-level code needs to be translated into machine language  Compilers do so _______ of time  Interpreters do so ___________ CompilerA = B * C

Programming Paradigms  Languages can be classified by ________  Many different programming languages  Only a few programming paradigms  Imperative/Procedural programming  Object-oriented programming  Functional programming  Logic/Declarative programming

Imperative Programming  Traditionally the most _________  The approach we have seen so far  Program is a _______ of steps  Receives input  Executes a sequence of commands for some computation  Generates output  Examples: Fortran, C, COBOL, Pascal

Object-Oriented Programming  Program is a collection of ________  An object contains __________ describing how that object should respond to various ________ (icon object and list object, for example)  Interaction between objects is via __________ passing  Examples: Smalltalk, C++, Java, C#

Functional Programming  This paradigm views the process of program development as connecting predefined “______ ______”, each of which accepts inputs and produces outputs Lisp Expression: (Divide (Sum Numbers) (Count Numbers)) Example: Lisp, Scheme, ML

Logic/Declarative Programming  Describe the _________ not the solution  The idea here is to discover and implement a ________ problem-solving algorithm  Once this is done, problems can be solved by developing a precise _________ of the problem  A major obstacle is the discovery of the underlying problem-solving algorithm  For this reason early declarative languages were designed for use in _________ applications  More recently, formal logic within ____________ gave a tremendous boost to this paradigm; this resulted in the emergence of logic programming (e.g., Prolog)

Evolution of Programming Paradigms

Traditional Programming Concepts  We consider some of the concepts found in imperative and object-oriented programming languages  We will draw examples from the languages C, C++, C#, Fortran, Java and Pascal  Appendix D contains a brief background of each lang.

Variables  Hold a temporary value that can _______  Some languages insist that a variable should have a ______, while others do not  Example: Java  To store an integer, use an int  To store a real number, use a float  To store a string, use a String

Data Types  Common  integer for ______ numbers (16 or 32 bits)  float for ______ numbers (32 or 64 bits)  character for data consisting of _________ (ASCII (8 bits) or Unicode(16 bits))  Sometimes available  Boolean for 0 or 1 (1 bit)  String for string of characters (variable length)  Many others

Sample Variable Declarations

Literals  Value is explicitly stated in a program  int X = 10(10 is a literal)  String Name = “Bob”(“Bob” is a literal)  Wage = hours  9.00(9.00 is a literal)  Although sometimes necessary, the use of literals should be _______ wherever possible

Literals: Problem  Example  AverageSales = Sales / 10  AverageSalary = Salary / 10  Pay = Hours  10  What does 10 mean in each of the previous examples?  Literals can ______ the meaning of the statements in which they appear  Literals can complicate the task of ________ the program  _________ should be used wherever possible

Constants  Variables that are not allowed to _____  Once defined, it can’t be changed later  Why use constants?  More ________ code  _______ to modify code Pascalconst pi= ; const numDays=10; FortranREAL PARAMETER :: pi = INTEGER PARAMETER :: numDays=10 C,C++const float pi = ; const int numDays=10; Javastatic final float pi = ; static final int numDays=10;

Data Structures  A way of thinking _________ data items as ______ larger data item  Different operations can be performed on different data structures  ________ is the most basic example  We will see others later

Arrays: Homogeneous  A structure that contains multiple values of the ______ kind  An array of integers  A string can be thought of as an array of _________ “This is a string”

Arrays: Homogeneous Example  In C, C++, Java char B[20] = “This is a string”;  You can access any item in an array  Index starts at __, not at __  For instance, if we execute B[2] = ‘u’, the array above will become “_____________”

Arrays: Heterogeneous  A structure that contains multiple values of different kinds

Assignment Statements  Assign to a variable  Value of another variable  Result of a computation  Result from a function  C, C++, Java  Total = Price + Tax;  Pascal  Total := Price + Tax;

Assignment Example  What are A and B at the end of the following? int A, B; A = 2; B = 3; A = A+A; A = A+B; B = B  B;

Operator Precedence  What is A at the end of the following? int A=2, B=3; A = A / B + B * A – A + B;  Most programming languages will do A = (A / B) + (B * A) – A + B;  Use ___________ to override precedence A = A /( (B + B) * (A – (A + B)));

Control Statements  Alter order of execution of statements in a program  ______-entry / ______-exit  Most common ones  if-then-else  while  switch  for

If Statement

While Statement

Switch Statement

For Statement

Comments  ____________ statements within the code  Should not just repeat the code, but __________ on it  ________ by compiler  C, C++, Java /* Insert Comments here */ // Or put them here