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

Similar documents
Programming Language Design and Implementation. Cunning Plan. Your Host For The Semester. Wes Weimer TR 9:30-10:45 MEC 214. Who Are We?

Compiler Design 1. Introduction to Programming Language Design and to Compilation

PLAGIARISM. Administrivia. Compilers. CS143 11:00-12:15TT B03 Gates. Text. Staff. Instructor. TAs. Office hours, contact info on 143 web site

Administrivia. Compilers. CS143 10:30-11:50TT Gates B01. Text. Staff. Instructor. TAs. The Purple Dragon Book. Alex Aiken. Aho, Lam, Sethi & Ullman

1DL321: Kompilatorteknik I (Compiler Design 1) Introduction to Programming Language Design and to Compilation

1DL321: Kompilatorteknik I (Compiler Design 1) Introduction to Programming Language Design and to Compilation

1DL321: Kompilatorteknik I (Compiler Design 1)

Introduction to Programming Languages and Compilers. CS164 11:00-12:30 TT 10 Evans. UPRM ICOM 4029 (Adapted from: Prof. Necula UCB CS 164)

PLAGIARISM. Administrivia. Course home page: Introduction to Programming Languages and Compilers

Introduction to Programming Languages and Compilers. CS164 11:00-12:00 MWF 306 Soda

COMP 181 Compilers. Administrative. Last time. Prelude. Compilation strategy. Translation strategy. Lecture 2 Overview

ICOM 4036 Spring 2004

