Principles of Programming Languages Topic: Introduction Professor Louis Steinberg



Similar documents
Lecture 1: Introduction

Programming Languages

CSC Software II: Principles of Programming Languages

CSE 307: Principles of Programming Languages

CSCI 3136 Principles of Programming Languages

What is a programming language?

n Introduction n Art of programming language design n Programming language spectrum n Why study programming languages? n Overview of compilation

Chapter 1. Dr. Chris Irwin Davis Phone: (972) Office: ECSS CS-4337 Organization of Programming Languages

Programming language concepts

Announcements FORTRAN ALGOL COBOL. Simula & Smalltalk. Programming Languages

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

1.1 WHAT IS A PROGRAMMING LANGUAGE?

Chapter 6: Programming Languages

History of Programming Languages

Functional Programming. Functional Programming Languages. Chapter 14. Introduction

Programming Language Pragmatics

Evolution of the Major Programming Languages

CSE 130 Programming Language Principles & Paradigms

Functional Programming

1/20/2016 INTRODUCTION

Fall 2012 Q530. Programming for Cognitive Science

Division of Mathematical Sciences

Semester Review. CSC 301, Fall 2015

Ch. 10 Software Development. (Computer Programming)

McGraw-Hill The McGraw-Hill Companies, Inc.,

The Evolution of Programming Languages

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

Understanding Programming Languages

Chapter 13 Computer Programs and Programming Languages. Discovering Computers Your Interactive Guide to the Digital World

Chapter 13: Program Development and Programming Languages

Chapter 5 Names, Bindings, Type Checking, and Scopes

Language Processing Systems

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Concepts of Programming Languages: A Unified Approach. Karl Abrahamson

02 B The Java Virtual Machine

Programming Languages

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

Moving from CS 61A Scheme to CS 61B Java

Asogwa Tochukwu Chijindu Department of Computer Engineering, Enugu State University of Science and Technology(ESUT), Enugu, Nigeria.

DEGREE PLAN INSTRUCTIONS FOR COMPUTER ENGINEERING

Object-Oriented Software Specification in Programming Language Design and Implementation

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding

COS 301 Programming Languages

Computer Science/Software Engineering

Compilers. Introduction to Compilers. Lecture 1. Spring term. Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.

Course Goal CMSC 330: Organization of Programming Languages. Studying Programming Languages. All Languages Are (Kind of) Equivalent.

Structure of Presentation. The Role of Programming in Informatics Curricula. Concepts of Informatics 2. Concepts of Informatics 1

Compiler Construction

How to make the computer understand? Lecture 15: Putting it all together. Example (Output assembly code) Example (input program) Anatomy of a Computer

Glossary of Object Oriented Terms

Chapter 13: Program Development and Programming Languages

Department of Computer Science

1 Idioms, Patterns, and Programming

CS 51 Intro to CS. Art Lee. September 2, 2014

Computer Programming I

Database trends: XML data storage

THE ROLE OF PROGRAMMING PARADIGMS IN THE FIRST PROGRAMMING COURSES. 1. Introduction

Chapter 15 Functional Programming Languages

Programming Languages

Programming Language Concepts for Software Developers

Curriculum Map. Discipline: Computer Science Course: C++

ATSBA: Advanced Technologies Supporting Business Areas. Programming with Java. 1 Overview and Introduction

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Datavetenskapligt Program (kandidat) Computer Science Programme (master)

Evolution of the Major Programming Languages

C Compiler Targeting the Java Virtual Machine

programming languages, programming language standards and compiler validation

Programming Languages

Lecture 9. Semantic Analysis Scoping and Symbol Table

CS 140: Introduction to Computer Science A Brief History of Computer Science. Edwin Rodríguez

Image credits:

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Compiler I: Syntax Analysis Human Thought

How To Understand Programming Languages And Programming Languages

COMPUTER SCIENCE. 1. Computer Fundamentals and Applications

Programming Languages in Artificial Intelligence

