4 May 2018
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.
Advisory: The HTML version of this document requires use of a browser that supports the display of MathML. A good choice as of May 2018 is a recent version of Firefox from Mozilla.
(22 Jan) Review syllabus. Distribute papers to be discussed over next two weeks.
(24-26 Jan) Discuss “Little Languages” paper
Paper: Jon Bentley. Programming Pearls: Little Languages, Communications of the ACM, Vol. 29, No. 8, pp. 711-721, August 1986.
Software: The groff
package includes the GNU implementations of the troff
set of “Unix” tools such as pic
and chem
. (I installed this on my iMac using Homebrew. I also installed the plotutils
package to help with display in various formats.)
Additional references for little language pic
(not discussed)
pic
Macros, Retrieved from http://www.kohala.com/start/ (troff resources, pic), 24 January 2018. [pic
source]Additional references for the little languages lex
, yacc
, make
, and chem
(not discussed)
(26-29 Jan) Discuss “No Silver Bullet” paper and related issues
Paper: Frederick P. Brooks. No Silver Bullet: Essence and Accident in Software Engineering, IEEE Computer, Vol. 20, No. 4, 10-19, 1987.
Retrospective paper after 10 years (not discussed): Frederick P. Brooks. ‘No Silver Bullet’ Refired, Chapter 17 in The Mythical Man Month: Essays on Software Engineering, Anniversary Edition, Addison Wesley, 1995.
(29-31 Jan) Discuss “Language-Oriented Programming” paper
Paper: M. P. Ward. Language-Oriented Programming, Software–Concepts and Tools, Vol. 15, No. 4, pp. 147-161, 1994. [local]
Additional references from paper (not discussed)
(31 Jan; intermittently until Spring Break, 19-28 Mar; 2-6 Apr) Discuss overview of Domain Specific Languages
Instructor’s notes on Domain Specific Languages
Mixed-in introductory discussion of Fowler’s DSL book introductory chapters, State Machine DSL, and Computer Configuration DSL below.
References used in notes (most not discussed directly)
(dates on items) Survey Design Patterns
(5-7 Feb) Instructor’s notes on Introduction to Patterns [HTML slides]
(7 Feb) Instructor’s notes on Pipes and Filters Architectural Pattern (Not fully covered, used mainly to illustrate approach to pattern definition) [Powerpoint]
(9-12 Feb) John Vlissides. Designing with Patterns, In Pattern Hatching: Design Patterns Applied, Addison-Wesley, 1998. [Powerpoint]
Additional references (not directly discussed in class)
(5, 14-21 Feb) Discuss Fowler’s introductory DSL example
Martin Fowler. An Introductory Example, Chapter 1, Domain-Specific Languages, Addison Wesley, 2011.
Martin Fowler. Using Domain-Specific Languages, Chapter 2, Domain-Specific Languages, Addison Wesley, 2011.
(dates on items) Discuss State Machine External DSLs based on Martin Fowler’s Secret Panel Controller (State Machine) DSLs
(2-5, 14-26 Feb) Martin Fowler. Domain Specific Languages, Addison Wesley, 2011.
Other items from the instructor’s notes
Scala versions (2009)
Scala notes
I developed the Scala versions in 2009 by referring to an in-work version of Fowler’s book on his website, so they may not follow his final book precisely. Fowler’s code is in Java, Ruby, C#, etc. I updated the Scala programs in 2018 to make sure they would compile and execute under the current Scala release.
Scala references below
(21 Feb) Graphviz and dot
language reference and examples (looked at examples in class)
graphviz
.dot
ExprLangModDep.gv
– script
– png
outputDFA01.gv
– script – pdf
outputNFA01.gv
– script – svg
outputNFA01a.gv
– script – svg
outputInfix1plus1b.gv
– script – png
output(14 Feb) Scala State Machine Semantic Model (Ch. 1, 3, 11)
(21 Feb) Scala XML-based External DSL (Ch. 1, 3, 5)
(16 Feb) Scala Custom External DSL with a Delimiter-Directed parser (Ch. 1, 3, 5, 17)
(19 Feb) Scala Custom External DSL with hand-coded Ad Hoc Recursive-Descent parser (Ch. 1, 3, 5, 21)
(21 Feb briefly) Scala Custom External DSL (using Scala parser combinator library) with embedded state machine builder (Ch. 1, 3, 5, 22)
(21 Feb briefly) Scala Custom External DSL (using Scala parser combinator library) with full AST construction (Ch. 1, 3, 5, 22)
(21 Feb briefly) Scala Static C Code Generator with Model-Aware target platform library (Ch. 1, 3, 5, 8, 52, 55)
(21 Feb) Scala Graphviz Dot Language Code Generator (added 2018) (Ch. 1, 3, 5, 8, 52)
(16 Feb) Announce homework Assignment #1 and Assignment #2
(23 Feb) Discuss Metaprogramming
Note: We return to this topic near the end of the semester with an emphasis on Python 3 metaprogramming features.
(dates on items) Discuss Fowler’s Computer Configuration Internal DSLs (Ch. 4, 35, 36, 38)
Background: Martin Fowler. Domain Specific Languages, (Addison Wesley, 2011).
Scala versions (2009)
(23 Feb) Scala semantic model (shared)
(23, 26 Feb) Scala internal DSL using Method Chaining
(26 Feb) Scala internal DSL using Nested Closures and Object Scoping
(26 Feb) 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)
Scala internal DSL using Method Chaining and Progressive Interfaces
(see dates on items) Explore Fowler’s Lair Configuration DSLs
Background on Lair DSL
Background on internal DSLs: Martin Fowler. Domain Specific Languages, (Addison Wesley, 2011). See chapters under Computer Configuration internal DSL above.
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
.
(28 Feb Python) Shared modules
Fowler’s Ruby source
Lua (2013)
Python 3 (2018)
(2 Mar Python) Internal DSL using Global Function Sequence pattern
Fowler’s Ruby
Lua (2013)
Python 3 (2018)
(7 Mar Python) Internal DSL using Class Method Function Sequence and Method Chaining patterns
Fowler’s Ruby
Lua (2013)
Python 3 (2018)
(7 Mar Python) 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
(5 Mar Python) External DSL using Parser/Builder (no corresponding example in Fowler book chapter)
Lua (2013)
Python 3 (2018)
(5 Mar) Announce homework Assignment #3
(not discussed, but an alternative context for Assignment #3) Use Sandwich DSL Case Study
Notes
Haskell version (2014, 2017) using algebraic data types
Scala version (2016) using case classes
Lua version (2013) implements slightly different problem
(9 Mar) No formal class. Work on new Assignment #3. Study the following handouts for discussion after Spring Break
(assigned first week of semester) James Coplien, Daniel Hoffman, and David Weiss. Commonality and Variability in Software Engineering, IEEE Software, Vol. 15, No. 6, November 1998.
Paper “A Little Language for Surveys: Constructing an Internal DSL in Ruby” BELOW
Conrad Barski. Building a Text Game Engine, Chapter 5, In Land of Lisp: Learn to Program in Lisp, One Game at a Time, pp. 69-84, No Starch Press, 2011.
The Common Lisp example in this chapter is similar to the classic Adventure game; the underlying data structure is a labeled digraph.
There is m<ore information about both labeled digraphs and the Wizard’s adventure game BELOW.
(12-16 Mar) Enjoy Spring Break!
(19-21, 2-6 Apr) Resume direct discussion of Domain Specific Languages notes
(21-26 Mar) Discuss commonality and variability analysis paper:
James Coplien, Daniel Hoffman, and David Weiss. Commonality and Variability in Software Engineering, IEEE Software, Vol. 15, No. 6, November 1998.
(dates below) Examine Cunningham’s Survey DSL case study, in particular the analysis and DSL design
(28 Mar; 2 Apr) Discuss paper: H. Conrad Cunningham. A Little Language for Surveys: Constructing an Internal DSL in Ruby, In Proceedings of the ACM SouthEast Conference, 6 pages, March 2008.
(2 Apr briefly) Ruby source code (2006, 2008)
(dates below) Study object-oriented software development
(for reference) Study domain analysis
(not updated) Instructor’s slides on Domain Modeling (Powerpoint), for course registration system example
Alistair Cockburn. Introduction, Chapter 1 in Writing Effective Use Cases, Addison-Wesley, 2001.
Doug Rosenberg with Kendall Scott. Domain Modeling, Chapter 2 in Use Case Driven Object Modeling with UML, Addison Wesley 1999.
Doug Rosenberg with Kendall Scott. Use Case Modeling, Chapter 3 in Use Case Driven Object Modeling with UML, Addison Wesley 1999.
(6-13 Apr) Instructor’s notes on Object-Oriented Software Development
(6-11 Apr) Instructor’s notes on Programming Paradigms – a draft “chapter” from the evolving “textbook” Exploring Languages using Interpreters and Functional Programming
(9 Apr) Discuss type systems terminology from Python 3 Metaprogramming notes
(for reference) Instructor’s notes on the Kinds of Polymorphism
(13 Apr) Distribute Assignment #4 (Final Project)
(dates below) Continue study of object-oriented software development
(16-18 Apr) Instructor’s slides on Using CRC Cards (Class-Responsibility-Collaboration) (HTML)
(handout, for reference) Kent Beck and Ward Cunningham. A Laboratory for Teaching Object-Oriented Thinking, In Proceedings of the OOPSLA’89 Conference, ACM, 1989.
(for reference) Paul Gestwicki. CRC Card Analysis (YouTube), Ball State University, February 2016.
(for reference) Ralph E. Johnson and Brian Foote. Designing Reusable Classes, Journal of Object-Oriented Programming, Vol. 1, No. 2, pages 22-35, June/July 1988.
(for reference) A simple example of the open-closed principle
(for reference) SOLID Design Principles, a look at the core SOLID principles through the lens of modularity.
(for reference) “Uncle” Bob Martin video on “SOLID Principles of Object-Oriented and Agile Design”
(for reference, slides need additional updating) Examine object-oriented programming
Understanding Inheritance, based on Timothy Budd’s Understanding Object-Oriented Programming with Java, Chapter 8: [Powerpoint]
Software Reuse, based on Timothy Budd’s Understanding Object-Oriented Programming with Java, Chapter 10: [Powerpoint]
Replacement and Refinement, loosely based on Timothy Budd’s An Introduction to Object-Oriented Programming, Third Edition, Section 16.2: [Powerpoint]
Implications of Inheritance, based on Timothy Budd’s Understanding Object-Oriented Programming with Java, Chapter 11: [Powerpoint]
Multiple Inheritance, based on Timothy Budd’s An Introduction to Object-Oriented Programming, Third Edition, Chapter 13: [Powerpoint]
Polymorphism, based on Timothy Budd’s Understanding Object-Oriented Programming with Java, Chapter 12: [Powerpoint]
Second Look at Classes, loosely based on Timothy Budd’s An Introduction to Object-Oriented Programming, Chapter 25 on Reflection and Introspection: [Powerpoint]
Luca Cardelli and Peter Wegner. On Understanding Types, Data Abstraction, and Polymorphism, ACM Computing Surveys, Vol. 17, No. 4, pp. 471-523, 1985.
(20-25 Apr) Do object-oriented analysis and design in class for a “choose your own adventure” game
Reference: Conrad Barski. Building a Text Game Engine, Chapter 5, In Land of Lisp: Learn to Program in Lisp, One Game at a Time, pp. 69-84, No Starch Press, 2011.
The Common Lisp example in this chapter is similar to the classic Adventure game; the underlying data structure is a labeled digraph.
There is more information about both labeled digraphs and the Wizard’s adventure game BELOW,
(25-30 Apr, 2-4 May) Explore Python 3 Reflexive Metaprogramming
(for reference) Background on writing Ruby DSLs
Jim Freeze. Creating DSLs with Ruby, Artima Developer, March 2006.
Jamis Buck. Writing Domain Specific Languages, The Bucklog (blog), 20 April 2006.
Rake (Ruby Make), a software management and build tool written as a Ruby internal DSL
(for reference) Discuss Fowler’s DSL Reader framework
Background:
Ruby DSLs (2006)
Ruby shared modules
Ruby direct configuration and testing of Reader
Ruby single-pass external text DSL
Ruby two-pass external XML DSL
Ruby internal DSL
(for reference) Study Parsing Expression Grammars (PEGs)
Wikipedia entry on Parsing Expression Grammar
Bryan Ford. Packrat Parsing: Simple, Powerful, Lazy, Linear Time, Functional Pearl. In Proceedings of the seventh ACM SIGPLAN International Conference on Functional Programming (ICFP ’02), ACM, pp, 36-47, 2002.
Bryan Ford. Parsing Expression Grammars: A Recognition-Based Syntactic Foundation, ACM SIGPLAN Notices, Vol. 39, No. 1, pp. 111-122, 2004. [slides]
(for reference) Arithmetic expression tree program skeletons
Background: These are expanded from the example in Notes on Scala for Java Programmers.
Scala versions (2008-16)
Scala traditional object-oriented version
Haskell version (2017)
Haskell Expression Tree Calculator case study [source]
Lua versions (2013-16)
Lua recursive function versions (2013, 2014)
Lua object-oriented versions (2013, 2016)
Lua LPEG parsers (2013)
unpack(t)
to table.unpack(t)
for Lua 5.2 and 5.3)(for reference, from 2017 CSci 450) Explore the Expression Language Syntax and Semantics (Chapter 10)
Supplemental slides:
Code in work:
(for reference, from 2017 CSci 450) Explore the Expression Language Parsing (Chapter 11)
Supplemental slides:
Code in work:
(for reference, from 2017 CSci 450) Explore the Expression Language Compilation (Chapter 12)
Code in work:
(for reference, from 2017 CSci 450) Explore the Imperative Core Language: No notes or slide yet, but the code follows
(for reference, from 2016 CSci 450) Examine modularized Expression Language 1 interpreter
Modules
Scripts to execute and test:
(for reference, from 2016 CSci 450) Imperative Core Language
(for reference, not updated) Kamin Interpreters in Lua Toolset (KILT)
Samuel N. Kamin. Programming Languages: An Interpreter-Based Approach, Addison-Wesley, 1990.
Note: I implemented the interpreter prototypes below in Lua 5.1 in 2013 for the Fall offering of CSci 658 and for a potential future offering of CSci 450. Some aspects my not work with Lua 5.2 or 5.3.
I subsequently reimplemented the first with improved modularization in Lua in 2016 and then reimplemented it again in 2017 in Haskell.
Language/Interpreter-independent modules
Kamin Chapter 1 Core language interpreter
Kamin Chapter 2 Lisp language interpreter
Kamin Chapter 4 Scheme language interpreter
(for reference) Simple, silly Employee hierarchy example
(for reference) Examine a natural number arithmetic package
This case study has implementations in five different languages (with some slight differences among the examples). So it can be used to compare implementations in different languages.
Background on Peano arithmetic
Elixir version (2015)
Scala versions (2012, 2016)
Java version (2004, 2016), simpler, no generics
(for reference) Abstract data types and modular design
Background: Abstract data types
Abstraction – draft “chapter” from evolving “textbook” Exploring Languages with Interpreters and Functional Programming (some overlap with Data Abstraction document)
Classic papers by David L. Parnas and associates:
William R. Cook. On Understanding Data Abstraction Revisited. In Proceedings of OOPSLA, October 2009. [local]
(for reference) Explore consequences of software architectural mismatch.
Paper: David Garlan, Robert Allen, and John Ockerbloom. Architectural Mismatch: Why Reuse is So Hard, IEEE Software, Vol. 12, No. 6, November 1995.
Instructor’s notes on Architectural Mismatch
(for reference) Examine the CookieJar ADT case study (in Scala)
Specification concepts and notation – from Candy Bowl ADT description
Immutable CookieJar ADT Implementation in Scala (ICookieJar
) – uses method chaining functional style with immutable objects
Mutable CookieJar ADT Implementation in Scala (CookieJar
) – uses object-oriented style with mutable state
(for reference) Examine Carrie’s Candy Bowl ADT (abstract data type) case study
(for reference) Examine the Labeled Digraph case study
Background:
Nell Dale and Henry Walker. “Directed Graphs or Digraphs,” Chapter 10, In Abstract Data Types: Specifications, Implementations, and Applications, pp. 439-469, D. C. Heath, 1996.
Conrad Barski. “Building a Text Game Engine,”, Chapter 5, In Land of Lisp: Learn to Program in Lisp, One Game at a Time, pp. 69-84, No Starch Press, 2011.
The Common Lisp example in this chapter is similar to the classic Adventure game; the underlying data structure is a labeled digraph.
Haskell solutions (2015)
Elixir solutions (2015)
Scala solutions (2016)
Using the Elixir Digraph ADT module to build the Wizard’s Adventure game (2015)
Wizard’s Adventure game, Version 1, adapted from Chapter 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.
Wizard’s Adventure game, Version 2, that uses a higher order function to generate game actions and improved handling of the game state.
(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, Version 1a, 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, Version 1b, is an eager version above with an attempt at memoization of functions neighbors
and game_tree
using the Elixir Agent
modules.
Dice of Doom, Version 2a, 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.
(for reference) Explore Systematic generalization.
Hans A. Schmid. Systematic Framework Design by Generalization, Communications of the ACM, Vol. 40, No. 10, pp. 48-51, October 1997.
Hans A. Schmid. Creating Applications From Components: A Manufacturing Framework Design, IEEE Software, Vol. 13, No. 6, November 1997.
Hans A. Schmid. Framework Design by Systematic Generalization, Chapter 15 in M. E. Fayad and R. E. Johnson, editors, Domain-Specific Application Frameworks, pp. 353-378, Wiley, 2000.
Hans A. Schmid. OSEFA: Framework for Manufacturing, Chapter 4 in M. E. Fayad, D. C. Schmidt, and R. E. Johnson, editors, Building Application Frameworks: Object-Oriented Foundations of Framework Design, pp. 43-65, Wiley, 1999.
(for reference) Mark Ardis, Nigel Daley, Daniel Hoffman, Harvey Siy, and David Weiss. Software Product Lines: A Case Study, Software Practice and Experience, Vol. 30, No. 7, pp. 825-847, 2000.
(for reference) Frameworks, based on Timothy Budd’s An Introduction to Object-Oriented Programming, Third Edition, Chapter 21.
Simple Sorting Framework in Scala
Ice Cream Store discrete event simulation
(for reference) Scala Divide-and-Conquer Framework, similar to the Java framework in the 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. [manuscript]
Note: The above paper was not discussed in class, but the Scala versions of the Divide-and-Conquer (immediately below) and Binary Tree Traversal (farther down on this page) frameworks were discussed.
(for reference) Binary Tree Visitor Scala Framework
Background: 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.
[manuscript]
Scala versions (2008, 2010)
Straightforward translation of the non-generic Java program to Scala
Generic implementation of BinTree framework in Scala.
(for reference) Study the Movable and Named Objects case study (in Lua but based on a Haskell case study by Thompson)
Purpose: The Named and Movable Objects case study explores use of inheritance hierarchies and multiple inheritance in Lua. I also extracted a “class support module” from the initial version of this code; this module was used in later case studies (e.g., Lair Configuration DSL).
The “makeClass” function dynamically creates a “class” that has zero or more superclasses. It creates the class prototype object with an appropriate constructor/initialization function, appropriate default definitions of instance methods, and the needed settings of metaclasses and the __index
metamethod to support the inheritance hierarchy.
Background reading on object-oriented programming languages: Object-oriented subsection of the Fundamental Concepts of Programming Languages notes
Background reading on case study: Section 14.6 of Simon Thompson. Haskell: The Craft of Functional Programming, Third Edition, Addison Wesley, 2011
Note: We should readdress the design and implementation of this case study and the class support module. The latter may be too complex for our purposes in this course.
First Lua version (movable.lua)
Modularized Lua version with improved class support:
Other older versions:<
(for reference) Study the prototype-based programming example
Comments: Lua is essentially a prototype-based programming language. A Lua table has its own state, a unique identity, and an independent lifecyle. By assigning function closures to identifier-style keys, a table can also have its own operations. The method-call syntax enables these operations to refer to its associated table conveniently.
The Lua metatable and metamethod features enable a table to delegate some of its work conveniently to other tables. In particular, the __index
metamethod enables accesses to data fields or operations not defined in one table to other tables.
The previous “object-oriented” Arithmetic Expression Tree and Movable & Named Objects examples use Lua’s prototype-based features to implement classes and inheritance structures.
This module uses those features in a more straightforward prototype-based approach–by creating a “copy” of the prototype object. It provides two constructor functions, set up to use the method-call syntax.
Constructor method Prototype:new
creates a new object as a shallow copy of the table parameter mixin
with other references delegated to object self
. A call Prototype:new
creates a basic object that delegates to object Prototype
. If obj
has been created by this new
method, then a call of obj:new
creates a new object that delegates to obj
rather than Prototype
. (This is different from the way Lua classes are implemented.)
Constructor method Prototype:clone
creates a new object that is a shallow copy of object self
and then mixes in the fields and methods from mixin
. It delegates accesses to any undefined fields to whatever object self
does.
Concepts: Prototype object, delegation, shallow copy, mixin
(for reference) Examine Rational Arithmetic case study (data abstraction)
Note: I have rewritten this 2016 case study to use Haskell and incorporated it into the draft Abstraction “chapter” of Exploring Languages with Interpreters and Functional Programming
Example motivated by sections 2.1.1 and 2.1.2 from: Harold Abelson and Gerald J. Sussman with Julie Sussman. Structure and Interpretation of Computer Programs, Second Edition, MIT Press, 1996
Concepts: designing modules with multiple implementations, data abstraction barrier (“building the wall”), canonical forms, using Lua modules, using higher order functions, using closures/thunks to encapsulate data
Rational arithmetic module – outer layer implementation of Rational Arithmetic abstraction
Rational number data representation using two-element arrays – primitive layer implementation 1
[module] [test script]
Rational number data representation using array but deferring GCD – – primitive layer implementation 2
[module] [test script]
Rational number data representation using closures – primitive layer implementation 3
[module] [test script]
(for reference) Examine the complex number arithmetic modules in Lua
Modules are repeated in each package in which they are used
Background reading: Structure and Interpretation of Computer Programs, Second Edition, MIT Press, 1996, Section 2.4
Rectangular coordinates modules:
[arithmetic] [rectangular representation] [utilities] [test driver]
Polar coordinates modules:
[arithmetic] [polar representation] [utilities] [test driver]
Tagged data modules: [arithmetic] [data tagging] [utilities] [test driver]
Data-directed programming modules:
[arithmetic] [rectangular representation] [polar representation] [data tagging] [utilities] [test driver]
Object-oriented modules:
[arithmetic] [utilities] [test driver]
(for reference) Lua list module case study (Cell List)
Purpose: This Lua case study illustrates (i) functional programming principles, (ii) design and implementation methods for abstract data types and information hiding modules, and, (iii) Lua programming techniques (linked lists, stateless iterators, closures, metatables, etc.)
Background reading on Lua: Chapter 11 on data structures (pages 107-116) and Chapter 15 on modules (pages 151-161) of Programming in Lua (PiL), Third Edition
Caveats: (1) These modules (from 2013-14) internally layer the operations into primitive and non-primitive operations, but they do not separate the primitive operations into its own module. That can be done similarly to the Rational Arithmetic case study. (2) In the future, I plan to construct a more efficient implementation that uses array-style tables. The table-based versions likely also need to use weak tables to avoid memory leaks.
Cell-based list module:
[module source] [test driver]
Closure-and-table-based list module variant:
[module source] [test driver]
Function-based cell list module variant:
[module source] [test driver]
Lazy list module variant using C preprocessor (cpp -P):
[module source] [source after cpp]
[test driver] [driver after cpp] [sh script]
Lazy list module variant using Lua Macro 2.5:
[macro definitions] [module macro source] [source after luam -o]
[macro test driver] [driver after luam -o] [sh script]
(for reference) Examine functions adapted from SICP
Background reading: Chapter 1 of the classic textbook SICP – Harold Abelson and Gerald J. Sussman with Julie Sussman. Structure and Interpretation of Computer Programs, Second Edition, MIT Press, 1996:
[book site at MIT Press] [HTML] [SICP ebook site
First-order functions in Scala
Higher-order functions in Scala
Lua versions
(for reference) Examine Square Root case study (stepwise refinement)
Concepts: TBD (examine the notes to see what was covered)
Example motivated by sections 1.1.7 and 1.1.8 from: Harold Abelson and Gerald J. Sussman with Julie Sussman. Structure and Interpretation of Computer Programs, Second Edition, MIT Press, 1996
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.
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.