314-CSCE Programming Languages, Spring 2015

Course Essentials

Course CSCE 314 – Programming Languages, 09:10 am–10:00 am, HECC 100
Instructor Jaakko Järvi
Course pages http://courses.cse.tamu.edu/jarvi/2015/CSCE-314
Contact jarvi@cse.tamu.edu
Office hours Monday 10:15–11:00, or by appointment (my office is 416)
Prerequisite CSCE 221.
Teaching Assistant Ankur Singhal (ankursinghal@email.tamu.edu), office hours: MWF 11:00–12:00, HRBB 339
Peer Teachers Steven Bierwagen
  Sarah R. Sahibzada
  Amelia Gaughan Peer teachers' office hours
  Bailey Bauman
  Nathan De Jong

In a nutshell

This course explores the design space of programming languages via an in-depth study of two programming languages, one functional (Haskell), one object-oriented (Java); it focuses on idiomatic uses of each language and on features characteristic for each language. Prerequisite: CSCE 221.

The syllabus can be found here.

News

<2015-04-26 Sun>
Assignment 8 is out, see the Assignments section.
<2015-04-19 Sun>
Assignment 7 is out, see the Assignments section.
<2015-04-05 Sun>
Assignment 6 is out, see the Assignments section.
<2015-03-24 Tue>
Assignment 5 is out, see the Assignments section.
<2015-02-17 Tue>
Assignment 3 is out, see the Assignments section.
<2015-01-27 Tue>
Assignment 1 is out, see the Assignments section.

Schedule and material

Date Topic Material Side reading
Wed, Jan 21 Class setup; Tour of Language Implementation Slides 1 Slides 2  
Fri, Jan 23 Haskell & Functional programming basics Slides 3 Hutton: Ch1
Mon, Jan 26 Haskell & Functional programming basics   Hutton: Ch2
Wed, Jan 28 Haskell & Functional programming basics   Hutton: Ch3
Fri, Jan 30 Haskell & Functional programming basics    
Mon, Feb 2 More of Haskell (patterns, comprehensions, higher-order functions…) Slides 4 Hutton: Ch4
Wed, Feb 4 More of Haskell (patterns, comprehensions, higher-order functions…)   Hutton: Ch5
Fri, Feb 6      
Mon, Feb 9     Hutton: Ch6
Wed, Feb 11 Data types Slides 5 Hutton: Ch7
Fri, Feb 13     Hutton: Ch10
Mon, Feb 16 Syntactic Analysis Slides 6  
Wed, Feb 18 Syntactic Analysis    
Fri, Feb 20 About names; Modules, ADTs Slides 7a Slides 7b  
Mon, Feb 23 Functional parsers Slides 8 Hutton: Ch8
Wed, Feb 25 Functional parsers Example code: P.hs  
Fri, Feb 27 Functional parsers    
Mon, Mar 2 Still a bit on parsing    
Wed, Mar 4 Review for midterm    
Fri, Mar 6 Expression parsers, starting on monads Example code: P2.hs  
Mon, Mar 9 Midterm    
Wed, Mar 11 Monads and I/O Slides 9 Hutton: Ch9
Fri, Mar 13 Monads and I/O io.hs monadic_interpreter.hs  
Mon, Mar 16 no class; spring break    
Wed, Mar 18 no class; spring break    
Fri, Mar 20 no class; spring break    
Mon, Mar 23 Type systems and type checking Slides 10  
Wed, Mar 25 Type systems and type checking    
Fri, Mar 27 Guest lecture: Gabriel Foust (Java primer) Slides Example code: java_code.tgz  
Mon, Mar 30 Guest lecture: Prof. Jeff Huang (About debugging Java programs) Slides  
Wed, Apr 1 Object-oriented programming basics Slides 11  
Fri, Apr 3 Reading day: no class    
Mon, Apr 6 Object-oriented programming basics    
Wed, Apr 8 Object-oriented programming basics    
Fri, Apr 10 Java Generics Slides 12  
Mon, Apr 13 Java Generics    
Wed, Apr 15 Co-contravariance, Wildcards    
Fri, Apr 17 Wildcards    
Mon, Apr 20 Java concurrency Slides 13, example programs  
Wed, Apr 22 Java concurrency    
Fri, Apr 24 Java concurrency    
Mon, Apr 27 Concurrency    
Wed, Apr 29 Reflection Slides 14  
Fri, May 1 JVM    
Mon, May 4 JVM Slides 15 animation  
Tue, May 5 JVM, review    
Fri, May 8th Final exam, 8:00–10:00AM    

Assignments

There will be approximately eight or nine assignments. The first two assignments will familiarize you with the basic features of functional programming languages, and the basics of functional programming. The assignments 3–6 give practice in more advanced features and programming idioms.

The assignments from (about) 7. onwards focus on features of modern object-oriented languages (Java in particular). We cover genericity, wildcards, reflection, and basics of the features for concurrent programming.

Assignment 1 Skeleton code: a1-skeleton.hs Due Monday, Feb 2nd Example answer
Assignment 2 Skeleton code: a2-skeleton.hs Due Tuesday, Feb 17th Example answer
Assignment 3   Due Fri, Feb 27th Example answer
Assignment 4 Skeleton code: a4-skeleton.tar Due Fri, Mar 13th Example answer as part of a5
Assignment 5 Skeleton code: a5-skeleton.tar Due Fri, Apr 3rd  
Assignment 6   Due Thu, Apr 16th Example answer
Assignment 7   Due Sun, Apr 26th Example answer
Assignment 8   Due Mon, May 4th  

