CS 152: Programming Language Paradigms January 29 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.

Slides:



Advertisements
Similar presentations
Introduction to Programming Languages Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
Advertisements

About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Programming Languages
Introduction to C Programming
Chapter 1: Preliminaries
Programming Languages Language Design Issues Why study programming languages Language development Software architectures Design goals Attributes of a good.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
1 ) Definition 2) Note on structured and modular programming, and information hiding 3) Example imperative languages 4) Features of imperative languages.
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
CS 354 Overview. Copyright © 2007 Addison-Wesley. All rights reserved. 1–2 Course Topics What is a programming language? What features do programming.
Computers: Tools for an Information Age
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Programming Languages Structure
Computability to Practical Computing - and - How to Talk to Machines.
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
6/27/2015G. Levine1 PROGRAMMING LANGUAGES Text: Programming Languages, Design and Implementation Pratt and Zelkowitz 4 th ed. Prentice-Hall.
CS 153: Concepts of Compiler Design August 25 Class Meeting Department of Computer Science San Jose State University Fall 2014 Instructor: Ron Mak
Summer 02-03Programming Language Concepts1 Programming Language Concepts (CS 360) Lecture 1: Overview, Grammars, and Little Languages Jeremy R. Johnson.
Introduction to C Programming
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
Chapter 2: Algorithm Discovery and Design
Programming Language Concepts
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall 1 Building Applications.
Computer Science 101 Introduction to Programming.
1 Programming Language Concepts Ethics Why study concepts of programming languages (PLs)? PL categories Influences on PL design Problem areas & needs that.
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
CSE 425: Intro to Programming Languages and their Design A Few Key Ideas No particular language is a prerequisite for this course –However you should be.
PZ01A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ01A -- Introduction Programming Language Design and.
CS 152: Programming Language Paradigms February 3 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
CS 153: Concepts of Compiler Design August 24 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
CS 363 Comparative Programming Languages
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
CS 152: Programming Language Paradigms February 10 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
1 Introduction Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Sections
Input, Output, and Processing
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
CS 153: Concepts of Compiler Design October 5 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming.
CS 152: Programming Language Paradigms April 2 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak
CS 153: Concepts of Compiler Design August 26 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
ISBN CS 354 Preliminaries. Copyright © 2006 Addison-Wesley. All rights reserved.1-2 Course Topics What is a programming language? What features.
ISBN Chapter 1 Preliminaries. Copyright © 2009 Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Reasons for Studying Concepts of.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
Theory of Programming Languages Introduction. What is a Programming Language? John von Neumann (1940’s) –Stored program concept –CPU actions determined.
CS 152: Programming Language Paradigms January 27 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
Programming and Languages Dept. of Computer and Information Science IUPUI.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Ada, Scheme, R Emory Wingard. Ada History Department of Defense in search of high level language around Requirements drafted for the language.
1 Types of Programming Language (1) Three types of programming languages 1.Machine languages Strings of numbers giving machine specific instructions Example:
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
a medium allowing humans and computers to communicate an abstraction of the real world a notation for expressing algorithms the set of all syntactically.
History. Development Driven by Function Functions of a Programming Language –To describe computation for use by computers –To describe computation and.
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
Concepts of Programming Languages
Why study programming languages?
PROGRAMMING LANGUAGES
CSCI-235 Micro-Computer Applications
Developing Applications
CMPE 152: Compiler Design August 23 Class Meeting
Programming Languages 2nd edition Tucker and Noonan
Von Neumann Architecture
Principles of Programming Languages
강의 내용 및 방법 접근방법 리포트 시험 Lambda Calculus, Proof of Correctness
CMPE 152: Compiler Design January 29 Class Meeting
Programming Languages, Preliminaries, History & Evolution
Presentation transcript:

