CS252 Advanced Programming Language Principles. Prof. Tom Austin San José State University Fall 2013

Similar documents


San José State University College of Science/Department of Computer Science CS 152, Programming Language Paradigms, Section 03/04, Fall, 2018

Programming Languages

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

Languages and Compilers

Compiler Design Spring 2018

Concepts of Programming Languages

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

IA010: Principles of Programming Languages

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN

Introduction to Security

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

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1, 2, and 3, Spring 2018

CONTENTS: What Is Programming? How a Computer Works Programming Languages Java Basics. COMP-202 Unit 1: Introduction

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015

Is Functional Programming (FP) for me? ACCU Conference 2008 Hubert Matthews

COSE212: Programming Languages. Lecture 0 Course Overview

CS152 Programming Language Paradigms Prof. Tom Austin, Fall Syntax & Semantics, and Language Design Criteria

Introduction. COMP 524: Programming Language Concepts Björn B. Brandenburg. The University of North Carolina at Chapel Hill

Programming Languages, Summary CSC419; Odelia Schwartz

Summer Assignment for AP Computer Science. Room 302

Programming language design and analysis

New Programming Paradigms

San Jose State University College of Science Department of Computer Science CS151, Object-Oriented Design, Sections 1,2 and 3, Spring 2017

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

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

San José State University Department of Computer Science CS151, Object Oriented Design, Section 04, Fall, 2016 (42968)

CS 11 Haskell track: lecture 1

Outline. Introduction Concepts and terminology The case for static typing. Implementing a static type system Basic typing relations Adding context

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

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

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

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

CSCI 3136 Principles of Programming Languages

Concepts of Programming Languages

Course and Contact Information. Course Description. Course Objectives

Functional Programming

Modules, Structs, Hashes, and Operational Semantics

Intensive Introduction to Computer Science. Course Overview Programming in Scratch

Programming Languages Third Edition

CS/SE 153 Concepts of Compiler Design

CS457/557 Functional Languages

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

What is programming? Elements of Programming Languages. From machine code to programming languages. What is a programming language?

CSE373: Data Structure & Algorithms Lecture 23: Programming Languages. Aaron Bauer Winter 2014

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

Look at all these toys!

CS558 Programming Languages

Com S 541. Programming Languages I

San José State University Department of Computer Science CS-174, Server-side Web Programming, Section 2, Spring 2018

CPSC 427a: Object-Oriented Programming

CS 415 Midterm Exam Spring 2002

Lecture 1. Introduction to course, Welcome to Engineering, What is Programming and Why is this the first thing being covered in Engineering?

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013

CS 11 java track: lecture 1

CS383 PROGRAMMING LANGUAGES. Kenny Q. Zhu Dept. of Computer Science Shanghai Jiao Tong University

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

61A LECTURE 1 FUNCTIONS, VALUES. Steven Tang and Eric Tzeng June 24, 2013

cmpt 440/821 Advanced Topics in Programming Languages

INTRODUCTION TO MATHEMATICAL PROOFS: A TRANSITION (TEXTBOOKS IN MATHEMATICS) BY CHARLES ROBERTS

TTh 9.25 AM AM Strain 322

CS 4349 Lecture August 21st, 2017

Simply-Typed Lambda Calculus

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


Introduction to Functional Programming and Haskell. Aden Seaman

Topic 9: Type Checking

Topic 9: Type Checking

CS 3110 Lecture 1 Course Overview

CS 3030 Scripting Languages Syllabus

Seminar in Programming Languages

Matching Logic A New Program Verification Approach

Programming Languages 2nd edition Tucker and Noonan"

What is a programming language?

CS 231 Data Structures and Algorithms, Fall 2016

G Programming Languages - Fall 2012

Formal Methods of Software Design, Eric Hehner, segment 24 page 1 out of 5

CS 240 Fall Mike Lam, Professor. Just-for-fun survey:

Haskell in the corporate environment. Jeff Polakow October 17, 2008

CSci 4211: Data Communications and Computer Networks. Time: Monday and Wednesday 1 pm to 2:15 pm Location: Vincent Hall 16 Spring 2016, 3 Credits

