San Jose State University : Site Name

Navigation

Main Content

Working in Mars Mission Control, JPL

Ronald Mak

Department of Computer Science
Spring Semester 2014

Office hours: MW: 7:15-8:30 PM
Office location: MacQuarrie Hall, room 413
E-mail: ron.mak@sjsu.edu
Mission Control, Jet Propulsion Laboratory (JPL)
NASA Mars Exploration Rover Mission

CS 152/SE 152: Programming Language Paradigms


Section 5: MW 3:00-4:15 PM, Duncan Hall, room 318


Unofficial field trip to the
Computer History Museum
Saturday, May 3 at 11:30 AM

Extra-credit quiz

Assignments


# Date Due Assignment
1 Feb 3 Feb 10 Algebra 1 nightmare in FORTRAN IV

Input "card deck": quadratic.in
Sample printout: quadratic.out
Sample solution: quadratic.for
2 Feb 17 Feb 24 Recursive Scheme procedures

Sample solution: Assignment2Solution.ss
Automatic grader: Assignment2Grader.ss
Sample grader output: Assignment2Grader.out
3 Feb 24 Mar 7 Symbolic differentiation using infix notation

Infix differentiator: InfixDifferentiator.ss
Sample solution: Assignment3Solution.ss
Automatic grader: Assignment3Grader.ss
Sample grader output: Assignment3Grader.out
4 Mar 5 Mar 14 Prolog murder mystery
5 Apr 2 Apr 16 Scheme parser and scanner

Input file: input.lisp
6 Apr 14 May 2 Scheme interpreter

Lectures


Date Content
Jan 27 Slides: Introduction; good reasons; origins; plugboard programming; machine language; assembly language; punched cards; FORTRAN; Algol

Programming language timelines (large posters):
Up to August 2013
Through 2004 in color
Jan 29 Slides: Major programming domains; historic timelines; Example programs: FORTRAN, COBOL, Pascal, Ada; von Neumann architecture and beyond; lambda calculus; data and control abstractions; basic, structured, and unit abstractions

Example FORTRAN IV programs:   rooter.for   hilbert.for   hilbert.out
Example COBOL program:   STUDENTS.COB   STUDENTS.dat   STUDENTS.RPT
Example Pascal program:   newton.pas
Example Ada program:   calc.ada
Feb 3 Slides: Assignment #1; programming language abstractions; computational paradigms; language definition; grammar; syntax; semantics
Feb 5 Slides: Programming language translation; compilers and interpreters; future and popularity of languages; good language design; historical overview; efficiency; regularity; generality; orthogonality; uniformity
Feb 10 Slides: FORTRAN IV syntax; causes of irregularity; Algol 68 example; security; extensibility; functional programming; programs as functions; variables: imperative languages vs. math; referential transparency; lack of state; first-class data objects; higher-order functions; Lisp; Scheme; atoms and lists

Example Algol 68 program
Feb 12 Slides: Scheme evaluation rule; functions; binding values to symbols; constructing and deconstructing lists; procedures; dotted pairs; predicates; sameness predicates; defining procedures
Feb 17 Slides: Conditional expressions; recursion; base case; trace; member?; remove-first; swapper; unique; Assignment #2; Scheme documentation; manipulating symbols; symbolic differentiation

Derivative procedure:   deriv1.lisp
Feb 19 Slides: Symbolic differentiation; f(x) and f'(x); eval; apply; metalinguistic power; flat recursion; append; mutual recursion: even? and odd?

Derivative procedure:   deriv2.lisp   deriv3.lisp   deriv4.lisp
f(x) and f'(x):   f.lisp
Feb 24 Slides: Assignment #3; flat recursion: remove-top; deep recursion: remove-all, flatten, remove-leftmost, member-all?; iteration; iterative factorial; tail recursion; Fibonacci; scope; let; letrec; closures
Feb 26 Slides: First-class objects; procedures as arguments; map; procedures as return values; compose; logic; Prolog; objects and relations; facts; questions; variables; place markers; conjunctions; backtracking; rules

Example Prolog databases: likes1.pl   likes2.pl   likes3.pl   likes4.pl   family.pl   thief.pl
Mar 3 Slides: Assignment #2 solutions; automated grading; Prolog resolution and unification; arithmetic; gcd; trace; cut; library application

Example Prolog arithmetic: gcd.pl
Example cut: library1.pl   library2.pl  
Mar 5 Slides: Cut-failure example; Prolog lists: cons, append, reverse; Prolog's search strategy; Assignment #4; uses of Prolog

Example Prolog list predicates: list.pl
Mar 10 Slides: Object-oriented programming; software reuse and independence; extension of data or operations; redefinition of operations; abstraction; polymorphism; encapsulation and loose coupling; software frameworks; Smalltalk; IDE; everything is an object; Towers of Hanoi; objects and messages, syntax, messages

Towers of Hanoi in Java: Hanoi1.java   Hanoi2.java
Towers of Hanoi in Smalltalk: hanoi.st
Mar 12 Slides: Smalltalk messages; variables; equality and identity; statements; review for the midterm; sample midterm questions: Scheme and Prolog
Mar 19 Slides: Midterm solutions; Eclipse CDT; allocation of Java objects; allocation of C++ objects; Java virtual method binding; C++ static and virtual method binding

