CS 6371: Advanced Programming Languages

Similar documents
CS : Language-based Security

Languages and Compilers

CS 241 Data Organization. August 21, 2018

CS 241 Data Organization using C

Introduction to Data Structures

CS 240 Fall 2015 Section 004. Alvin Chao, Professor

Data Structures and Algorithms

Beijing Jiaotong University CS-23: C++ Programming Summer, 2019 Course Syllabus

CS 3813/718 Fall Python Programming. Professor Liang Huang.

Principles of Compiler Construction ( )

CS 113: Introduction to

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

CS 220: Introduction to Parallel Computing. Arrays. Lecture 4

COSE212: Programming Languages. Lecture 0 Course Overview

Announcements. 1. Forms to return today after class:

Introduction to Programming System Design CSCI 455x (4 Units)

CSE 504: Compiler Design

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling

AP Computer Science A: Java Programming

Updated: 2/14/2017 Page 1 of 6

Welcome to... CS113: Introduction to C

San Jose State University - Department of Computer Science

Object-Oriented Programming for Managers

CSC324 Principles of Programming Languages

Welcome to CompSci 201

HW1 due Monday by 9:30am Assignment online, submission details to come

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

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

COMP 215: INTRO TO PROGRAM DESIGN. Prof. Chris Jermaine Chris Prof. Chris Dr. Chris

CSE 374 Programming Concepts & Tools

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

Computer Science Department

Principles of Compiler Construction ( )

Final CSE 131B Spring 2004

Lecture 1: Course Introduction

CS61C : Machine Structures

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

TTh 9.25 AM AM Strain 322

Compilers for Modern Architectures Course Syllabus, Spring 2015

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

Hi! My name is Sorin. Programming Languages. Why study PL? (discussion) Why study PL? Course Goals. CSE 130 : Fall 2013

Programming Languages

CMSC 201 Spring 2018 Lab 01 Hello World

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

CMSC 201 Spring 2017 Lab 01 Hello World

Programming Language Concepts, cs2104 Lecture 01 ( )

Java Programming. Zheng-Liang Lu. Java 308 Spring Department of Computer Science & Information Engineering National Taiwan University

CS61C : Machine Structures

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

Semantic Analysis. Lecture 9. February 7, 2018

CS 161: Object Oriented Problem Solving

15-411/ Compiler Design

Question: Total Points: Score:

ECE Object-Oriented Programming using C++ and Java

CIS 3308 Web Application Programming Syllabus

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

CS 231 Data Structures and Algorithms, Fall 2016

CSci Introduction to Operating Systems. Administrivia, Intro

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

Functions. Nate Foster Spring 2018

Python for Analytics. Python Fundamentals RSI Chapters 1 and 2

Midterms Save the Dates!

CS16 Exam #1 7/17/ Minutes 100 Points total

Principles of Program Analysis. Lecture 1 Harry Xu Spring 2013

San José State University Department of Computer Science CS 166 / SE 166, Information Security, Section 4, spring, 2017

Lecture 1: Course Introduction

CS 211 Programming I for Engineers

ESET 349 Microcontroller Architecture, Fall 2018

CSE 114, Computer Science 1 Course Information. Spring 2017 Stony Brook University Instructor: Dr. Paul Fodor

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

Survey of Programming Languages Dr. R. M. Siegfried 407 Science (516) (not for homework submission)

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

CMPE 152 Compiler Design

Assignment Tutorial.

Outline. Intro. Week 1, Fri Jan 4. What is CG used for? What is Computer Graphics? University of British Columbia CPSC 314 Computer Graphics Jan 2013

Intro. Week 1, Fri Jan 4

CSCI455: Introduction to Programming System Design

Using the Computer for Essays

CS 375 UNIX System Programming Spring 2014 Syllabus

Section 1: Let s Shake Off the Rust!

Department of Computer & Information Sciences. CSCI-342: Introduction to Information Security Syllabus

CSE 333 Lecture 1 - Systems programming