CS 152: Programming Language Paradigms January 29 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 2 Small Teams  You will learn better by working in small teams.  Form your own teams of 2 or 3 students each. Choose your team members wisely!  Be sure you’ll be able to meet and communicate with each other and work together well.  No moving to another team. Each team member will receive the same score on the team assignments. me your team name and the list of team members and addresses by Monday, February 3 :

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 3 Major Programming Domains  Scientific Large numbers of floating point computations. Use of arrays. Example: FORTRAN  Business Produce reports, use decimal numbers and characters. Example: COBOL  Artificial intelligence Symbols rather than numbers manipulated. Use of linked lists. Example: LISP _

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 4 Major Programming Domains, cont’d  Systems Need efficiency because of continuous use at a low level. Example: C  Web Markup  Example: HTML Scripting  Example: PHP General-purpose  Example: Java _

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 5 Historic Timelines  Links to more detailed and more recent programming language timelines are posted on the class web page: _

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 6 Take roll!

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 7 A Historic Timeline Programming Languages: Principles and Practice, 3 rd ed. Kenneth Louden & Kenneth Lambert (c) 2012 Course Technology. All rights reserved

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 8 FORTRAN  FORTRAN: FORmula TRANslation language Developed by John Backus in the early 1950s. Reflected the architecture of a particular type of machine. Lacked the structured control statements and data structures of later high-level languages.  Popular with scientists and engineers for its support for algebraic notation and floating-point numbers.  The language has evolved and is still used today. FORTRAN IV FORTRAN 77 FORTRAN 90 FORTRAN 95 FORTRAN

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 9 FORTRAN DOUBLE PRECISION NUMBER, ROOT C DO 500 I = 1, 3 C 5 WRITE (6, 10) 10 FORMAT ('ENTER A NUMBER') C READ (5,100) NUMBER 100 FORMAT (F5.1) C IF (NUMBER.GE. 0.0) GO TO 175 WRITE (6, 150) 150 FORMAT ('*** THE NUMBER MUST NOT BE NEGATIVE.') GOTO 5 C 175 ROOT = DSQRT(NUMBER) C WRITE (6,200) NUMBER, ROOT 200 FORMAT ('THE SQUARE ROOT OF ', F5.1, ' IS ', F15.10) C 500 CONTINUE C PAUSE STOP END

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 10 COBOL  Common Business Oriented Language Primary domain is in business, finance, and administrative systems for companies and governments. Created by a committee of researchers from private industry, universities, and the U.S. government (specifically, the Department of Defense) in Grace Hopper is “the mother of the COBOL language”. Specifications completed in December  A COBOL program is divided into four divisions: IDENTIFICATION DIVISION ENVIRONMENT DIVISION DATA DIVISION PROCEDURE DIVISION

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 11 COBOL  Key design goals English-like syntax to enable non-programmers (managers and users) to read and understand the code. A simple language  No pointers  No user-defined types  No user-defined functions Highly portable  Machine dependencies are limited to the ENVIRONMENT DIVISION.  FORTRAN (for scientific applications) and COBOL (for business applications) were the most popular programming languages during the 1960s and 1970s.

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 12 COBOL  Example PROCEDURE DIVISION statements: Is it English-like? READ StudentFile AT END SET EndOfStudentFile TO TRUE END-READ PERFORM UNTIL EndOfStudentFile ADD 1 TO StudentCount OF WorkTotals IF Male ADD 1 TO MaleCount OF WorkTotals ELSE ADD 1 TO FemaleCount OF WorkTotals END-IF READ StudentFile AT END SET EndOfStudentFile TO TRUE END-READ END-PERFORM Demo

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 13 A Historic Timeline Programming Languages: Principles and Practice, 3 rd ed. Kenneth Louden & Kenneth Lambert (c) 2012 Course Technology. All rights reserved

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 14 Algol  Algol: Algorithmic Language released in 1960 Provided a standard notation for computer scientists to publish algorithms in journals. John Backus was a major contributor.  Structured control statements Sequencing (begin-end blocks) Loops (for loop) Selection (if and if-else statements)  Different numeric types  Introduced the array structure  Supported procedures Including recursive procedures

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 15 The Algol Family  A large number of high-level languages descended from Algol, including: Pascal: language for teaching programming in the 1980s Ada: for embedded applications of U.S. Dept. of Defense  Algol control structures are present in today’s languages, including Java, C, C++, etc. _

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 16 Example Pascal Program PROGRAM Newton; CONST epsilon = 1e-6; VAR number : integer; root, sqroot : real; BEGIN REPEAT writeln; write('Enter new number (0 to quit): '); read(number); IF number = 0 THEN BEGIN writeln(number:12, 0.0:12:6); END

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 17 Example Pascal Program, cont’d ELSE IF number < 0 THEN BEGIN writeln('*** ERROR: number < 0'); END ELSE BEGIN sqroot := sqrt(number); writeln(number:12, sqroot:12:6); writeln; root := 1; REPEAT root := (number/root + root)/2; writeln(root:24:6, 100*abs(root - sqroot)/sqroot:12:2, '%') UNTIL abs(number/sqr(root) - 1) < epsilon; END UNTIL number = 0 END. Demo

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 18 Ada  The Ada language was developed by the U.S. Department of Defense (DoD). The most extensive and expensive language design effort.  1974: DoD projects used over 450 different languages.  1975: Military services convened to: Identify requirements for a new DoD language. Evaluate existing languages. Recommend adoption or implementation of a language.  1979: Four language proposals were considered, all based on the Pascal language. The winner was designed by Cii Honeywell/Bull from France. Named Ada after Ada Lovelace, the first computer programmer.

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 19 Example Ada Program -- Integer calculator program. Takes lines of input consisting of --, and applies each one to a display value. The -- display value is printed at each step. The operator is one of =, -- +, -, *, /, or ^, which correspond to assign, add, subtract, multiply -- divide, and raise, respectively. The display value is initially zero. -- The program terminates on a input of q. -- with Text_IO; with Gnat.Io; use Gnat.Io; procedure Calc is Op: Character; -- Operation to perform. Disp: Integer := 0; -- Contents of the display. In_Val: Integer; -- Input value used to update the display. begin loop -- Print the display. Put(Disp); New_Line; -- Promt the user. Put("> ");

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 20 Example Ada Program, cont’d -- Skip leading blanks and read the operation. loop Get(Op); exit when Op /= ' '; end loop; -- Stop when we're supposed to. exit when Op = 'Q' or Op = 'q'; -- Read the integer value (skips leading blanks) and discard the -- remainder of the line. Get(In_Val); Text_IO.Skip_Line; -- Apply the correct operation. case Op is when '=' => Disp := In_Val; when '+' => Disp := Disp + In_Val; when '-' => Disp := Disp - In_Val; when '*' => Disp := Disp * In_Val; when '/' => Disp := Disp / In_Val; when '^' => Disp := Disp ** In_Val; when '0'..'9' => Put_Line("Please specify an operation."); when others => Put_Line("What is " & Op & "?"); end case; end loop; end Calc;

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 21 The von Neumann Architecture  Most modern programming languages still retain the von Neumann machine architecture. An area of memory containing both programs and data. A single CPU that sequentially executes program instructions fetched from memory.  : The first five decades of computing. Hardware improvements led us into the Information Age. Moore’s Law: Hardware speeds increase by a factor of 2 every 18 months. _

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 22 The von Neumann Architecture, cont’d Concepts of Programming Languages, 10 th ed. Robert W. Sebesta (c) 2012 Pearson. All rights reserved

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 23 Beyond the von Neumann Architecture  But we are now reaching the limits of physics. To increase performance, we now have multicore machines.  Programs are becoming larger and more complex. A model of computation that relies on changes to the values of variables makes large programs difficult to debug. What improvements do we need in software?  Programming languages need not be based on a particular model of hardware.  Languages need only to support models of computation suitable for various styles of problem solving.

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 24 Example: The Lambda Calculus  A computational model developed by the mathematician Alonzo Church in the 1930s. Based on the theory of recursive functions. Express computations by variable binding and substitution.  Lisp: A programming language that uses the functional model of computation. Created in the late 1950s by John McCarthy at M.I.T. and later at Stanford University. Although Lisp runs on a von Neumann architecture, its computational model does not depend on the von Neumann model. _

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 25 Beyond the von Neumann Architecture, cont’d  Other non-von Neumann computational models: Parallel processing models. A formal logic model with automatic theorem proving. A model involving the interaction of objects via message passing. _

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 26 The Most Important Concept  What is the most important concept in computer science? Abstraction  Computer science deals with information and with complexity. We make complexity manageable by judiciously reducing it whenever possible. Computation is the art of carefully throwing away information. Given an overwhelming collection of data, reduce it to a useable result by discarding most of its content.  Abstraction: Treat something complex as if it were simpler by throwing away detail. _

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 27 Programming Language Abstractions  Two types of programming language abstractions: Data abstraction Control abstraction  Data abstractions Simplify the behavior and attributes of data. Examples: numbers, character strings, search trees  Control abstractions Simplify properties of the transfer of control. Examples: loops, conditional statements, procedure calls _

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 28 Programming Language Abstractions, cont’d  Abstractions can also be categorized by levels. How much information is contained or hidden in the abstraction? An orthogonal axis to data and control.  Basic abstractions Collect the most localized machine information.  Structured abstractions Collect intermediate information about the structure of a program.  Unit abstractions Collect large-scale information in a program.

SJSU Dept. of Computer Science Spring 2014: January 29 CS 152: Programming Language Paradigms © R. Mak 29 Programming Language Abstractions, cont’d datacontrol basic structured unit basic data structured data unit data basic control structured control unit control TYPE LEVEL