Programming Languages CSCI-4430 & CSCI-6430, Spring 2016 Ana Milanova Lally Hall 314, 518 276-6887

Slides:



Advertisements
Similar presentations
Copyright © 2005 Elsevier Imperative languages Group languages as –imperative von Neumann(Fortran, Pascal, Basic, C) object-oriented(Smalltalk, Eiffel,
Advertisements

Goran Šuković, University of Montenegro 1/21 Compiler Construction Course at University of Montenegro 7 th Workshop on “Software Engineering Education.
Chapter 1: Preliminaries
PLLab, NTHU Cs2403 Programming Languages Implementation Issues Cs2403 Programming Language Spring 2005 Kun-Yuan Hsieh.
CS 330 Programming Languages 09 / 07 / 2006 Instructor: Michael Eckmann.
ISBN Chapter 1 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Motivation Programming Domains.
Compiler Design Lexical Analysis Syntactical Analysis Semantic Analysis Optimization Code Generation.
CS 330 Programming Languages 09 / 06 / 2007 Instructor: Michael Eckmann.
Programming Languages Structure
CSI Fall 2002 Dr. William A. Maniatty Assistant Prof. Dept. of Computer Science University At Albany Programming Languages and Systems Concepts Fall.
ISBN Lecture 01 Preliminaries. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.1-2 Lecture 01 Topics Motivation Programming.
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.
ISBN Chapter 1 Topics Motivation Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language.
COP4020/CGS5426 Programming languages Syllabus. Instructor Xin Yuan Office: 168 LOV Office hours: T, H 10:00am – 11:30am Class website:
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
CPSC 388 – Compiler Design and Construction Lecture: MWF 11:00am-12:20pm, Room 106 Colton.
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.
1 CSCE Programming Languages Introduction and Course Administration Dr. Hyunyoung Lee 410B HR Bright
CS 355 – Programming Languages
(1.1) COEN 171 Programming Languages Winter 2000 Ron Danielson.
Programming Languages and Design Lecture 1 Introduction to Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern University,
COP4020 Programming Languages
Chapter 1. Introduction.
CS 363 Comparative Programming Languages
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
CS 330 Programming Languages 09 / 04 / 2008 Instructor: Michael Eckmann.
1 Programming Languages Tevfik Koşar Lecture - II January 19 th, 2006.
CST 229 Introduction to Grammars Dr. Sherry Yang Room 213 (503)
Compiler course 1. Introduction. Outline Scope of the course Disciplines involved in it Abstract view for a compiler Front-end and back-end tasks Modules.
CST 320 Compiler Methods Dr. Sherry Yang PV 171 (541)
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages.
1 COMP 3438 – Part II-Lecture 1: Overview of Compiler Design Dr. Zili Shao Department of Computing The Hong Kong Polytechnic Univ.
CSCI 51 Introduction to Computer Science Dr. Joshua Stough January 20, 2009.
Programming Languages & Translators (CE 359) Fall 2013 Prof. Dr: Ahmed El Nahass Lecture 1 1 FACULTY OF ENGINEERING COMPUTER ENGINEERING Prof.Dr Ahmed.
Copyright © 2007 Addison-Wesley. All rights reserved.1-1 Reasons for Studying Concepts of Programming Languages Increased ability to express ideas Improved.
ICS 313 Fundamentals of Programming Languages Instructor: Abdul Wahid Wali Lecturer, CSSE, UoH
1.  10% Assignments/ class participation  10% Pop Quizzes  05% Attendance  25% Mid Term  50% Final Term 2.
1 Programming Languages Fundamentals Cao Hoaøng Truï Khoa Coâng Ngheä Thoâng Tin Ñaïi Hoïc Baùch Khoa TP. HCM.
ISBN Chapter 1 Preliminaries. Copyright © 2009 Addison-Wesley. All rights reserved.1-2 Chapter 1 Topics Reasons for Studying Concepts of.
1 Compiler Design (40-414)  Main Text Book: Compilers: Principles, Techniques & Tools, 2 nd ed., Aho, Lam, Sethi, and Ullman, 2007  Evaluation:  Midterm.
Course Overview for Compilers J. H. Wang Sep. 14, 2015.
CMSC 2021 CMSC 202 Computer Science II for Majors Spring 2002 Sections Ms. Susan Mitchell.
CMSC 2021 CMSC 202 Computer Science II for Majors Spring 2001 Sections Ms. Susan Mitchell.
Course Overview for Compilers J. H. Wang Sep. 20, 2011.
COP4020 INTRODUCTION FALL COURSE DESCRIPTION Programming Languages introduces the fundamentals of the design and implementation of programming languages.
Programming Language Theory 2014, 1 Chapter 1 :: Introduction Origin : Michael L. Scott School of Computer & Information Engineering,
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
The College of Saint Rose CIS 433 – Programming Languages David Goldschmidt, Ph.D. from Concepts of Programming Languages, 9th edition by Robert W. Sebesta,
Chapter 1. Introduction.
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Compiler Design (40-414) Main Text Book:
Concepts of Programming Languages
Why study programming languages?
Chapter 1 Introduction.
PROGRAMMING LANGUAGES
CMPUT Compiler Design and Optimization
Chapter 1 Introduction.
课程名 编译原理 Compiling Techniques
Compiler Lecture 1 CS510.
CS416 Compiler Design lec00-outline September 19, 2018
Introduction to Compiler Construction
Course supervisor: Lubna Siddiqui
Programming Languages 2nd edition Tucker and Noonan
CS416 Compiler Design lec00-outline February 23, 2019
Introduction to Compiler Construction
CISC 7120X Programming Languages and Compilers
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
School of Computer & Information Engineering,
Introduction to Compiler Construction
Presentation transcript:

Programming Languages CSCI-4430 & CSCI-6430, Spring Ana Milanova Lally Hall 314, Office hours: Wednesdays Noon-2pm

2 Lecture Outline Introduction Art of programming language design Programming language spectrum Why study programming languages? Overview of compilation Read: Scott Chapter 1

Spring 16 CSCI 4430, A Milanova 3 Introduction Course webpage 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

Spring 16 CSCI 4430, A Milanova 4 Introduction 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”)