First Programming Language in CS Education The Arguments for Scala

CS 241 Data Organization. August 21, 2018

CSCI 201L Syllabus Principles of Software Development Spring 2018

Topic I. Introduction and motivation References: Chapter 1 of Concepts in programming languages by J. C. Mitchell. CUP, 2003.

San Jose State University - Department of Computer Science

Lecture 8: Summary of Haskell course + Type Level Programming

CS350 : Operating Systems. General Assignment Information

Alan J. Perlis - Epigrams on Programming

Introduction to Data Structures

How Rust is Tilde s Competitive Advantage

Lecture 02, Fall 2018 Friday September 7

CMSC 330: Organization of Programming Languages. Functional Programming with OCaml

CSci 5103 Operating Systems. Jon Weissman. Administrivia

Kickstart Intro to Java Part I

Advanced Topics in Programming Languages Lecture 2 - Introduction to Haskell

Introduction to Computer Science I

Computer Science Seminar. Whats the next big thing? Ruby? Python? Neither?

CS 6371: Advanced Programming Languages

Transcription:

CS252 Advanced Programming Language Principles Prof. Tom Austin San José State University Fall 2013

What are some programming languages?

Why are there so many? Different domains Mobile devices (Objective C) Web programming (Ruby, Python, PHP) Databases (SQL) Different design choices. Some concerns: Flexibility (Scripting languages) Type safety (Java, Scala, Haskell) Performance (C, C++, Go) Build time (Go, Rust, D) Concurrency (Erlang, Go, Rust, D)

Which language is better?

Good language features Simplicity Readability and writability Learn-ability (familiarity helps here) Safety Machine independence Efficiency (of execution, but also of compilation) Backwards compatibility

These goals almost always conflict Type systems prevent bad programs from running, but also restrict what the programmer can do. Machine-independence and efficient low-level operations are difficult to pair. Good language designs choosing careful compromises for the right set of features.

Why do we study programming languages? For undergrads, we want to warp their minds and make them better programmers.

Mind warping is good for grad students as well... but we also want you to: be familiar with advanced language features know how to evaluate different features to choose the right language for the job understand the necessary formalisms, so that you can take part in the discussion.