Hi! My name is Sorin. Programming Languages. Why study PL? (discussion) Why study PL? Course Goals. CSE : Fall 2017

These are notes for the third lecture; if statements and loops.

CIS 101 Introduction to Computers Online Section About This Course and Getting Started Online Instructor Brad Ford

CS 553 Compiler Construction Fall 2009 Project #1 Adding doubles to MiniJava Due September 8, 2009

CS 220: Introduction to Parallel Computing. Beginning C. Lecture 2

CSCI-GA Scripting Languages

Type Checking and Type Equality

Introduction to Nate Foster Spring 2018

Syllabus for CSC 455 Database Systems 3 Credit Hours Spring 2012

CIS 121 Data Structures and Algorithms with Java Spring 2018

Syllabus COSC-051-x - Computer Science I Fall Office Hours: Daily hours will be entered on Course calendar (or by appointment)

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

Course Wrap-up. CSC207 Fall 2015

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

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB!

CS61C : Machine Structures

Spring 2017 :: CSE 506. Introduction. Nima Honarmand

Transcription:

CS 6371: Advanced Programming Languages Dr. Kevin Hamlen Spring 2017 Fill out, sign, and return prereq forms: Course number: CS 6371 Section: 1 Prerequisites: CS 5343: Algorithm Analysis & Data Structures CS 5349: Automata Theory

Today s Agenda Course overview and logistics Course philosophy and motivation What is an advanced programming language? Type-safe vs. Unsafe languages Functional vs. Imperative programming Introduction to OCaml The OCaml interpreter and compiler An OCaml demo

Course Overview How to design a new programming language specifying language formal semantics bad language design and the software crisis new programming paradigms: functional & logic how to formally prove program correctness Related courses CS 4337: Organization of Programming Languages CS 5349: Automata Theory CS 6353: Compiler Construction CS 6367: Software Verification & Testing

Course Logistics Class Resources: Course homepage: www.utdallas.edu/~hamlen/cs6371sp17.html My homepage: www.utdallas.edu/~hamlen Tentative office hours: 1 hr immediately after each class Email: hamlen AT utdallas DOT edu Grading Homework: 25% In-class quizzes: 15% Midterm exam: 25% Final exam: 35% Homework 9 assignments: 6 programming + 3 written Homework must be turned in by 1:05pm on the due date. Programming assignments submitted through elearning; written assignments submitted in hardcopy at start of class. Late homeworks NOT accepted! Attendance of at least 2 of first 3 classes is MANDATORY.

Homework Policy Students MAY work together with other current students on homeworks You MAY NOT consult homework solution sets from prior semesters (or collaborate with students who are consulting them). CITE ALL SOURCES includes webpages, books, other people, etc. citation is required even if you don t copy the source word-for-word there is nothing wrong with using someone else s ideas as long as you cite it you will not lose any marks or credit as long as you cite Violating the above policies is PLAGIARISM (cheating). Cheating will typically result in automatic failure of this course and possible expulsion from the CS program. It is much better to leave a problem blank than to cheat! Usually ~60% is a B and ~80% is an A. However, cheating earns you an F. It s not worth it!

Quizzes in-class on specified homework due dates about 15-20 min. each approximately 1 quiz per unit, so about 8 total lowest one dropped, so you can miss one without penalty other misses only permitted in accordance with university policy (e.g., illness with doctor s note, etc.) closed-book, closed-notes think of them as extensions to the homework length/difficulty similar to one or two homework problems To prepare, be sure you can solve problems like those seen on the most recent homework in about 15-20 minutes each and without group help!

Difficulty Level Warning: This is a tough course cutting-edge, PhD-level material difficulty ranked 9/9 on average by past students No required text book very few (approachable) texts cover this advanced material no large pools of sample problems exist to my knowledge useful texts: book by Glynn Winskel on reserve in UTD library online text and several online manuals linked from webpage Warning: Some online web resources devoted to this material are INCORRECT (e.g., certain Wikipedia pages). Rely only on authoritative sources. What you ll get out of taking this course excellent preparation for PhD APL qualifier exam solid understanding of language design & semantics modern issues in declarative vs. imperative languages deep connections between abstract logic and programming