Exams

Midterm

The first exam will be on Monday, Mar 9th, during regular class hours. Exam is based on lectures and discussions in class. The material to study is thus all slides, assignments, and chapters 1–8 and 10. from the Haskell book.

Some hints about what to study are here.

Final exam

The final exam is on Friday, May 8th, 8:00-10:00AM.

Material to study include all slides and notes from class since the midterm and the assignments on Java.

Some hints:

It is good to know the Monad type class, and understand a few of its instances, such as Maybe and Parser, and how the return and >>= functions are defined for them.

It is worth the while to study Java generics: how to specify type parameter and their bounds; the basic idea of how Java implements generics; and wildcards (especially how subtyping works when wildcards are used as type arguments).

It is equally worthy to understand equals, and the limitations of OO for defining such binary methods.

It is invariably so, that class invariants should be something that you understand; you should also know what pre- and post conditions are.

It is useful to study the concurrency features of Java: what are threads, how to construct threads and make tasks run on separate threads, and how to synchronize with locks.

It is advicable to reflect on reflection, e.g., the Class class, Java's entry point to reflection, and how it is used.

It is virtually certain that something small will be asked about the JVM, even though we have not yet even covered any of it.

Do not study just the above, there'll be questions outside of these topics as well.

About the course

We use the following Haskell book:

Graham Hutton: Programming in Haskell, Cambridge University Press.

In addition, you will need some Java book (regarded as more of reference material), such as:

Java(TM) Programming Language, by James Gosling, Ken Arnold and David Holmes; 4th edition, Prentice Hall, 2006.

Other recent books about Java are suitable as well. Not all of the books will be covered, and other material is used as well.

The course aims to deepen understanding on the concepts and features of programming languages, and how programming languages work. After a general overview of language processing, we study the features of Haskell, focusing on what constitutes a functional programming language. Non-exhaustive list of what follows is:

  • Types, static typing and type inference
  • Parametric polymorphism
  • Higher-order functions, closures
  • Recursive types and functions
  • Algebraic data types
  • Abstract data types and modules
  • Type classes
  • Effects in a ``pure'' language

Along the way, we cover the basic ingredients of a programming language implementation, including:

  • Grammars, lexing and parsing
  • Abstract syntax, internal representations
  • Types and type checking
  • Interpretation

We use Haskell to implement a small programming language as course assignments.

The Java portion of the class focuses on the major features of a modern object-oriented programming language, and focuses on interesting language features and the language infrastructure of Java, including:

  • Subtyping and inheritance
  • Subtype polymorphism
  • Exception handling
  • Generics, wildcards
  • Reflection
  • Concurrency

Programming languages are a very large area. The course aims at providing an understanding of the use, efficiency considerations, and implementation approaches of common abstraction mechanisms and language constructs in modern programming languages. I hope that the course will allow you to more effectively use the languages of today, make it easier for you to learn new programming languages in the future, and possibly get excited about contributing to research and development of programming languages in the future. Even though we use and study two specific programming languages, Haskell and Java, learning more of these languages should be considered as a side benefit of the course, not the main goal.


Resources

Software

Many programming assignments will be done with Haskell, here are a few pointers to get you started:

Using GHC

A few other compilers exist, but we will use the Glasgow Haskell Compiler. It is installed on linux.cse.tamu.edu and compute.cse.tamu.edu servers.

An easy way to interact with GHC is to edit your document, say, Foo.hs in your favourite editor (== Emacs, with haskell-mode), and invoke the GHC interpreter in a shell window:

ghci 

The most commonly used commands are

  • :l Foo to load the module Foo (from your file foo.hs)
  • :r to re-load the previously loaded module
  • :i x to inspect the value, type, … x
  • :t x to show the type of x
  • :q to quit the interpreter

The compiler is invoked, for example, as:

ghc --make main.hs

The --make option determines automatically which modules need to be recompiled, so you don't have to write a makefile yourself. (Also GHC's analysis of what needs to be recompiled is more fine grained, thus faster).

GHC and Emacs in linux.cse.tamu.edu

To set up ghc with Emacs, follow the directions below:

  1. Create a .emacs file (if you don't have one)
  2. Add the following to your .emacs
(load "/home/faculty/jarvi/lib/emacs/haskell-mode/haskell-site-file")

(add-hook 'haskell-mode-hook 'turn-on-haskell-ghci)
(add-hook 'haskell-mode-hook 'turn-on-font-lock)

(add-hook 'haskell-mode-hook 
	  (function
	   (lambda ()
	     (setq haskell-program-name "ghci"))))

(setq haskell-ghci-program-args '("-fglasgow-exts"))
  1. Launch emacs, start editing some Haskell file, such as a1.hs.
  2. C-c C-l launches the interpreter and loads the current file.

\(\LaTeX\) Typesetting System

Author: Jaakko Järvi

Created: 2015-05-05 Tue 16:49

Emacs 24.4.1 (Org mode 8.2.10)

Validate