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



Similar documents
CSCI 3136 Principles of Programming Languages

Programming Languages

1/20/2016 INTRODUCTION

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

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

CSE 307: Principles of Programming Languages

Image credits:

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

What is a programming language?

Language Processing Systems

CSE 130 Programming Language Principles & Paradigms

Principles of Programming Languages Topic: Introduction Professor Louis Steinberg

CA Compiler Construction

Lecture 1: Introduction

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

Programming Languages

COS 301 Programming Languages

Semester Review. CSC 301, Fall 2015

Lecture 9. Semantic Analysis Scoping and Symbol Table

Chapter 15 Functional Programming Languages

Dr. Angela Guercio. Spring 2011

Computer Programming. Course Details An Introduction to Computational Tools. Prof. Mauro Gaspari:

Programming Language Pragmatics

CSCI E 98: Managed Environments for the Execution of Programs

Computer Science Theory. From the course description:

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

Artificial Intelligence. Class: 3 rd

Fundamentals of Programming Languages

Programming Languages

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

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

Numerical Analysis. Professor Donna Calhoun. Fall 2013 Math 465/565. Office : MG241A Office Hours : Wednesday 10:00-12:00 and 1:00-3:00

Programming Language Design and Implementation. Wes Weimer MW 2:00 3:15 Thornton E-303

CSCE 314 Programming Languages

02-201: Programming for Scientists

CS 40 Computing for the Web

Evolution of the Major Programming Languages

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

Programming Languages

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

CS 2302 Data Structures Spring 2015