Java object allocation: MyClass.java    AllocateTest.java
C++ object allocation: MyClass.cpp

Java virtual methods: Animal.java    Cat.java    VirtualTest1.java    VirtualTest2.java
C++ static and virtual methods: VirtualCpp.cpp
Apr 2 Slides: Compilers and interpreters; conceptual design 1; parser; scanner; token; source; conceptual design 2; front end; intermediate tier; back end; conceptual design 3; how to scan for tokens; basic scanning algorithm; Scheme syntax diagrams; Scheme keywords; Scheme intermediate code; symbol table; Assignment #5
Apr 7 Slides: How to build intermediate code; top-down recursive-descent parser; symbol table implementation; symbol table stack; global symbol table; top-level symbol table; nested scopes and the symbol table stack; parse trees and symbol tables
Apr 9 Slides: Assignment #5 tips; nested scopes and the symbol table stack; symbol tables and nesting levels; executing Scheme programs; runtime stack; activation records
Apr 14 Slides: Executing Scheme programs; calling a procedure; runtime display; Assignment #6: Backus Naur Form (BNF); optional and repeated items; grammars and languages; derivations and productions
Apr 16 Slides: Extended BNF (EBNF); JavaCC compiler-compiler: regular expressions and parser specification; static and dynamic scoping; runtime memory management; Java Virtual Machine (JVM) architecture; runtime heap management; garbage collection: reference counts, mark and sweep, stop and copy, generational

JavaCC example: phone.jj
Apr 21 Slides: Name resolution and overloading; C++ operator overloading; data types; strongly and weakly typed languages; simple types; type constructors; reference and pointer types; type compatibility; polymorphism; sort an array of ints; use an ArrayList; dangers of raw ArrayList; use ArrayList<Integer>; boxing and unboxing

Java name overloading: OverloadMax.java
C++ operator overloading: OverloadOperator.cpp
Apr 23 Slides: Comparing objects; covariant Java arrays; synchronous and asynchronous runtime errors; runtime exception handing; exception objects; resumption vs. termination models; exception propagation; programmer-defined exceptions; parameter passing mechanisms; pass by value; pass by reference; pass by value-result; pass by name; thunks

Java covariant arrays:
CovariantArrays.java    SimpleShape.java    Square.java    Rectangle.java    Circle.java

Parameter passing:
PassStructByValue.cpp    PassArrayByValue.cpp    PassByValue.java    PassByReference.cpp
Apr 28 Slides: Data types: logical and physical forms; abstract data types (ADTs); encapsulation; language support for ADTs; design goals; example list ADT; operations; implementation as an array in Java; Assignment #5 solution; building a parse tree recursively; multithreaded programming; thread vs. process; advantages and challenges; multicores

Assignment #5 sample solution: Assignment5.zip
Apr 30 Slides: Multithreaded programming in Java; create a thread; Runnable example; thread states; activating and terminating threads; choosing threads to run; thread synchronization example; race condition; mutual exclusion; critical region; locks

Runnable example: GreetingProducer.java    ThreadTester.java
Thread synchronization examples: queue1.zip   queue2.zip
May 5 Slides: Locks; lock conditions; thread-safe queue add and remove; synchronize printing; integrated Java support for multithreading; monitors; Java synchronized methods; object locks; condition objects; bounded queue monitor; Ada monitors; multithreaded programming in C; degrees of granularity of parallism; program-level parallelism; C fork()

Thread synchronization examples: queue3.zip   queue4.zip   queue5.zip
C fork() example: forktest.c
May 7 Slides: Multithreaded programming is hard; multithreaded cafe example; message passing; Google's Go language

Multithreaded program example: BitbergCafe.zip
May 12 Slides: Assignment #6 partial solution: building symbol tables, walking parse trees, activation records, returning values; postmortem reports; final exam schedule; review for the final

Partial Assignment #6 solution: Schemer.zip

Goals


The primary goal of this course is to become a better programmer and software architect. We will accomplish this by attaining a deeper understanding of the programming languages that we use. The better we understand a (programming) language, the better we're able to express ourselves (write a program) in that language.

Every language is a product of its culture. Some cultures can express certain ideas and concepts better than other cultures. We will learn programming languages from other "cultures" such as functional programming and logic programming. This will expand our scope of programming concepts that we can then code in our "native" languages such as Java or C++.

We will also learn how programming languages are designed and implemented.

Prerequisites


CS 151 or CMPE 135 Object-Oriented Design grade C- or better
  Department policy is to enforce  
  all course prerequisites strictly.  

Required books


Programming Languages: Principles and Practice, 3rd edition
Kenneth Louden and Kenneth Lambert
Cengage Learning, 2012
ISBN: 978-1-111-52941-3

Online (more to come)


Teach Yourself Scheme in Fixnum Days, Dorai Sitaram
Structure and Interpretation of Computer Programs, 2nd ed., Harold Abelson and Gerald Jay Sussman