I maintain these notes as text in the Pandoc’s dialect of Markdown using embedded LaTeX markup for the mathematical formulas and then translate the notes to HTML, PDF, and other formats as needed.
Browser Advisory: The HTML version of this document requires use of a browser that supports the display of MathML. A good choice as of August 2020 is a recent version of Firefox from Mozilla.
(25, 28 Jan) Survey the Primary Paradigms (ELIFP Chapter 2)
(25 Jan) Motivate the study of functional programming
(for reference) 1977 Turing Award Address: John Backus. Can Programming Be Liberated from the von Neumann Style? A Functional Style and Its Algebra of Programs, Communications of the ACM 21.8 (1978): 613-641.
(for reference) Survey the Object-Based Paradigms (ELIFP Ch. 3)
HTML Slides: Original ELIFP
Scala example: Object-Oriented CountingOO.scala
Additional notes: Object-Oriented Software Development
Additional slides on Using CRC Cards (Class-Responsibility-Collaboration): HTML slides
Background: Kent Beck and Ward Cunningham. A Laboratory for Teaching Object-Oriented Thinking, In Proceedings of the OOPSLA’89 Conference, ACM, 1989.
Tutorial: Paul Gestwicki. CRC Card Analysis (YouTube), Ball State University, February 2016.
(30 Jan, 1, 4, 6 Feb) Introduce Scala to Java programmers
Note: These Notes were adapted from: Michel Schniz and Philipp Haller, A Scala Tutorial for Java Programmers
Notes on Scala for Java Programmers: HTML – PDF
Diagram for Scala’s unified type hierarchy
Scala source code from Notes:
(for reference) Miscellaneous overviews, cheat sheets, and tutorials
(1 Feb) Distribute Assignment #1. Due 13 Feb.
(6, 8 Feb) Examine Recursion Styles, Correctness, and Efficiency: Scala Version
Scala source code from Notes: RecursionStyles.scala
(for reference) “Tail Call” article on Wikipedia
(8 Feb) Take Quiz #1 over semester content through Notes on Scala for Java
(for reference) Examine functions adapted from SICP
Background reading: Chapter 1 of the classic SICP textbook
Harold Abelson and Gerald J. Sussman with Julie Sussman. Structure and Interpretation of Computer Programs, Second Edition, MIT Press, 1996:
First-order functions in Scala
Higher-order functions in Scala
(11 Feb) Survey Type System Concepts
(13, 15, 18, 20, 22, 25 Feb, 1 Mar) Study Functional Data Structures
Background reading: “Functional Data Structures,” Chapter 3, Paul Chiusano and Runar Bjarnason, Functional Programming in Scala, Manning, 2015 (i.e. the Red Book)
Lecture notes on Chapter 3 (primarily on List
type): HTML – PDF
Scala source: List2.scala
Reference: See the discusion of the object-based paradigms above for general information on the object-oriented nature of Scala.
(16 Feb) Distribute Assignment #2. Originally due 28 February, but extended to 4 March.
(22 Feb) Take Quiz #2 over Recursion Styles, Type System Concepts, and Sections 3.1-3.2 of Functional Data Structures notes. (Returned on 25 Feb.)
(27 Feb, 1 Mar) Examine a natural number arithmetic case study
(for reference) Background on Peano arithmetic and design patterns
Scala versions (2008, 2012, 2019)
Functional object-oriented with ordinary classes: Scala source
This version uses an object-oriented hierarchy of classes/objects organized according to the Composite, Singleton, and Null Object software design patterns. Once created, the Nat objects are immutable. The operations do not modify the state of an object; they create new objects with the modified state. It carries out computations by “passing messages” among the objects, taking advantage of subtype polymorphism (dynamic binding) to associate method calls with the correct implementation. This version also encapsulates the state within the objects in the hierarchy.
Functional module with case classes: Scala source
This version uses a Scala algebraic data type (defined using a sealed trait and case class/objects) with a group of functions defined in the companion object for the trait. It is organized similarly to the List algebraic data type from the Functional Data Structures chapter. This version uses pattern matching to identify the correct operation functionality. By using cases classes/objects, this version exposes the state outside the hierarchy.
Functional object-oriented with case classes: Scala source
This version is in-between the implementations above. It uses the traditional OO structure, but uses case classes/objects instead of ordinary objects. It uses subtype polymorphism for the left argument and uses pattern matching for the right argument to select the correct operation functionality. By using cases classes/objects, this version exposes the state outside the hierarchy.
Elixir version (2015):
Lua version (2013, 2014): source nats2.lua
Ruby version (2006): source Nat.rb
Java version (2004), simpler, no generics:
(for reference) Survey design patterns
Introduction to Patterns: HTML – PDF – HTML slides
John Vlissides. Designing with Patterns, In Pattern Hatching: Design Patterns Applied, Addison-Wesley, 1998: Powerpoint
Patterns notes and slides:
Additional references:
(4, 6, 8, 18, 20 Mar) Explore Handling Errors without Exceptions
Background reading: “Handling Errors without Exceptions,” Chapter 4, Paul Chiusano and Runar Bjarnason, Functional Programming in Scala, Manning, 2015 (i.e. the Red Book)
Scala source code from notes: Option2.scala
– Either2.scala
Scala examples for parameter-passing discussion:
ClosureExample.scala
– ClosureExample.out
ThunkExample.scala
– ThunkExample.out
Scala example for wrapping exceptions with Option
and Either
: WrapException.scala
(8, 18 Mar) Discuss Semester Project
(11-15 Mar) Enjoy Spring Break
(18, 20 Mar) Continue discussion of notes on Handling Errors without Exceptions
(18, 20, 22 Mar) Continue discussion of Semester Project; distribute description on 22 March
(25 Mar) Take double-point Quiz #3 over notes on Functional Data Structures and Handling Errors without Exceptions
(29 Mar) Return and discuss Quiz #3: Quiz03Test.scala
– List3.scala
(22 Mar) Distribute description of Assignment #3 (Mealy Machine Simulator); (29 Mar) extend deadline
See a similar, but imperative and object-oriented, implementation below for the Semantic Model (part e) for the State Machine used for for Fowler’s “Secret Panel” Controller External DSLs
(20, 22, 27, 29 Mar; 1, 3, 5 Apr) Explore Abstract Data Types in Scala using the Labeled Digraph ADT case study
Background reading on abstract data types
Background reading on directed graph ADTs
Scala solutions using method-chaining abstract data type API
Digraph
DigraphList
– test program Test_DigraphList.scala
DigraphMap
– test program Test_DigraphMap.scala
(for reference) Haskell solutions
DigraphADT_Map
– test module(for reference) Elixir solutions
(for reference) Notes on Data Abstraction (Parts of these notes have been integrated into the notes on Abstract Data Types in Scala above.)
(not updated 2019) Notes on Data Abstraction—Java Supplement (These notes describe nongeneric Java implementations, circa 1997, of the Stack
and Day
ADTs specified in the Data Abstraction notes above.)
(for reference) Lecture Notes on Modular Design (Parts of these notes have been integrated into the notes on Abstract Data Types in Scala above.)
(for reference) H. C. Cunningham, Y. Liu, and J. Wang. “Designing a Flexible Framework for a Table Abstraction,” In Y. Chan, J. Talburt, and T. Talley, editors, Data Engineering: Mining, Information, and Intelligence, pp. 279-314, Springer, 2010.
(for reference) Classic papers by David L. Parnas and associates:
(8 Apr) Take Quiz #4 over Abstract Data Types in Scala above; returned 10 April@. (10 Apr) Post Challenge Assignment #4
(10 Apr) Host guest lecture by J. P. Marum on reactive programming (20 minutes)
(10 Apr) Distribute Optional Assignment #4
Sandwich DSL Implementation (one opiton on assignment)
(10 Apr; 1, 3 May) Explore Strictness and Laziness
Background reading: “Strictness and Laziness,” Chapter 5, Paul Chiusano and Runar Bjarnason, Functional Programming in Scala
Scala source code from notes: StreamC.scala
(for reference) John Hughes, Why Functional Programming Matters, Computer Journal, Vol. 32, No. 2, pp. 98-107, 1989.
(for reference) Notes on Functional Program Evaluation Concepts – not updated 2019
(15 Apr) Yunshu Wang and Silu Zhang: Spark Fundamentals
(17 Apr) Nusrat Armin and Carla Rego: PySpark and Jupyter
(22 Apr) Matthew Toche: Scala Futures and Promises
(24 Apr) Chris Donelson and Deep Sharma: Squants Package
(26 Apr) Amulya Arora (and Layton Jones): Software Testing
(29 Apr) Saman Ray: Akka Actors in Scala
(3 May) Layton Jones Project Presentation (Software Testing)
(1 May) Continue exploring Strictness and Laziness above
(3 May) Take Quiz #5 over Chapter 5 Strictness and Laziness
(6 May: Noon – 3:00 p.m.) Optional final exam: Contact instructor by Noon on 3 May if you plan to take this exam!
END of Spring 2019 semester: Enjoy Summer!
(for reference) Use the Digraph ADT module (to build a game)
TODO: Create a Scala version of this example.
Wizard’s Adventure game, Elixir Version 1
This game is based on Chapters 5, 6, and 17 of Conrad Barski’s Land of Lisp: Learn to Program in Lisp, One Game at a Time, No Starch Press, 2011.
Concepts: Importing Elixir modules, use of Elixir features such as atoms, maps, pipes, and complex pattern matching, designing functional programs to handle global state; use of Elixir API modules Enum
, Dict
, List
, Keyword
, String
, IO
, etc.).
Wizard’s Adventure game, Elixir Version 2
This version uses a higher-order function to generate game actions and improved handling of the game state.
Additional concepts: Use of higher-order factory function to generate functions from first- and higher-order arguments; storing functions in a data structure, calling functions stored in a data structure; use of mutator (setter) and accessor (getter) functions for the data structure.
(for reference) Examine the CookieJar ADT case study (and other examples)
Description of Bag Concept (used in specification)
Immutable CookieJar ADT Implementation in Scala (ICookieJar.scala
) – uses method-chaining functional style with immutable objects
Mutable CookieJar ADT Implementation in Scala (CookieJar
) – uses object-oriented style with mutable state
Carrie’s Candy Bowl ADT in Lua – gives the specification of a Candy Bowl ADT (similar to the Cookie Jar above) and two implementation using Lua modules
Carrie’s Candy Bowl ADT in Scala
CandyBowl
to define abstract data type interfaceCandyBowlList
to define a list-based implementationOlder mutable Java abstract data type implementations. These use nongeneric Java implementations done during the 1997-98 timeframe
ArrayList
or Vector
)(for reference) Examine the Dice of Doom game
Background: Conrad Barski. Land of Lisp: Learn to Program in Lisp, One Game at a Time, No Starch Press, 2011.
Dice of Doom, Elixir Version 1a
This is a basic eagerly evaluated version (similar to that developed on pages 303-325 of Land of Lisp). This version supports either two human players or a human player and a simple, minimax search-based “AI” (artificial intelligence) opponent.
Dice of Doom, Elixir Version 1b
This is an eager version above with an attempt at memoization of functions neighbors
and game_tree
using the Elixir Agent
modules.
Dice of Doom, Elixir Version 2a,
This is a lazy version using Elixir Stream
data structures (but without the memoization optimizations). This is based on version 1a above plus the discussion from pages 384-389 in chapter 18 of Land of Lisp. This version implements a limited depth minimax search, but it does not implement the artificial intelligence heuristics given in the last part of chapter 18.
(TBD) Discuss domain-specific languages and Sandwich DSL case study
Concepts: domain-specific languages (DSLs); DSLs versus general-purpose programming languages; external versus internal DSLs; shallow versus deep embedding of internal DSLs; use of algebraic data types to implement DSLs
Notes: Domain-Specific Languages
Sandwich DSL Implementation
Sandwich DSL in Lua (similar but not identical to Haskell description
sandwich_model.lua
(for reference) Discuss State Machine External DSLs based on Martin Fowler’s Secret Panel Controller (State Machine) DSLs
Backgrond: Martin Fowler. Domain Specific Languages, Addison Wesley, 2011.
Other items from the instructor’s notes
Scala notes
Graphviz and dot
language reference and examples
graphviz
.dot
ExprLangModDep.gv
– script
– png
outputDFA01.gv
– script – pdf
outputNFA01.gv
– script – svg
outputNFA01a.gv
– script – svg
outputInfix1plus1b.gv
– script – png
outputScala XML-based External DSL (Fowler Ch. 1, 3, 5)
Scala Custom External DSL with a Delimiter-Directed parser (Fowler Ch. 1, 3, 5, 17)
Scala Custom External DSL with hand-coded Ad Hoc Recursive-Descent parser (Fowler Ch. 1, 3, 5, 21)
Scala Custom External DSL (using Scala parser combinator library) with embedded state machine builder (Fowler Ch. 1, 3, 5, 22)
Scala Custom External DSL (using Scala parser combinator library) with full AST construction (Fowler Ch. 1, 3, 5, 22)
Scala Static C Code Generator with Model-Aware target platform library (Fowler Ch. 1, 3, 5, 8, 52, 55)
Scala Graphviz Dot Language Code Generator (added 2018) (Fowler Ch. 1, 3, 5, 8, 52)
(TBD) Discuss Fowler’s Computer Configuration Internal (Ch. 4, 35, 36, 38)
Background: Martin Fowler. Domain Specific Languages, (Addison Wesley, 2011).
Scala versions (2009)
(TBD) Discuss Fowler’s Email Message Building Internal DSL (Ch. 35)
Background: Martin Fowler. Domain Specific Languages, (Addison Wesley, 2011). See listing of chapters under Computer Configuration internal DSL above.
Scala versions (2009)
Explore Fowler’s Lair Configuration DSLs
Background on Lair DSL
Background on internal DSLs: Martin Fowler. Domain Specific Languages, (Addison Wesley, 2011).
See the CSci 658 (Software Language Engineering) course materials for more information about DSLs.
Background on Lua
See Lua references below
Several of the Lair DSL programs must execute with Lua 5.1 because they use a few Lua platform features changed in Lua 5.2 or 5.3. I installed the lua@5.1 package on my iMacs using the Homebrew package manager.
At the terminal command line, lua5.1 testNN.lua
compiles and executes the test driver program for the DSL with files builder program builderNN.lua
and DSL script rulesNN.lua
.
Shared modules
Fowler’s Ruby source
Lua (2013)
Python 3 (2018)
Internal DSL using Global Function Sequence pattern
Fowler’s Ruby
Lua (2013)
Python 3 (2018)
Internal DSL using Class Method Function Sequence and Method Chaining patterns
Fowler’s Ruby
Lua (2013)
Python 3 (2018)
Internal DSL using Expression Builder and Method Chaining patterns
Fowler’s Ruby
Lua (2013)
Python 3 (2018)
Internal DSL using Nested Closures pattern
Fowler’s Ruby
Lua (2013)
Python 3 – none yet. (Python’s weak syntactic support for lambdas does not allow the relatively direct approach usable in Ruby, Scala, and Lua.)
Internal DSL using Expression Builder, Object Scoping, and Method Chaining patterns
Fowler’s Ruby
Lua (2013)
Python 3 – none yet
Internal DSL using Literal Collection pattern
Fowler’s Ruby
Lua (2013)
Python 3 – none yet
External DSL using Parser/Builder (no corresponding example in Fowler book chapter)
Lua (2013)
Python 3 (2018)
(TBD) Discuss Fowler’s DSL Reader framework (2006)
Background:
Ruby shared modules (2006)
Ruby direct configuration and testing of Reader (2006)
Ruby single-pass external text DSL (2006)
Ruby two-pass external XML DSL (2006)
Ruby internal DSL
H.C. Cunningham. “A Little Language for Surveys: Constructing an Internal DSL in Ruby,” In Proceedings of the ACM SouthEast Conference, 6 pages, March 2008.
(for reference) Simple, silly Employee hierarchy example
(TBD) Overview object-oriented programming in Scala
Instructor’s notes on Object-Oriented Software Development
Scala translation of Frog dynamic composition example: Scala source – output
Modified Philosophical Frog example from Odersky et al:
Scala source – output
Modified Stackable traits example (IntQueue) from Odersky et al:
Scala source – output
(TBD) Frameworks, based on Timothy Budd’s An Introduction to Object-Oriented Programming, Third Edition, Chapter 21
Simple Sorting Framework examples.
Ice Cream Store discrete event simulation.
(TBD) Cunningham group “Using Classic Problems …” paper.
H. C. Cunningham, Y. Liu, and C. Zhang. “Using Classic Problems to Teach Java Framework Design,” Science of Computer Programming, Special Issue on Principles and Practice of Programming in Java (PPPJ 2004), Vol. 59, No. 1-2, pp. 147-169, January 2006. doi: 10.10.16/j.scico.2005.07.009. preprint PDF
Related tutorial: H. C. Cunningham, Y. Liu, and C. Zhang. “Teaching Framework Design Using Classic Problems,” Journal of Computing Sciences in Colleges, Vol. 21, No. 5, pp. 10-12, CCSC, May 2006: abstract presentation
(TBD) Scala Divide-and-Conquer Framework, similar to the Java framework in the “Using Classic Problems …” paper
Template-based Divide-and-Conquer Framework (DivConqTemplate):
Scala source
Strategy-based Divide-and-Conquer Framework (DivConqStrategy):
Scala source
Traits for Problem and Solution descriptions for both frameworks (DivConqProblemSolution):
Scala source
Application of Template-based framework to QuickSort (QuickSortTemplateApp):
Scala source – program output
Application of Strategy-based framework to QuickSort (QuickSortStrategyApp):
Scala source – program output
Descriptor for QuickSort state for both QuickSort applications (QuickSortDesc):
Scala source
(TBD) Scala Binary Tree Framework, similar to the Java framework in the “Using Classic Problems …” paper
Straightforward translation of the Java program to Scala:
Generic implementation of BinTree framework in Scala:
H. Conrad Cunningham. Introduction to Functional Programming Using Haskell, Computer and Information Science, University of Mississippi, 2016-2017. (I am writing this “textbook” primarily for CSci 450 and likely will use the title Exploring Languages with Interpreters and Functional Programming for the Fall 2018 draft.)
H. Conrad Cunningham. Notes on Functional Programming with Haskell, Computer and Information Science, University of Mississippi, 1994-2014. (I am revising this document and integrating it with other materials to produce the new “textbook” above Exploring Languages with Interpreters and Functional Programming. The chapters at the chapters at the end have not yet been integrated.)
School of Haskell online tutorials
Miron Lipovaca. Learn You a Haskell for Great Good: A Beginner’s Guide, a free online tutorial at http://learnyouahaskell.com/. (It is also in print from No Starch Press, 2011.)
Kees Doets and Jan van Eijck. The Haskell Road to Logic, Math and Programming, March 2004. This book is also available in print, published by College Publications, 2004.
Paul Hudak. The Haskell School of Music: From Signals to Symphonies, Version 2.6, January 2014. This book is a recent rewrite of Hudak’s The Haskell School of Expression: Learning Functional Programming through Multimedia, Cambridge University Press, 2000.
Simon Marlowe. Parallel and Concurrent Programming in Haskell: Techniques for Multicore and Multithreaded Programming,
Bryan O'Sullivan, Don Stewart, and John Goerzen. Real World Haskell,
Definitive reference: Roberto Ierusalimshcy. Programming in Lua, Fourth Edition, Lua.org, Rio de Janiero, Brazil, 2016. (The First Edition of this book, covering Lua 5.0, is available online at https://www.lua.org/pil/contents.html.)
Instructor’s Lua slides (from CSci 450, Fall 2016)
Bernd Klein. Python Course
Chris Pine. Learn to Program
why the lucky stiff (Jonathan Gillette). why's (poignant) guide to Ruby
Definitive reference: Martin Odersky, Lex Spoon, and Bill Venners. Programming in Scala, Third Edition, Artima, 2016. The first edition (2008) is available online at http://www.artima.com/pins1ed/.
Martin Odersky. Scala by Example, EPFL, 2014. [local]
Instructor’s Notes on Scala for Java Programmers
Paul Chiusano and Runar Bjarnason. Functional Programming in Scala, Manning, 2015.