Lesson 06: Basics of Software Development (W02D2

CSC Software II: Principles of Programming Languages

CS 525 Advanced Database Organization - Spring 2013 Mon + Wed 3:15-4:30 PM, Room: Wishnick Hall 113

Web-Based Database Applications ITP 300x (3 Units)

Chapter 6: Programming Languages

03 - Lexical Analysis

Semantic Analysis: Types and Type Checking

Announcements FORTRAN ALGOL COBOL. Simula & Smalltalk. Programming Languages

Sample Syllabus (C++) CSCI 1301 Introduction to Programming Principles

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

MIS630 Data and Knowledge Management Course Syllabus

Functional Programming. Functional Programming Languages. Chapter 14. Introduction

Programming Languages & Tools

Introduction. Compiler Design CSE 504. Overview. Programming problems are easier to solve in high-level languages

Assessment for Master s Degree Program Fall Spring 2011 Computer Science Dept. Texas A&M University - Commerce

AUTOMATIC EVALUATION OF COMPUTER PROGRAMS USING MOODLE S VIRTUAL PROGRAMMING LAB (VPL) PLUG- IN

Master of Science (M.S.), Major in Software Engineering

Compiler Construction

DEGREE PLAN INSTRUCTIONS FOR COMPUTER ENGINEERING

IT3503 Web Development Techniques (Optional)

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

Programming Languages and Compilers

Compiler and Language Processing Tools

Chapter 13: Program Development and Programming Languages

How To Understand Programming Languages And Programming Languages

Compiler I: Syntax Analysis Human Thought

Computer Science. Requirements for the Major (updated 11/13/03)

Scanning and parsing. Topics. Announcements Pick a partner by Monday Makeup lecture will be on Monday August 29th at 3pm

Functional Programming

RARITAN VALLEY COMMUNITY COLLEGE ACADEMIC COURSE OUTLINE. CISY 105 Foundations of Computer Science

CS 106 Introduction to Computer Science I

General Introduction

CIS Information and Database Systems I. Course Syllabus Spring 2015

Chapter 14. Programming and Languages. McGraw-Hill/Irwin. Copyright 2008 by The McGraw-Hill Companies, Inc. All rights reserved.

How To Teach C++ Data Structure Programming

Syllabus INFO-GB Design and Development of Web and Mobile Applications (Especially for Start Ups)

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Canisius College Computer Science Department Computer Programming for Science CSC107 & CSC107L Fall 2014

Report on the Examination

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

Welcome to Introduction to Computers and Programming Course using Python

Syllabus INFO-UB Design and Development of Web and Mobile Applications (Especially for Start Ups)

Software: Systems and. Application Software. Software and Hardware. Types of Software. Software can represent 75% or more of the total cost of an IS.

DIRECT PH.D. (POST B.S.) IN COMPUTER SCIENCE PROGRAM

The Online Grade Book A Case Study in Learning about Object-Oriented Database Technology

Levels of Programming Languages. Gerald Penn CSC 324

Introduction to Python

CS 6371: Advanced Programming Languages

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

Fall 2012 Q530. Programming for Cognitive Science

Instructor Özgür ZEYDAN BEU Dept. of Enve. Eng. CIV 112 Computer Programming Lecture Notes (1)

Scope of this Course. Database System Environment. CSC 440 Database Management Systems Section 1

SYLLABUS MAC 1105 COLLEGE ALGEBRA Spring 2011 Tuesday & Thursday 12:30 p.m. 1:45 p.m.

Cambridge International AS and A Level Computer Science

Programming Language Concepts for Software Developers

CSE 562 Database Systems

College Algebra MATH 1111/11

Transcription:

Lecture Outline Programming Languages CSCI-4430 & CSCI-6430, Spring 2016 www.cs.rpi.edu/~milanova/csci4430/ Ana Milanova Lally Hall 314, 518 276-6887 milanova@cs.rpi.edu Office hours: Wednesdays Noon-2pm Art of programming language design Programming language spectrum Why study programming languages? Overview of compilation Read: Scott Chapter 1 2 Course webpage http://www.cs.rpi.edu/~milanova/csci4430 Announcements check regularly Schedule, Notes, Reading Schedule, lecture slides and assigned reading Homework Homework assignments posted there Homework server Homework submission and grades RPILMS Discussion board and grades 3 Required textbook Programming Language Pragmatics, 3 rd Edition, by Michael Scott, Morgan Kaufmann, 2009 Recommended textbook Compilers: Principles, Techniques, and Tools, 2 nd Edition, by A. Aho, M. Lam, R. Sethi and J. Ullman, Addison Wesley, 2007 (as known as The Dragon Book ) 4 Syllabus www.cs.rpi.edu/~milanova/csci4430/syllabus.htm Topics, outcomes, policies and grading 2 midterm exams and a final exam: 50% 9 homework assignments: 42% 10 quizzes: 8% 2% extra credit for attendance and participation 5 Homework is due at the beginning of lecture on the due date Submit written homework electronically in Homework server AND on paper at the beginning of lecture Submit programming homework in Homework server No late days! You may submit a late homework at the beginning of next lecture for 50% credit 6 1

Quizzes 10 in-class quizzes Will cover material of previous week Work in groups is encouraged We will distribute quizzes at the beginning of lecture Keep and submit quiz at the end of class In-class exercises At the end of class, I may give a simple problem on the material we have just covered Work in groups and ask questions You can discuss or submit answers to receive feedback Participation in these exercises carries towards 2% extra credit 7 8 Graduate students taking 6430 as part of the PhD qualifying exam To earn an A, you must earn 94% or more AND Complete (satisfactorily!) a paper critique Check syllabus www.cs.rpi.edu/~milanova/csci4430/syllabus.htm for details 9 Random Notes Prolog and Scheme programming assignments must be be completed individually Java programming assignment must be completed in teams of two using pairprogramming Ask questions: in class, after class, email, LMS 10 Academic Integrity All written homework assignments must be completed individually Programming assignments, except for last one, must be completed individually Excessive similarities in homework and exams! will be considered cheating Incidents of cheating will be taken extremely seriously and will result in penalties 11 How to Study Read textbook chapter in advance of lecture I will assign reading at the end of each class Read lecture notes and textbook chapter (again) immediately after class I will post lecture notes short after class Solve exercises in lecture notes Form study groups ASK QUESTIONS in class, after class, etc. 12 2

Course Topics Lecture Outline Programming language syntax: Scanning and parsing Programming language semantics: Attribute grammars Naming, binding and scoping Data abstraction and types Control abstraction and parameter passing Concurrency A logic-oriented language: Prolog A functional language: Scheme Imperative languages An object-oriented language: Java A dynamic language: Python to the course The art of programming language design The programming language spectrum Why study programming languages Overview of compilation 13 14 The Art of Language Design Why are there so many languages? Different programming domains Business applications Process data, reports, transactions, increasingly distributed Manufacturing/control systems Reliability and non-stop operation Scientific applications Computationally intensive Personal preference The Art of Language Design Some languages are more successful than others Expressive Power Abstraction Ease of use by novice Excellent compilers Powerful sponsors Circumstances 15 16 Imperative languages Von Neumann languages: Fortran, C, Object-oriented languages: Java, C++, Smalltalk, Dynamic languages: Perl, Python, PHP, Declarative languages Functional languages: Scheme/Lisp, ML, Haskell Logic languages: Prolog There are other declarative languages: e.g., Imperative languages Evolved from the von Neumann Architecture Variables Assignment Statements dataflow languages 17. Graph: Sebesta, 2005 18 3

Imperative languages j := i j lw t0,28(sp) lw t1,24(sp) subu t2,t0,t1 sw t2,24(sp) von Neumann bottleneck : tube connecting CPU and memory Imperative languages Most widely popular programming style FORTRAN, C, C++, C#, Java, Python, Visual BASIC, Perl, JavaScript, Ruby, etc. Variable and assignment statement are central concepts Program is a sequence of statements: j := i j; k := j * l; Execution is a sequence of transitions on memory state 19 20 FORTRAN was invented in mid-1950 John Backus, the inventor of FORTRAN, wrote the following paper in 1979: Can programming be liberated from the von Neumann style? A functional style and its algebra of programs Problems with imperative languages Difficult to understand programs Difficult to reason about correctness of programs Von Neumann Bottleneck Functional Programming Main alternative to imperative programming Lisp/Scheme, ML, Haskell Program consists of function definitions + evaluation expr (fun3 (fun2 (fun1 data))) (fun3 (fun2 data2)) (fun3 data3) data4 Execution is a sequence of function applications (i.e., reductions) Logic Programming Perform queries against knowledge base Prolog, Datalog, SQL 21 22 An Example: Inner Product Inner product in FORTRAN: 1. C := 0; 2. for I := 1 step 1 until N do 3. C := C + a[i]* b[i]; Illustrates state-transition semantics An Example: Inner Product Inner product in FP: Function composition Def IP = (Insert +) º (ApplyToAll *) º Transpose IP <<1,2,3>,<6,5,4>> is (Insert +) ((ApplyToAll *) (Transpose <<1,2,3>,<6,5,4>>)) (Insert +) ((ApplyToAll *) <<1,6>,<2,5>,<3,4>>) (Insert +) <6,10,12> 28 Fall 16 CSCI 4430, A Milanova 23 Illustrates reduction (applicative) semantics 24 4

Why Study Programming Languages Goal of the course: learn to analyze programming languages What are the questions we ask when facing a new programming language Helps learn new languages, choose the right language for a problem, understand language features, design better languages! Lecture Outline to the course The art of language design The programming language spectrum Why study programming languages Overview of compilation 25 26 Compilation and Interpretation Compilation A high-level program is translated into executable machine code Compiler Pure interpretation A program is translated and executed one statement at a time Interpreter Hybrid interpretation A program is compiled into intermediate code; intermediate code is interpreted Both a compiler and an interpreter 27 Compilation character stream Scanner (lexical analysis) token stream Parser (syntax analysis) parse tree Semantic analysis and intermediate code generation abstract syntax tree and/or intermediate form Machine-independent code improvement Code Generation COMPILER modified intermediate form target language (assember) Machine-dependent code improvement modified target language 28 Compilation Compilation position = initial + rate * 60; Scanner <id,1> <=> <id,2> <+> <id,3> <*> <60> Parser Symbol table 1. position, 2. initial, 3. rate, Semantic analysis and intermediate code generation = <id,1> + <id,2> * <id,3> inttoreal 60 Abstract Syntax Tree Semantic analysis and intermediate code generation tmp1 = inttoreal (60) tmp2 = id3 * tmp1 tmp3 = id2 + tmp2 id1 = tmp3 Intermediate form (three-address code) 29 30 5

Compilation Pure Interpretation Machine-independent code improvement tmp1 = id3 * 60.0 id1 = id2 + tmp1 Code generation Improved intermediate form e.g. BASIC REM COMMENT LET X = 5 LET Y = 8 PRINT X PRINT Y LET Z = X PRINT Z... Also JavaScript... movf id3, R2 mulf #60.0, R2 movf id2, R1 addf R2, R1 movf R1, id1 Target language 31 32 Hybrid Interpretation Compilation vs. Interpretation 09 AB 19 29 99 73 09 AB 19 29 99 73 09 AB 19 29 99 73 09 AB 19 29 99 73 09 AB 19 29 99 73 09 e.g. Java byte code e.g. Java Virtual Machine (JVM) A language can be implemented using a compiler or using an interpreter One can build a compiler for Lisp and one can easily build an interpreter for C or Fortran However, language features (determined during language design) have tremendous impact on compilability and the decision compiler vs. interpreter Also Perl... 33 34 Compilation vs. Interpretation What are the features that impact compilability? Static languages, i.e., languages that perform most semantic checks program execution, are suitable for compilation Dynamic languages, i.e., languages that perform most semantic checks execution, are suitable for interpretation 35 Compilation vs. Interpretation Advantages of compilation? Faster execution Advantages of interpretation? Greater flexibility Sandboxing, source-level debugging, dynamic semantic (type) checks, other dynamic features are much easier 36 6

Compilation vs. Interpretation New languages are increasingly dynamic Hybrid implementations are common: compiler from source to intermediate form, then a smart interpreter (Virtual Machine) which does interpretation and JIT (Just-in-Time) compilation Tons of code written in static languages (C, C++, Fortran) Dynamic instrumentation tools (Valgrind, Pin, DynamoRio) serve as interpreters for compiled binaries 37 Next Class We will review regular expressions and context free grammars Read Chapter 2.1 and 2.2 from Scott s book 38 39 7