About me Ph.D. from Cornell University (2006) B.S. in CS & Math from Carnegie Mellon Research: Computer Security, PL, Compilers Industry Experience: Microsoft Personal Christian married, three sons (one 4-year-old, and twin 2-year-olds) Programming habits C/C++ (for low-level work) assembly (malware reverse-engineering) C#, Java (toy programs) Prolog (search-based programs) OCaml, F#, Haskell, Gallina/Coq (everything else)

Course Plan Running case-study: We will design and implement a new programming language Code an interpreter in OCaml OCaml ( Objective Categorical Abstract Meta- Language ) is an open-source variant of ML Microsoft F# is OCaml for.net (but not fully compatible with OCaml, so don t use it for homework) Warning: OCaml has a STEEP learning curve! Pre-homework: Install OCaml Go to the course website and follow the instructions entitled To Prepare for the Course by next time

What is an Advanced Programming Language?

C/C++: Unsafe Languages Find the bug: #include <stdio.h> int main() { char name[1024]; printf( Enter your name: ); gets(name); printf( Your name is: %s\n, name); return 0; }

C/C++: Unsafe Languages Find the bug: #include <stdio.h> Buffer Overflow! int main() { char name[1024]; printf( Enter your name: ); gets(name); printf( Your name is: %s\n, name); return 0; } C/C++ lets you write programs that seg fault Some language features cannot be used safely! Most of the software crashes you experience are a direct result of the unsafe design of C/C++

Java: A Type-safe, Imperative Find two bugs: Language import java.io.*; import java.util.*; class Summation { public static void main(string[] args) { List list = new LinkedList(); for (int i=0; i<args.length; ++i) list.add(args[i]); int sum = 0; while (!list.isempty()) sum += ((Integer)list.remove(1)).intValue(); } } System.out.println(sum);

Java: A Type-safe, Imperative Language Find two bugs: import java.io.*; import java.util.*; OutOfBounds Exception! class Summation { public static void main(string[] args) { List list = new LinkedList(); Cast Exception! for (int i=0; i<args.length; ++i) list.add(args[i]); int sum = 0; while (!list.isempty()) sum += ((Integer)list.remove(1)).intValue(); } } System.out.println(sum);

Problems with Java Every Java cast operation is a potential crash In Java, a crash is an uncaught exception instead of a seg fault Some typecasting issues can be solved with Generics, but not all (e.g., list emptiness check) Problem: Java relies on programmer-supplied typing annotations

Goals of Functional Languages In an Advanced Programming Language: The compiler should tell you about typing errors in advance (not at runtime!) The language structure should make it difficult to write programs that might crash (no unsafe casts!) 80% of your time should be spent getting the program to compile, and only 20% on debugging should be tractable to create a formal, machinecheckable proof of correctness for mission-critical core routines, or even full production-level apps

In OCaml You almost never need to cast anything The compiler figures out all the types for you If there s a type-mismatch, the compiler warns you OCaml is fast Somewhere between C (fastest) and Java (slow) Very hard to measure precisely. (So-called language benchmarks typically call underlying math libraries that aren t even implemented in the languages being tested!) Functions are first-class : you can pass them around as values, assign them to variables, you can build them at runtime (Runtime Code Generation) But: The syntax is very weird if you ve only ever programmed in imperative languages!

OCaml: Getting Started OCaml programs are text files (*.ml) Write them using any text editor (e.g., Notepad) Unix: Emacs has syntax highlighting for ML/OCaml Windows: I use Vim (www.vim.org) Installing OCaml (see course website) Unix: pre-installed on the department Unix machines Windows: Self-installers for native x86 and for Cygwin Two ways to use OCaml: The OCaml compiler: ocamlc (compile *.ml to binary) OCaml in interactive mode (use OCaml like a calculator) Demo