Data Abstraction and Hierarchy

Semantic Analysis: Types and Type Checking

Levels of Programming Languages. Gerald Penn CSC 324

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

On the Design of an Object Oriented Programming Language

Ed. v1.0 PROGRAMMING LANGUAGES WORKING PAPER DRAFT PROGRAMMING LANGUAGES. Ed. v1.0

Lexical analysis FORMAL LANGUAGES AND COMPILERS. Floriano Scioscia. Formal Languages and Compilers A.Y. 2015/2016

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science

CS 40 Computing for the Web

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

Parsing Technology and its role in Legacy Modernization. A Metaware White Paper

COURSE CODE: CSC 411 Organization of Programming Languages

Eastern Washington University Department of Computer Science. Questionnaire for Prospective Masters in Computer Science Students

School of Computer Science

The First Report on Scheme Revisited

On Understanding Types, Data Abstraction, and Polymorphism

Charles Dierbach. Wiley

02-201: Programming for Scientists

Artificial Intelligence. Class: 3 rd

Transcription:

Principles of Programming Languages Topic: Introduction Professor Louis Steinberg CS 314, LS,LTM: L1: Introduction 1

Contacts Prof. Louis Steinberg lou @ cs.rutgers.edu x5-3581 401 Hill TA: to be announced Class web site http: //www.remus.rutgers/cs314/steinberg CS 314, LS,LTM: L1: Introduction 2

Books Kenneth Louden, Programming Languages Kenneth Reek, Pointers on C Kip Irvine, C++ and Object-Oriented Programming Clocksin & Mellish, Programming in Prolog CS 314, LS,LTM: L1: Introduction 3

Work Midterm (Friday 3/5 2:50-4:10PM ) Final 3 projects Homework In-lab programming test (?) CS 314, LS,LTM: L1: Introduction 4

Topics Introduction Formal Languages - RE s, BNF, context-free grammars, parsing Functional Programming (Scheme) Names, Bindings, Memory management Imperative Programming (C) Parameter Passing ADT s, Object-oriented Design (C++) Logic Programming (Prolog) Types Parallel Programming? Threads and monitors? CS 314, LS,LTM: L1: Introduction 5

Course Goals To gain an understanding of the basic structure of programming languages: Data types, control structures, naming conventions,... To learn the principles underlying all programming languages: So that it is easier to learn new languages To study different language paradigms: Functional (Scheme), Imperative (C), Object-Oriented (C++, Java), Logic (Prolog) So that you can select an appropriate language for a task CS 314, LS,LTM: L1: Introduction 6

What is a programming language? a language intended for use by a person to express a process by which a computer can solve a problem -Hope and Jipping a set of conventions for communicating an algorithm - E. Horowitz the art of programming is the art of organizing complexity - Dijkstra, 1972 CS 314, LS,LTM: L1: Introduction 7

Anthropomorphism Whenever a human term (e.g., language ) is used about computers, ask: How analogous How differs CS 314, LS,LTM: L1: Introduction 8

Desiderata for PL Design Readable comments, names, ( ) syntax Simple to learn Orthogonal - small number of concepts combine regularly and systematically (without exceptions) Portable language standardization Abstraction control and data structures that hide detail Efficient CS 314, LS,LTM: L1: Introduction 10

Why learn more than one PL? So you can choose the right language for a given problem If all you have is a hammer, every problem looks like a nail CS 314, LS,LTM: L1: Introduction 11

Why learn more than one PL? So you can learn a new language more easily later As your job changes, you may need to used different languages As our understanding of programming improves, new languages are created To learn new ways of thinking about problems Different languages encourage you to think about problems in different ways Paradigms CS 314, LS,LTM: L1: Introduction 12

What is a Paradigm A way of looking at a problem and seeing a program What kind of parts do you look for? Problem: Print a large X of size n. E.g., size 5 is X X X X X X X X X CS 314, LS,LTM: L1: Introduction 13