Spring 16 CSCI 4430, A Milanova 5 Introduction Syllabus 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

Introduction 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 Spring 16 CSCI 4430, A Milanova 6

Introduction 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 Spring 16 CSCI 4430, A Milanova 7

Introduction 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 Spring 16 CSCI 4430, A Milanova 8

9 Introduction 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 for details

Random Notes… Prolog and Scheme programming assignments must be be completed individually Java programming assignment must be completed in teams of two using pair- programming Ask questions: in class, after class, , LMS Spring 16 CSCI 4430, A Milanova 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 Spring 16 CSCI 4430, A Milanova 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. Spring 16 CSCI 4430, A Milanova 12

Spring 16 CSCI 4430, A Milanova 13 Course Topics 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

Spring 16 CSCI 4430, A Milanova 14 Lecture Outline Introduction to the course The art of programming language design The programming language spectrum Why study programming languages Overview of compilation

15 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… Spring 16 CSCI 4430, A Milanova

16 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… Spring 16 CSCI 4430, A Milanova

17 The Programming Language Spectrum 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., dataflow languages

Spring 16 CSCI 4430, A Milanova. Graph: Sebesta, The Programming Language Spectrum Imperative languages Evolved from the von Neumann Architecture Variables Assignment Statements

Spring 16 CSCI 4430, A Milanova 19 The Programming Language Spectrum Imperative languages j := i – j lw t0,28(sp) lw t1,24(sp) subut2,t0,t1 sw t2,24(sp) “von Neumann bottleneck”: tube connecting CPU and memory

20 The Programming Language Spectrum 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 Spring 16 CSCI 4430, A Milanova

21 The Programming Language Spectrum 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 Spring 16 CSCI 4430, A Milanova

22 The Programming Language Spectrum 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

Fall 16 CSCI 4430, A Milanova 23 An Example: Inner Product Inner product in FORTRAN: Illustrates state-transition semantics 1. C := 0; 2. for I := 1 step 1 until N do 3. C := C + a[I]* b[I];

24 An Example: Inner Product Inner product in FP: Def IP = (Insert +) º (ApplyToAll *) º Transpose IP, > is (Insert +) ((ApplyToAll *) (Transpose, >)) (Insert +) ((ApplyToAll *),, >) (Insert +) 28 Illustrates reduction (applicative) semantics Function composition

25 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! Spring 16 CSCI 4430, A Milanova

26 Lecture Outline Introduction to the course The art of language design The programming language spectrum Why study programming languages Overview of compilation

Spring 16 CSCI 4430, A Milanova 27 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

Spring 16 CSCI 4430, A Milanova 28 Compilation Scanner (lexical analysis) Parser (syntax analysis) Machine-independent code improvement Code Generation COMPILER character stream token stream parse tree modified intermediate form target language (assember) Semantic analysis and intermediate code generation abstract syntax tree and/or intermediate form Machine-dependent code improvement modified target language

Spring 16 CSCI 4430, A Milanova 29 Compilation Scanner Parser position = initial + rate * 60; Semantic analysis and intermediate code generation 1.position, … 2.initial, … 3. rate, … Symbol table

30 Compilation = + * inttoreal 60 tmp1 = inttoreal (60) tmp2 = id3 * tmp1 tmp3 = id2 + tmp2 id1 = tmp3 Semantic analysis and intermediate code generation Abstract Syntax Tree Intermediate form (three-address code) Spring 16 CSCI 4430, A Milanova

31 Compilation tmp1 = id3 * 60.0 id1 = id2 + tmp1 movf id3, R2 mulf #60.0, R2 movf id2, R1 addf R2, R1 movf R1, id1 Machine-independent code improvement Code generation Improved intermediate form Target language

32 Pure Interpretation e.g. BASIC REM COMMENT LET X = 5 LET Y = 8 PRINT X PRINT Y LET Z = X PRINT Z... Also JavaScript.... Spring 16 CSCI 4430, A Milanova

33 Hybrid Interpretation e.g. Java byte code 09 AB AB AB AB AB e.g. Java Virtual Machine (JVM) Also Perl....

Compilation vs. Interpretation 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” Spring 16 CSCI 4430, A Milanova 34

Compilation vs. Interpretation Spring 16 CSCI 4430, A Milanova 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 Spring 16 CSCI 4430, A Milanova 36

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 Spring 16 CSCI 4430, A Milanova 37

Next Class We will review regular expressions and context free grammars Read Chapter 2.1 and 2.2 from Scott’s book Spring 16 CSCI 4430, A Milanova 38

Spring 16 CSCI 4430, A Milanova 39