Hi, I'm Noel Welsh. I write software and books, and work on other projects in the software space.

Latest Writing

  • A Case Study in Incrementally Improving Code
    09 October 2021

    In this article I'm going to go through the process of improving some code. I'm mentoring a new developer who is applying for their first job. They were asked to complete some tasks on Codility as the first step of the interview process. To get used to the platform they did the first example task, and I advised them on some changes. I'm writing up here the progression from their code to (what I think is) better code. (Since this is the example task, not a task used to assess applicants, I think this is ok to publically post.)

    Continue reading

  • Enough: A Review
    14 March 2021

    "I was three when the elephants ate the house next door," opens a paragraph on page 108 of my copy of Enough, the new book by Dr Cassandra Coburn. It encapsulates a lot of what I like about this book: it deals with important issues but it's also a lot of fun.

    Continue reading

  • Techniques for Understanding Code
    29 July 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.

    Continue reading

  • Scoring Ten-Pin Bowling with Algebraic Data and Finite State Machines
    18 July 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.

    Continue reading

  • What Functional Programming Is, What it Isn't, and Why it Matters
    05 July 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.

    Continue reading