Compilers. Lecture 2 Overview. (original slides by Sam

What Is Computer Science? The Scientific Study of Computation. Expressing or Describing

Programming Language Specification and Translation. ICOM 4036 Fall Lecture 3

Introduction. Compilers and Interpreters

CS 3304 Comparative Languages. Lecture 1: Introduction

Lecture 1: Course Introduction

CS131: Programming Languages and Compilers. Spring 2017

Compilers and Interpreters

Lecture 1: Course Introduction

Compilers. Introduction. Yannis Smaragdakis, U. Athens (original slides by Sam

Introduction to Compilers

INTRODUCTION PRINCIPLES OF PROGRAMMING LANGUAGES. Norbert Zeh Winter Dalhousie University 1/10

Lexical Analysis. Lecture 2-4

CS 415 Midterm Exam Spring 2002

CSCI 3136 Principles of Programming Languages

Introduction to Lexical Analysis

Compiling Techniques

CS 432 Fall Mike Lam, Professor. Compilers. Advanced Systems Elective

Formal Languages and Compilers Lecture I: Introduction to Compilers

Introduction to Lexical Analysis

Administrivia. Lexical Analysis. Lecture 2-4. Outline. The Structure of a Compiler. Informal sketch of lexical analysis. Issues in lexical analysis

CS 432 Fall Mike Lam, Professor. Compilers. Advanced Systems Elective

Lexical Analysis. Lecture 3-4

ECE573 Introduction to Compilers & Translators

CSC 261/461 Database Systems. Fall 2017 MW 12:30 pm 1:45 pm CSB 601

CSE 504: Compiler Design

PA101 Learning the Ropes

trends in programming languages

San Jose State University - Department of Computer Science

CSE 417 Practical Algorithms. (a.k.a. Algorithms & Computational Complexity)

15-411/ Compiler Design

CS Compiler Construction West Virginia fall semester 2014 August 18, 2014 syllabus 1.0

CS1 Lecture 2 Jan. 16, 2019

Philadelphia University Faculty of Information Technology Department of Computer Science --- Semester, 2007/2008. Course Syllabus

Course Syllabus. Programming Language Paradigms. Spring - DIS Copenhagen. Semester & Location: Elective Course - 3 credits.

CS415 Compilers Overview of the Course. These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University

CS 3110 Lecture 1 Course Overview

CS153: Compilers Lecture 1: Introduction

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

CS 241 Data Organization. August 21, 2018

COMP 401 COURSE OVERVIEW

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

CSE4305: Compilers for Algorithmic Languages CSE5317: Design and Construction of Compilers

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

! Broaden your language horizons! Different programming languages! Different language features and tradeoffs. ! Study how languages are implemented

Lexical Analysis. Chapter 2

Semantic Analysis. Lecture 9. February 7, 2018

San José State University Department of Computer Science CS151, Section 04 Object Oriented Design Spring 2018

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

Syntactic Analysis. CS345H: Programming Languages. Lecture 3: Lexical Analysis. Outline. Lexical Analysis. What is a Token? Tokens

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

Simply-Typed Lambda Calculus

CS 4120 and 5120 are really the same course. CS 4121 (5121) is required! Outline CS 4120 / 4121 CS 5120/ = 5 & 0 = 1. Course Information

CS 6371: Advanced Programming Languages

CS 553: Algorithmic Language Compilers (PLDI) Graduate Students and Super Undergraduates... Logistics. Plan for Today

CSCI 201L Syllabus Principles of Software Development Spring 2018

Seminar in Programming Languages

Math 2280: Introduction to Differential Equations- Syllabus

UVa ID: NAME (print): CS 4501 LDI Midterm 1

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

CISC 124: Introduction To Computing Science II

CSc 520. Course Outline (Subject to change) Course Outline (Subject to change)... Principles of Programming Languages. Christian Collberg

More Lambda Calculus and Intro to Type Systems

Compilers. Computer Science 431

Compilers for Modern Architectures Course Syllabus, Spring 2015

Earlier edition Dragon book has been revised. Course Outline Contact Room 124, tel , rvvliet(at)liacs(dot)nl

Department of Electrical Engineering and Computer Sciences Spring 2001 Instructor: Dan Garcia CS 3 Midterm #2. Personal Information

COSE212: Programming Languages. Lecture 0 Course Overview

CSCI 528: OBJECT ORIENTED PROGRAMMING, Fall 2015

What is a compiler? var a var b mov 3 a mov 4 r1 cmpi a r1 jge l_e mov 2 b jmp l_d l_e: mov 3 b l_d: ;done

Course Syllabus. Course Information

Lecture 1. Course Overview, Python Basics

CS 526 Advanced Topics in Compiler Construction. 1 of 12

CSC 172 Data Structures and Algorithms. Fall 2017 TuTh 3:25 pm 4:40 pm Aug 30- Dec 22 Hoyt Auditorium

General Course Information. Catalogue Description. Objectives

Compiler Construction D7011E

Introduction to Prof. Clarkson Fall Today s music: Prelude from Final Fantasy VII by Nobuo Uematsu (remastered by Sean Schafianski)

CSE 142. Lecture 1 Course Introduction; Basic Java. Portions Copyright 2008 by Pearson Education

Who are we? Andre Platzer Out of town the first week GHC TAs Alex Crichton, senior in CS and ECE Ian Gillis, senior in CS

378: Machine Organization and Assembly Language

Programming (ERIM) Lecture 1: Introduction to programming paradigms and typing systems. Tommi Tervonen

Programming Languages, Summary CSC419; Odelia Schwartz

EECE.2160: ECE Application Programming Spring 2019

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

What a lot of folks might call the class but as we ll see later, it s not entirely accurate.

COMP 117: Internet-scale Distributed Systems Lessons from the World Wide Web

Introduction to Database Systems CS432. CS432/433: Introduction to Database Systems. CS432/433: Introduction to Database Systems

Lexical Analysis. Finite Automata

Transcription:

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

Cunning Plan Who Are We? Wes, Jonathan Dorn, graders Administrivia What Is This Class About? Brief History Lesson Understanding a Program in Stages #2

Course Home Page google: virginia cs 4610 http://www.cs.virginia.edu/~weimer/4610 Lectures slides are available before class You should still take notes! Assignments are listed also grading breakdown, regrade policies, etc. Use the class forum for all public questions #3

Course Options Three options are available: Take only CS 4610 (Programming Languages) for 3 credits Take CS 4610 (Progamming Languages) for 3 credits and also take CS 4501 (Compilers Practium) for 2 credits Take neither (this is actually the best choice) CS 4501 Compilers Practicum Must attend CS 4610 PL lectures Has additional lectures, homeworks, tests #4

Should I Take This Course? Beg for more mid-assignment checkpoints. Also, beg that the optional two-credit class only be opened just before the withdrawal deadline so you don't have to decide early on before you understand what you've decided to do to yourself. Finally, beg for mercy. :) Professor Weimer is very engaging in his lectures, which kept me awake and interested even through the most boring or difficult sections of the class. And some of the class material WAS boring. And it was most DEFINITELY difficult. While the assignments were VERY time-consuming and difficult (sometimes ridiculously so), I felt great accomplishment after completing them, and I feel that I may have learned more from this class than any I have ever taken before. #5

Should I Take This Course? Easily the most time-consuming class that I have taken at UVA. There were times that I got very little sleep at all. In addition, the assignments require a deep understanding of the material, in order to do well on them. Nevertheless, I learned a lot from this class. On top of this, Professor Weimer is extremely knowledgeable and teaches in such a way that even very difficult concepts become much easier to grasp. This being said, do not take Programming Languages, because you will put in over 9,000 hours into the class. The hardest class that I've taken at UVA. Although it's worth 5 credits, the extra 2 credits are essentially worthless, since all of the credit requirements are for classes worth 3 credits each. #6

Should I Take This Course? This course was the hardest course I have taken thus far, but Professor Weimer made it very enjoyable. The amount of work at times was a little overwhelming, but I definitely learned a lot from it. Weimer was one of the best lecturers I have had in the Engineering school and he truly wanted the students to understand the material. This was a great course. A ridiculous amount of work but that was known information from the first day of the course. The instructor was enthusiastic and taught very well. I don't know what you should do, but this class had ruined my life. I have spent more time on this class than the rest of my classes combined this semester. However, knowing what I know now I would take this class again! #7

Happiness Unhappiness is related to unrealized desires cf. Must take this to graduate, Must have good grades, Must have free time. I have failed students in 4610. Currently open: CS 4501 Reasoning About Computation CS 4501 Computational Complexity CS 6354 Computer Architecture CS 6501 Advanced Graphics: Manipulating 2D, 3D Content, and 3D Printing CS 4993 Independent Study (!) (e.g., survey 20 papers) #8

Compilers Practicum Sections There will be one sixty-minute Compilers Section each week (about 10 sections) Hosted by Jonathan Dorn When do those meet? We're still waiting on a room assignment. We may be able to vote for times that everyone in Compilers can make If you cannot make the Section, you must drop Compilers. Sorry. Notes posted on web. #9

#10

#11

Course Structure Course has theoretical and practical aspects Best of both worlds! Need both in programming languages! Reading = both Many external and optional readings Written assignments = theory Class hand-in, right before lecture, 0-5 points Programming assignments = practice Electronic hand-in Strict deadlines Ask me why... #12

Resources Textbook Programming Language Pragmatics Michael L. Scott, third edition Free Online Materials Udacity CS 262 (same instuctor) Optional Readings #13

Academic Honesty Don t use work from uncited sources Including old code We often use plagiarism detection software PLAGIARISM #14

Academic Honesty Don t use work from uncited sources Including old code We often use plagiarism detection software #15

PL Course Project A big project: an Interpreter! in four easy parts Start early! #16

PL Course Goals At the end of this course, you will be acquainted with the fundamental concepts in the design and implementation of high-level programming languages. In particular, you will understand the theory and practice of lexing, parsing, semantic analysis, and code interpretation. You will also have gained practical experience programming in multiple different languages. #17

Compilers Project & Course Goals The final project for the Compilers Practicum is a working optimizing compiler (code generator) that produces either bytecode or x86-64 assembly. At the end of this course, you will be acquainted with the fundamental concepts in code generation and optimization. In particular, you will understand the theory and practice of code generation, stack layouts, calling conventions, dynamic dispatch, control flow graphs, and dataflow analyses. #18

How are Languages Implemented? Two major strategies: Interpreters (take source code and run it) Compilers (translate source code, run result) Distinctions blurring (e.g., just-in-time compiler) Interpreters run programs as is Little or no preprocessing Compilers do extensive preprocessing Most implementations use compilers #19

Don t We Already Have Compilers? #20

Dismal View Of Prog Languages C++ Java (or C#) #21

(Short) History of High-Level Languages 1953 IBM develops the 701 Defense Calculator 1952, US formally ends occupation of Japan 1954, Brown v. Board of Education of Topeka, Kansas All programming done in assembly Problem: Software costs exceeded hardware costs! John Backus: Speedcoding An interpreter Ran 10-20 times slower than hand-written assembly #22

FORTRAN I 1954 IBM develops the 704 John Backus Idea: translate high-level code to assembly Many thought this impossible 1954-7 FORTRAN I project By 1958, >50% of all software is in FORTRAN Cut development time dramatically (2 weeks 2 hours) #23

FORTRAN I The first compiler Produced code almost as good as hand-written Huge impact on computer science Led to an enormous body of theoretical work Modern compilers keep the outlines of FORTRAN I #24

Real-World Languages This Indo-European language is associated with South Asian Muslims and is the lingua franca of Pakistan. It developed from Persian, Arabic and Turkic influences over about 900 years. Poetry in this language is particularly famed, and is a reported favorite of US President Barack Obama. Example: السل م علیکم #25

Interpreters Lexical Analysis Parsing Semantic Analysis Optimization (optional) Interpret The Program Compilers Lexical Analysis Parsing Semantic Analysis Optimization (optional) Generate Machine Code Run that Machine Code The first 3, at least, can be understood by analogy to how humans comprehend English. #26

Lexical Analysis First step: recognize words. Smallest unit above letters This is a sentence. Note the Capital Blank Period T (start of sentence symbol) (word separator). (end of sentence symbol) #27

More Lexical Analysis Lexical analysis is not trivial. Consider: How d you break this up? Plus, programming languages are typically more cryptic than English: *p->f += -.12345e-6 #28

And More Lexical Analysis Lexical analyzer divides program text into words or tokens if x == y then z = 1; else z = 2; Broken up: if, x, ==, y, then, z, =, 1, ;, else, z, =, 2, ; #29

Parsing Once words are understood, the next step is to understand sentence structure Parsing = Diagramming Sentences The diagram is a tree Often annotated with additional information #30

Diagramming a Sentence This line is a longer article noun verb article adjective subject sentence noun object sentence #31

Parsing Programs Parsing program expressions is the same Consider: if x == y then z = 1; else z = 2; Diagrammed: x == y z 1 z 2 relation assign assign predicate then-stmt else-stmt if-then-else #32

Semantic Analysis Once sentence structure is understood, we can try to understand meaning But meaning is too hard for compilers Compilers perform limited analysis to catch inconsistencies: reject bad programs early! Some do more analysis to improve the performance of the program #33

Semantic Analysis in Programming { Programming languages define int Sydney = 3; strict rules to avoid { such ambiguities int Sydney = 4; cout << Sydney; This C++ code prints } 4 ; the inner } Scoping or definition is used aliasing problem. #35

Optimization No strong counterpart in English, but akin to editing (cf. poems, short stories) Automatically modify programs so that they Run faster Use less memory In general, conserve some resource CS 4501 has an Optimization assignment #37

Code Generation Produces assembly code (usually) which is then assembled into executables by an assembler A translation into another language Analogous to human translation CS 4501: produce machine code Either Java Bytecode or x86-64 assembly #38

Issues Compiling and interpreting are almost this simple, but there are many pitfalls. Example: How are bad programs handled? Language design has big impact on compiler Determines what is easy and hard to compile Course theme: trade-offs in language design #39

Languages Today The overall structure of almost every compiler & interpreter follows our outline The proportions have changed since FORTRAN Early: lexing, parsing most complex, expensive Today: optimization dominates all other phases, lexing and parsing are cheap Thus: this course puts a lesser emphasis on ancient parsing techniques (e.g., LL, LALR) #40

Trends in Languages Optimization for speed is less interesting. But: scientific programs advanced processors (Digital Signal Processors, advanced speculative architectures) small devices where speed = longer battery life Ideas we ll discuss are used for improving code reliability: memory safety detecting concurrency errors (data races) type safety automatic memory management #41

Why Study Prog. Languages? Increase capacity of expression See what is possible Improve understanding of program behavior Know how things work under the hood Increase ability to learn new languages Learn to build a large and reliable system See many basic CS concepts at work #42

What Will You Do In This Class? Reading (textbook, videos, outside sources) Learn about different kinds of languages Imperative vs. Functional vs. Object-Oriented Static typing vs. Dynamic typing etc. Learn to program in different languages Python, Ruby, JavaScript, ML, Cool (= Java) Complete homework assignments Write an interpreter! #43

What Is This? #44

The Rosetta Stone The first programming assignment involves writing the same simple (50-75 line) program in: Ruby, Python, JavaScript, OCaml, Cool and C PA1c, due Mon Jan 20 (MLK), requires you to write the program in three languages (you pick) PA1, due one week later, requires all six Long, long be my heart with such memories fill'd! Like the vase in which roses have once been distill'd: You may break, you may shatter the vase if you will, But the scent of the roses will hang round it still. - Thomas Moore (Irish poet, 1779-1852) #45

Live Submission Demo Let's visit the automated submission website #46

Start The Homework Now It may help you decide whether to stay in this course #47

Homework Scott Book reading (for Wednesday) Get started on PA1c (due in 9 days) Questions? #48