Adages about the Practical OCaml Programmer

  1. The practical OCaml programmer first seeks to understand what is going on. They write unit tests to concretize their understanding.
  1. The practical OCaml programmer then seeks to understand how things work. And then they write a program and run it through its unit tests.
  1. The Practical OCaml programmer writes unit tests methodically and makes sure that they include corner cases. For each new implementation, they verify that the unit tests provide code coverage.
  1. The practical OCaml programmer uses structural recursion for data that were constructed inductively. And so when faced with a structurally recursive computation, they first specify it inductively.
  1. The practical OCaml programmer heeds the reverse order of accumulation in tail-recursive programs.
  1. The practical OCaml programmer is not afraid of anonymous functions.
  1. The practical OCaml programmer shuns gratuitous variations because uniformity in the form (the “how”) fosters unity both in the content (the “what”) and in the function (the “why”).
  1. The measure of the practical OCaml programmer’s understanding is the clarity of their discourse, for
    • a commented code listing does not a report make, and
    • paraphrasing how a program works does not explain what this program does.
  1. The practical OCaml programmer learned that the road to simplicity is full of bumps.
  1. The practical OCaml programmer doesn’t always start from nothing. They try to start from what they have already done.
  1. The practical OCaml programmer interacts with the OCaml toplevel loop in a minimal way. They use the file system for long-term storage. (This way, they can start from what they have already done.)
  1. The practical OCaml programmer chooses meaningful names and uses auto-completion. They concur with Albert Camus that naming something poorly adds to the world’s unhappiness. (Also, more prosaically, life is too short for misspellings.)
  1. The practical OCaml programmer rejoices at their mistakes as an opportunity to learn, since to learn from our mistakes, we first need to make mistakes.
  1. When the practical OCaml programmer does not find an error somewhere (e.g., in their program), they look somewhere else (e.g., in their unit tests).
  1. When reporting an error, the Practical OCaml programmer puts their recipient in position to reproduce this error. In the spirit of Magritte, they send their code, not a picture of their code.
  1. The practical OCaml programmer is aware that as pointed out by Edsger Dijkstra, incomplete testing only proves the presence of errors, not their absence, since it does not enumerate all possible cases, even when it provides test coverage. They further know that since complete testing enumerates all possible cases, it does prove the absence of errors.
  1. The practical OCaml programmer lives by Don Knuth‘s tenet that early optimization is the source of a lot of evil, and by Kent Dybvig‘s patient observation that often, nothing needs to be made efficient if it is done right in the first place.
  1. The Practical OCaml Programmer authored the following theorem: if one’s program hasn’t been tested, it doesn’t work.

Version

Added the adage about the Practical OCaml Programmer’s theorem [21 Apr 2023]

Added two new adages (one about writing unit tests methodically and another about reporting errors) [14 Apr 2023]

Created [10 Jan 2023]

Table Of Contents

Previous topic

Food for thought to take home

Next topic

More Sayings about the Practical OCaml Programmer