Blub programmers Paul Graham introduced the concept of "Blub programmers" in a famous blog post (http://www.paulgraham.com/avg.html). "Blub" is a hypothetical language midway in the "power continuum". (He defines "power" roughly as being able to do more with fewer lines of code.)

The Blub Paradox "As long as our hypothetical Blub programmer is looking down the power continuum, he knows he's looking down [Blub programmers are] satisfied with whatever language they happen to use, because it dictates the way they think about programs." --Paul Graham Why do I need (monads, closures, type inference, metaobject protocols)? My language doesn't have it, and it works just fine!!!

Languages we will cover (subject to change) Haskell (focus will be here) Ruby (for metaprogramming) Go (Concurrency, and trying to kill C++) Scala (Domain Specific Languages)

Theoretical foundations topics Formal semantics (especially operational semantics) Type systems and proofs Concurrency approaches Metaprogramming Security features

In this course, you will learn the practical and the theoretical

What are the issues of interest to industry in the development of new language features?

Multi-core explosion Single core CPU performance increases have slowed. Performance gains now come from multiple cores. How can we take advantage of these extra cores? Automatic parallelization of code Security features (secure multi-execution)

Mobile Devices Fierce competition has arisen around mobile devices (Android, iphone). "Mobile-only users". What unique challenges are there in this space? How can language features help address these issues?

Rise of the Web and Scripting Languages Perl, Python, Ruby, PHP, JavaScript Flexible: dynamically typed: the type system does not stop valid program executions, even if the complete program has issues. Easy to get started. (Generally) less typing required

Hello world in Java public class HelloWorld { } public static void main(string[] args) { System.out.println("Hello World!"); } Hello world in Ruby puts "Hello World!"

What are the main areas of interest in Programming Languages (PL) research? Types Types More types! (OK, maybe a little more than that )

Why are they different? PL research helps create concepts used in the languages of the future Garbage collection Advanced type systems Advanced concurrency constructs But it also tends to miss some areas of interest to industry programmers.

Idealized relationship between academia and industry Academics come up with brilliant ideas Academia shares its ideas with people in industry Engineers use these ideas to build great things

Actual relationship between academia and industry Academics share ideas with industry (2) Academics come up with ideas (1) Engineers use these ideas, incorporating their own ideas and experiences (3)

Actual relationship between academia and industry Academics share ideas with industry (2) Academics come up with ideas (1) The cycle continues (6) Sometimes they don't work out well (4) Academics learn from the experience of engineers (5)

In order to participate in the discussion, you need to be comfortable with formal semantics.

Who needs formal semantics? No one, except: Those who write programs that manipulate other programs: compilers and interpreters program transformation tools (e.g. JavaScript rewriting) instrumentation tools program analyzers software engineering tools

Who needs formal semantics? No one, except: Those who want to describe (unambiguously) a language feature or program transformation ECMAScript committee Semantics help to frame discussion and highlight some issues early in the process We can formally prove that a language supports a given property Those who write critical software http://en.wikipedia.org/wiki/list_of_software_bugs

Three Approaches to Language Semantics Operational semantics how to evaluate or execute a program useful for implementing a compiler or interpreter Axiomatic semantics given a program and a set of starting states and inputs, what is the set of final states after execution does it include assertion failed? useful for proving program correctness Denotational semantics characterize meaning of each procedure as a mathematical function mathematically heavyweight we will not cover it in this course.

Once we have the tools for a discussion, we can determine in an objective sense whether a language or feature is "good".

Administrative Details Green sheet available at http://www.sjsu.edu/people/thomas.austin/ courses/cs252-fall2013/s1/greensheet.html Homework assignments will be submitted through Canvas (https://sjsu.instructure.com/) Academic integrity policy: http://info.sjsu.edu/static/catalog/integrity.html

Schedule The class schedule is available through Canvas Late homeworks will not be accepted Check the schedule before every class Check the schedule before every class And finally, CHECK THE SCHEDULE BEFORE EVERY CLASS.

Prerequisites You are expected to have taken an undergraduate programming languages course Functional programming should be familiar You should be comfortable with mathematical notation If you are not sure, please see me

Resources All available online!!! A Tour of Go, http://tour.golang.org http://learnyouahaskell.com/

Grading 50% -- Homework assignments. 40% -- Final project. 10% -- Participation. The project is open-ended: do something you find interesting. We will discuss project ideas more in a later class.

Office hours MacQuarrie Hall room 216. Wednesdays 10am 11am. Thursdays 10am 11am. If you need to meet with me another time, send me an email.

Haskell

Haskell is purely functional We define "what stuff is" rather than how to do it. No side effects, allowing for referential transparency. This means that you can replace an expression with its value and you won't change anything.

Wait, no side effects?! How is that possible? Some Haskell functions do have side effects, such as file I/O. However, Haskell isolates functions that do have side effects, making it easy to write functions without side effects. Java is "object-oriented", but you can still write programs that do not follow OO style; similarly you can write Haskell functions with side-effects.

Type inference In most typed languages, you must explicitly declare the type of your data and functions In scripting languages, you do not need to specify your types, but you will get runtime errors if your types don't work "Duck typing" Flexible, but not safe With Haskell, you do not need to declare types, but the compiler checks them anyway (and you can declare them if you wish)

Lazy evaluation An almost unique feature of Haskell is that it is lazy it does not calculate results until they are needed. This feature allows Haskell to represent infinite data structures

Lazy Example Start up Haskell interactive mode and type: *Main> let oddnumbers = [1,3..] Note that this definition works just fine. However, if you now type in oddnumbers, it will print all odd numbers greater than 1. You can use this function to print out however many odd numbers you want: *Main> take 5 oddnumbers [1,3,5,7,9]

First homework due August 30th This assignment is designed to get you up and running with Haskell. Available in Canvas. Get started now!

Getting started with Haskell Install Haskell from http://www.haskell.org/platform/contents.html Work on examples from Chapter 2 of "Learn You a Haskell" (LYH from now on). http://learnyouahaskell.com/starting-out Ask me if you have questions