12 February 2018 (after class)
Copyright (C) 2018, H. Conrad Cunningham
Professor of Computer and Information Science
University of Mississippi
211 Weir Hall
P.O. Box 1848
University, MS 38677
(662) 915-5358
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 February 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 and related issues
Jon Bentley. Programming Pearls: Little Languages, Communications of the ACM, Vol. 29, No. 8, pp. 711-721, August 1986.
Instructor’s note on pic
: On my iMac, I installed (using Homebrew) the groff
package, which includes the GNU pic
implementation. (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 little graph language dot
and the GraphViz package (not discussed)
Additional references for the little languages lex
, yacc
, make
, and chem
(not discussed)
(26, 29 Jan) Discuss “No Silver Bullet” paper and related issues
Frederick P. Brooks. No Silver Bullet: Essence and Accident in Software Engineering, IEEE Computer, Vol. 20, No. 4, 10-19, 1987.
(29, 31 Jan) Discuss “Language-Oriented Programming” paper
M. P. Ward. Language-Oriented Programming, Software–Concepts and Tools, Vol. 15, No. 4, pp. 147-161, 1994. [local]
Other references from paper (not discussed)
(31 Jan; 2, 5, 14 Feb) Discuss Domain Specific Languages notes and related issues
References used in notes (not discussed directly)
(5, 14 Feb) Discuss Fowler’s introductory DSL example
Martin Fowler. An Introductory Example, Chapter 1, Domain-Specific Languages, Addison Wesley, 2011.
Survey Design Patterns (see dates on items)
(5, 7 Feb) Introduction to Patterns [HTML slides]
(7 Feb) 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. [slides]
Additional references from instructor’s notes (not directly disucssed in class)
Additional references (mentioned in class, but not discussed in depth)
Reference material possibly useful at this point (may discuss explicitly later if needed)
Python 3
Scala
Object-oriented software development
(2, 5, 14 Feb) Discuss State Machine DSLs based on Martin Fowler’s Secret Panel Controller (State Machine) DSLs
Caveat: 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 Scala, Ruby, C#, etc. I updated the Scala programs in 2018 to make sure they would compile under the current Scala.
Background: Martin Fowler. Domain Specific Languages, Addison Wesley, 2011.
Fowler introduces the Secret Panel Controller (State Machine) case study in Chapter 1 (An introductory example) It is an example running through several of the 57 chapters of the book.
Martin Fowler’s List of DSL Patterns from Domain Specific Languages, Addison Wesley, 2011
Scala versions (2009)
Scala State Machine Semantic Model (Ch. 1, 3, 11)
Scala XML-based External DSL (Ch. 1, 3, 5)
Scala Custom External DSL with a Delimiter-Directed parser (Ch. 1, 3, 5, 17)
Scala Custom External DSL with hand-coded Ad Hoc Recursive-Descent parser (Ch. 1, 3, 5, 21)
Scala Custom External DSL (using Scala parser combinator library) with embedded state machine builder (Ch. 1, 3, 5, 22)
Scala Custom External DSL (using Scala parser combinator library) with full AST construction (Ch. 1, 3, 5, 22)
Scala Static C Code Generator with Model-Aware target platform library (Ch. 1, 3, 5, 8, 52, 55)
(5, 14 Feb) Discuss Fowler’s Computer Configuration Internal DSLs (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).
Scala versions (2009)
Scala internal DSL using Method Chaining and Progressive Interfaces
(assigned, not discussed yet, TBD) Discuss Coplien’s SCV paper
James Coplien, Daniel Hoffman, and David Weiss. Commonality and Variability in Software Engineering, IEEE Software, Vol. 15, No. 6, November 1998.
(TBD) Domain Modeling slides, for course registration system example.
(TBD) 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.
(TBD) S. Thibault, R. Marlet, and C. Consel. Domain-Specific Languages: From Design to Implementation–Application to Video Device Drivers Generation. IEEE Transactions on Software Engineering, 25(3):363–377, May/June 1999.
(TBD) Ralph E. Johnson and Brian Foote. Designing Reusable Classes, Journal of Object-Oriented Programming, Vol. 1, No. 2, pages 22-35, June/July 1988.
(TBD) Develop a Survey DSL
Background: 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.
Ruby source code (2006, 2008)
(reference material on Lua, from Fall 2016 CSci 450 notes)
Reference: Roberto Ierusalimshcy. Programming in Lua, Fourth Edition, Lua.org, Rio de Janiero, Brazil, 2016. The First Edition of this book is available online at https://www.lua.org/pil/contents.html; it covers Lua 5.0.
Background: The slides below are adapted, in part, from Programming in Lua, Slides for Course by Fabio Mascarenhas from the Federal University of Rio de Janeiro, Brazil. He taught a course, which used Lua 5.2, at Nankai University, P. R. China, in July 2013.
Introduction to Lua slides based, in part, on Mascarenhas slide sets 0-5
Advanced Lua Functions slides based, in part, on Mascarenhas slide set 6
Modules in Lua slides based, in part, on Mascarenhas slide set 9
Lua Metatables slides based, in part, on Mascarenhas slide set 10
Lua Objects slides based, in part, on Mascarenhas slide set 11
(TBD) Discuss Fowler’s Lair Configuration DSL
Caveat: Some of these DSL programs may depend upon features from Lua 5.1 that were changed in Lua 5.2 and 5.3.Background:
Lua versions (2013)
Lua shared modules
Lua internal DSLs
Using Global Function Sequence pattern
builder module (builder08.lua) – dsl script (rules08.lua) – test driver (test08.lua)
Using Class Method Function Sequence and Method Chaining patterns
builder module (builder11.lua) – dsl script (rules11.lua)
Using Expression Builder and Method Chaining patterns
builder module (builder14.lua) – dsl script (rules14.lua) – test driver (test14.lua)
Using Nested Closures pattern
builder module (builder03.lua) – dsl script (rules03.lua) – test driver (test03.lua)
Using Expression Builder, Object Scoping, and Method Chaining patterns
builder module (builder17.lua) – dsl script (rules17.lua) – test driver (test17.lua)
Using Literal Collection pattern
builder module (builder22.lua) – dsl script (rules22.lua) – test driver (test22.lua)
Lua external DSLs
(TBD) 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
(TBD) Sandwich DSL Case Study
Lua version (simpler, 2013)
(TBD) Abstract data types and modular design
Background: Abstract data types
Nell Dale and Henry Walker. Abstract specification techniques, Chapter 1, In Abstract Data Types: Specifications, Implementations, and Applications, pp. 1-34,D. C. Heath, 1996.
H. Conrad Cunningham, Yi Liu, and Jingyi Wang. Designing a flexible framework for a table abstraction, Chapter 13 in Y. Chan, J. Talburt, and T. Talley, editors, Data Engineering: Mining, Information, and Intelligence, pp. 279-314, Springer, 2010.
[manuscript] [slides]
(OO reference materia, repeated from abovel) Object-Oriented Software Development
(Programming paradigms reference material, repeated from above) Programming Paradigms
William R. Cook. On understanding data abstraction revisited. In Proceedings of OOPSLA, October 2009.
[local]
K. H. Britton, R. A. Parker, and D. L. Parnas. A procedure for designing abstract interfaces for device interface modules, In Proceedings of the 5th International Conference on Software Engineering, pp. 195-204, March 1981.
D. L. Parnas. On the criteria to be used in decomposing systems into modules, Communications of the ACM, Vol. 15, No. 12, pp. 1053-1058, 1972.
D. L. Parnas. On the design and development of program families, IEEE Transactions on Software Engineering, Vol. SE-2, No. 1, pp. 1-9, March 1976.
D. L. Parnas. Designing software for ease of extension and contraction, IEEE Transactions on Software Engineering, Vol. SE-5, No. 1, pp. 128-138, March 1979.
D. L. Parnas, P. C. Clements, and D. M. Weiss. The modular structure of complex systems, IEEE Transactions on Software Engineering, Vol. SE-11, No. 3, pp. 259-266, March 1985.
(TBD) 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
(TBD) Examine Carrie’s Candy Bowl ADT (abstract data type) case study
(TBD) 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.
(TBD) Parsing Expression Grammars
Wikipedia entry on Parsing Expression Grammar
Bryan Ford. Parsing Expression Grammars: A recognition-based syntactic foundation.
[slides]
(TBD) Doug Rosenberg with Kendall Scott. “Domain Modeling,” Chapter 2 in Use Case Driven Object Modeling with UML, Addison Wesley 1999.
(TBD) Doug Rosenberg with Kendall Scott. “Use Case Modeling,” Chapter 3 in Use Case Driven Object Modeling with UML, Addison Wesley 1999.
(TBD) Reference: Alistair Cockburn. “Introduction,” Chapter 1 in Writing Effective Use Cases, Addison-Wesley, 2001.
(TBD) Understanding Inheritance, based on Timothy Budd’s Understanding Object-Oriented Programming with Java, Chapter 8:
[slides]
(TBD) Simple, silly Employee hierarchy example
(TBD) Examine a natural number arithmetic package
This case study has implementations in four different languages (with some slight differences among the examples). So it can be used to compare implementations in different languages.
Background on Peano arithmetic
Background on software design patterns
Elixir version (2015)
Scala versions (2012, 2016)
Java version (2004, 2016), simpler, no generics
(TBD) Software Reuse, based on Timothy Budd’s Understanding Object-Oriented Programming with Java, Chapter 10:
]slides]
(TBD) Replacement and Refinement, loosely based on Timothy Budd’s An Introduction to Object-Oriented Programming, Third Edition, Section 16.2:
[slides]
(TBD) Implications of Inheritance, based on Timothy Budd’s Understanding Object-Oriented Programming with Java, Chapter 11:
[slides]
(TBD) Multiple Inheritance, based on Timothy Budd’s An Introduction to Object-Oriented Programming, Third Edition, Chapter 13:
[slides]
(TBD) Polymorphism, based on Timothy Budd’s Understanding Object-Oriented Programming with Java, Chapter 12:
[slides]
(TBD) Second Look at Classes, loosely based on Timothy Budd’s An Introduction to Object-Oriented Programming, Chapter 25 on Reflection and Introspection:
[slides]
(TBD) 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
(TBD) 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.
(TBD) Introduction to Design Patterns, Chapter 6 in, Eric Braude, Software Design: From Programming to Architecture, Wiley, 2004.
(TBD) [Siemens book] Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, and Michael Stal. Pattern-Oriented Software Architecture: A System of Patterns, Wiley, 1996.
(TBD) (“Gang of Four” (GoF) book) Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software, Addison Wesley, 1995.
(TBD) Mark Grand. Patterns in Java: A Catalog of Reusable Design Patterns Illustrated with UML, Volume 1, Wiley, 1998.
Template Method Design Pattern: [slides]
Reference: Gof, “Template Method,” pp. 325-329.
Reference: Grand, “Template Method,” pp. 377-384.
Strategy Design Pattern: [slides]
Reference: GoF, “Strategy,” pp. 315-323.
Reference: Grand, “Strategy,” pp. 371-376.
Factory Method Design Pattern: [slides]
Reference: GoF, “Factory Method,” pp. 107-116.
(TBD) 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]
Additional pattern references
GoF, “Composite,” pages 163-174.
Grand, “Composite,” pages 165-174.
GoF, “Visitor,” pages 331-344.
Grand, “Visitor,” pages 385-395.
Scala versions (2008, 2010)
Straightforward translation of the non-generic Java program to Scala
Generic implementation of BinTree framework in Scala.
(TBD) Use the Digraph ADT module to build the Wizard’s Adventure game
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.
(TBD) 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.
(TBD) Arithmetic expression tree program skeletons
Background: These are expanded from the example in Notes on Scala for Java Programmers.
Lua versions (2013-16)
Lua recursive function versions (2013, 2014)
Lua object-oriented versions (2013, 2016)
Lua LPEG parsers (2013)
Scala versions (2008-16)
(TBD) 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:
(TBD) Examine the complex number arithmetic modules in Lua
Modules are repeated in each package in which they are used
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]
(TBD) Kamin Interpreters in Lua Toolset (KILT)
Language/Interpreter-independent modules:
[REPL Module (repl.lua)]
[Environment Module (environment.lua)]
[Function Table Module (funtab.lua)]
[Utilities Module (utilities.lua)]
[Opcodes Factory Module (opcodes.lua)]
[Values Factory Module (values.lua)]
[Parser Factory Module (parser.lua)]
[Evaluator Factory Module (evaluator.lua)]
Kamin Chapter 1 Core language interpreter:
[Core Interpreter (Core.lua)]
[Core Opcodes (opcodes_core.lua)]
[Core Values Module (values_core.lua)]
[Core Parser Module (parser_core.lua)]
[Core Evaluator Module (evaluator_core.lua)
Kamin Chapter 2 Lisp language interpreter:
[Lisp Interpreter (Lisp.lua)]
[Lisp Opcodes (opcodes_lisp.lua)]
[Lisp Values Module (values_lisp.lua)]
[Lisp Parser Module (parser_lisp.lua)]
[Lisp Evaluator Module (evaluator_lisp.lua)
[A few Lisp examples]
Kamin Chapter 4 Scheme language interpreter:
[Scheme Interpreter (Scheme.lua)]
[Scheme Opcodes (opcodes_scheme.lua)]
[Scheme Values Module (values_scheme.lua)]
[Scheme Parser Module (parser_scheme.lua)]
[Scheme Evaluator Module (evaluator_scheme.lua)
[A few Scheme examples]
(TBD) 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]
(TBD) 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
Jim Weirich. “Rake Tutorial,” “Rake User Guide,” and “Rake by Example,” 2005.
(Basic ideas discussed.) [Ruby Rake web site]
Jim Freeze. Creating DSLs with Ruby, Artima Developer, http://www.artima.com/rubycs/articles/ruby\_as\_dsl.html, March 2006.
[Artima website] [[local printer-friendly copy](http://www.cs.olemiss.edu/~hcc/engr692ruby/notes/ruby\_as\_dslP.html)]
Jamis Buck. Writing Domain Specific Languages, the { buckblogs :here }
, 20 April 2006.
[blog entry]