Imperative Paradigm A program is: A sequence of state-changing actions Manipulate an abstract machine with: Variables that name memory locations Arithmetic and logical operations Reference, evaluate, assign operations Explicit control flow statements Fits the Von Neumann architecture closely Key operations: Assignment and GoTo CS 314, LS,LTM: L1: Introduction 17

Imperative Paradigm Sum up twice each number from 1 to N. Fortran SUM = 0 DO 11 K=1,N SUM = SUM + 2*K 11 CONTINUE C sum = 0; for (k = 1; k <= n; ++k) sum += 2*k; Pascal sum := 0; for k := 1 to n do sum := sum + 2*k; CS 314, LS,LTM: L1: Introduction 18

Functional Paradigm A program is: Composition of operations on data Characteristics (in pure form): Name values, not memory locations Value binding through parameter passing Recursion rather than iteration Key operations: Function Application and Function Abstraction Based on the Lambda Calculus CS 314, LS,LTM: L1: Introduction 19

Functional Paradigm Scheme (define (sum n) (if (= n 0) 0 (+ (* n 2) (sum (- n 1))) ) ) (sum 4) evaluates to 20 CS 314, LS,LTM: L1: Introduction 20

Logic Paradigm A program is: Formal logical specification of problem Characteristics (in pure form): Programs say what properties the solution must have, not how to find it Solutions are obtained through a specialized form of theorem-proving Key operations: Unification and NonDeterministic Search Based on First Order Predicate Logic CS 314, LS,LTM: L1: Introduction 21

Logic Paradigm sum(0,0). sum(n,s) :- N>0, NN is N - 1, sum(nn, SS), S is N * 2 + SS. Prolog?- sum(1,2). yes?- sum (2,4). no?-sum(20,s). S = 420?-sum (X,Y). X = 0 = Y CS 314, LS,LTM: L1: Introduction 22

Object-Oriented Paradigm A program is: Communication between abstract objects Characteristics: Objects collect both the data and the operations Objects provide data abstraction Can be either imperative or functional (or logical) Key operation: Message Passing or Method Invocation CS 314, LS,LTM: L1: Introduction 23

