Recently I saw a talk about Pico-8, a really restricted game maker platform, it makes me think about what can be learned by being restrictive.

Some time ago I made some experiments, CRC cards from Kent Beck and Ward Cunningham made me try to program without public getters and setters. I learned a lot from it, especially about “double dispatching”, and how it is useful but we usually forget about it (shame, shame…).

It shifts your mind from “what should I use” to “how do I use” …

Functional programming made me experiment to program only with immutable objects. That’s a very interesting restriction I advocate anyone to try. Essentially, it teaches me when I can safely use mutability, and I can say it has its place.

Also, learning Racket made me try to program without loops at all. After a while I learned to use recursion and loops very effectively.

The main point here is that constraints make you keep your focus where it matters, stripping useless details and superfluous choices. It shifts your mind from “what should I use” to “how do I use”, a far better question to learn.

There is a legend about Demosthenes, the famous greek orator, about being a better speaker using pebbles in the mouth.

Here is my list of “pebbles” :)

  • Immutable classes and collections only, no mutable state anywhere.
  • No public getters and setters, no direct access to struct fields outside of module/file/something local.
  • No loops, only recursion. Only tail call recursion.
  • Paralellism by piping things to different processes, no shared state (immutable or not).
  • No classes, just structures.
  • No ifs or cases, just pattern matching/multimethods/method overloading/subclasses (goes well with the previous one).
  • Everything as a fluent interface/method chaining.
  • …?

Go practice!

Written by

Just a common guy

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store