Techniques for Understanding Code

July 29, 2020

Building an understanding of code is one of the main tasks in software development. Whenever we want to answer a question about code—what is this doing? why doesn’t it work? how can we make it faster?—this is what we’re doing. I have found it valuable to consciously surface the strategy I use to answer these questions, and have categorized my approaches into three groups:

  1. reasoning about code;
  2. inspecting running code; and
  3. referring to an authoritative source.

In this post I will discuss these different ways of understanding code and their benefits and drawbacks.

Read more


Scoring Ten-Pin Bowling with Algebraic Data and Finite State Machines

July 18, 2020

I recently led a training session where we implemented the rules for scoring ten-pin bowling in Scala. It makes for a good case study. It’s small enough that you can pick up the rules in a few minutes, but the dependencies between frames makes calculating the score non-trivial. I decided to implement my own solution which turned into an interesting exercise in algebraic data and finite state machines. In this post I’ll describe my implementation and my process for developing it.

For my implementation I solely focused on scoring the game. I didn’t implement any parsing code, as that part of the problem didn’t interest me.

Read more


What Functional Programming Is, What it Isn't, and Why it Matters

July 5, 2020

The programming world is moving towards functional programming (FP). More developers are using languages with an explicit bias towards FP, such as Scala and Haskell, while object-oriented (OO) languages and their communities adopt FP features and practices. (A striking example of the latter is the rise of Typescript and React in the Javascript community.) So what is FP and what does it mean to write code in a functional style? It’s common to view functional programming as a collection of language features, such as first class functions, or to define it as a programming style using immutable data and pure functions. (Pure functions always return the same output given the same input.) This was my view when I started down the FP route, but I now believe the true goals of FP are enabling local reasoning and composition. Language features and programming style are in service of these goals. In this post I attempt to explain the meaning and value of local reasoning and composition.

Read more


Scala with Cats 2

March 16, 2020

Scala with Cats 2 is underway, with a fancy new website. Go and join the mailing list linked from the site if you want to keep up with the latest developments.

Read more


A Quick Sketch of Research on Pedagogy and Curriculum for Teaching Programming

March 12, 2020

In preparation for a talk at NEScala I wrote this quick survey on the research on curriculum and pedagogy for teaching programming (curriculum means what we teach, and pedagogy is how we teach it). My goals are:

  • give a framework for thinking about curriculum and pedagogy;
  • give some specific tips for teaching programming;
  • point out where I believe more research is needed.

My survey is based on the published literature, but it’s not a comprehensive document. I’m not an academic and I don’t have the time (sadly) to read all the relevant literature. However I’ve linked to papers I found interesting or important so you can explore further if something grabs your interest. There is a lot of interesting research out there and the tiny bit I’ve read has made my teaching much better.

Read more