Object-oriented Paradigm class intset : public Set { public: intset() { } //inherits Set add_element(), Set del_element() //from Set class, defined as a set of Objects } public int sum( ){ } int s = 0; SetEnumeration e = new SetEnumeration(this); while (e.hasmoreelements()) do {s = s + ((Integer)e.nextElement()).intValue();} return s; Java CS 314, LS,LTM: L1: Introduction 24

Translation Compilation: Program is translated from a highlevel language into a form that is executable on an actual machine Interpretation: Program is translated and executed one statement at a time by a virtual machine Some PL systems are a mixture of these two E.g., Java foo.java Source Input Intermediate code javac Translator Virtual Machine java (JVM) foo.class bytecode Intermediate code Output CS 314, LS,LTM: L1: Introduction 25

Compilation scanner optimizer parser code generator intermediate code generator assembler linker CS 314, LS,LTM: L1: Introduction 26

scanner parser Compilation position = initial + rate * 60; id1 := id2 + id3 * 60 optimizer code generator intermediate code generator assembler linker CS 314, LS,LTM: L1: Introduction 27

Compilation scanner parser intermediate code generator symbol table (position,...) (initial, ) (rate, ) tmp1 = inttoreal (60) tmp2 = id3 * tmp1 tmp3 = id2 + tmp2 id1 = tmp3 := parse tree id1 + id2 * id3 int-to-real 60 CS 314, LS,LTM: L1: Introduction 28

Compilation tmp2 = id3 * 60.0 id1 = id2 + tmp2 movf id3, R2 mulf #60.0, R2 movf id2, R1 addf R2, R1 movf R1, id1 optimizer code generator assembler linker move R1, R-base, R-offset movf R1, 45733 CS 314, LS,LTM: L1: Introduction 29

History of PLs Prehistory 300 B.C. Greece, Euclid invented the greatest common divisor algorithm - oldest known algorithm ~1820-1850 England, Charles Babbage invented two mechanical computational devices difference engine analytical engine Countess Ada Augusta of Lovelace, first computer programmer Precursors to modern machines 1940 s United States, ENIAC developed to calculate trajectories CS 314, LS,LTM: L1: Introduction 30

History of PLs 1950 s United States, first high-level PLs invented Fortran 1954-57, John Backus (IBM on 704) designed for numerical scientific computation fixed format for punched cards implicit typing only counting loops, if test versus zero only numerical data 1957 optimizing Fortran compiler translates into code as efficient as hand-coded CS 314, LS,LTM: L1: Introduction 31

History of PLs Algol60 1958-60, designed by international committee for numerical scientific computation [Fortran] block structure with lexical scope free format, reserved words while loops, recursion explicit types BNF developed for formal syntax definition Cobol 1959-60, designed by committee in US, manufacturers and DoD for business data processing records focus on file handling English-like syntax CS 314, LS,LTM: L1: Introduction 32

History of PLs APL 1956-60 Ken Iverson, (IBM on 360, Harvard) designed for array processing functional programming style LISP 1956-62, John McCarthy (MIT on IBM704, Stanford) designed for non-numerical computation uniform notation for program and data recursion as main control structure garbage collection Snobol 1962-66, Farber, Griswold, Polansky (Bell Labs) designed for string processing powerful pattern matching CS 314, LS,LTM: L1: Introduction 33

History of PLs PL/I 1963-66, IBM designed for general purpose computing [Fortran, Algol60, Cobol] user controlled exceptions multi-tasking Simula67 1967, Dahl and Nygaard (Norway) designed as a simulation language [Algol60] data abstraction inheritance of properties Algol68 1963-68, designed for general purpose computing [Algol60] orthogonal language design interesting user defined types CS 314, LS,LTM: L1: Introduction 34

History of PLs Pascal 1969, N. Wirth(ETH) designed for teaching programming [Algol60] 1 pass compiler call-by-value semantics Prolog 1972, Colmerauer and Kowalski designed for Artificial Intelligence applications theorem proving with unification as basic operation logic programming Recent C 1974, D. Ritchie (Bell Labs) designed for systems programming allows access to machine level within high-level PL efficient code generated CS 314, LS,LTM: L1: Introduction 35

History of PLs Clu 1974-77, B. Liskov (MIT) designed for simulation [Simula] supports data abstraction and exceptions precise algebraic language semantics attempt to enable verification of programs Smalltalk mid-1970s, Alan Kay (Xerox Parc), considered first real object-oriented PL, [Simula] encapsulation, inheritance easy to prototype applications hides details of underlying machine Scheme mid-1970s, Guy Steele, Gerald Sussman (MIT) Static scoping and first-class functions CS 314, LS,LTM: L1: Introduction 36

History of PLs Concurrent Pascal 1976 Per Brinch Hansen (U Syracuse) designed for asynchronous concurrent processing [Pascal] monitors for safe data sharing Modula 1977 N. Wirth (ETH), designed language for large software development [Pascal] to control interfaces between sets of procedures or modules real-time programming Ada 1979, US DoD committee designed as general purpose PL explicit parallelism - rendezvous exception handling and generics (packages) CS 314, LS,LTM: L1: Introduction 37

History of PLs C++ 1985, Bjorne Stroustrup (Bell Labs) general purpose goal of type-safe object-oriented PL compile-time type checking templates Java ~1995, J. Gosling (SUN) aimed at portability across platform through use of JVM - abstract machine to implement the PL aimed to fix some problems with previous OOPLs multiple inheritance static and dynamic objects ubiquitous exceptions thread objects CS 314, LS,LTM: L1: Introduction 38

http://www.oreilly oreilly.com/pub/a/.com/pub/a/oreilly/news/languageposter_0504.html CS 314, LS,LTM: L1: Introduction 39