Minimalism in Programming

The topic of minimalism is pretty large, so this topic may span multiple posts.

Recently, I’ve been really caught up in the idea of minimalism, and of simplicity in general. I’m subscribed to a guy named Matt D’Avella on Youtube. His ideas on creativity and his simple, straightforward style got me really excited to dig deeper into the idea of minimalism. Then I found out he directed a Netflix documentary called The Minimalists. Their doc really got me thinking about not only the material items I keep in my life, but the mindset I have as well. In order to be deliberate, sometimes we must take a step back and examine our previous assumptions. A mindset of minimalism will allow us to do just that.

Hello World is misleading

The simplest programs usually consist of “Hello World”. Here’s that program in three separate languages (Javascript, Ruby, Java respectively):

Unfortunately, these programs are misleading. Often, you’ll be looking to solve a bigger problem, and Hello World ain’t gonna cut it. Depending on your goals, the problem can get out of hand VERY quickly.

When the problems become larger, so does their solution space. Often, you’ll need to integrate libraries from external developers, weigh the pros and cons of similar technologies, and write feature after feature while stomping bug after bug. Code becomes an entangled mess, with different parts of the code base inexplicably relying on other parts, etc.

In the production world, the solution to this problem is often microservices. Microservices give us a smaller, deployable solutions to subproblems. This allows for developers to focus on smaller parts of the pipeline. This design pattern works well for certain types of applications but it doesn’t work for all applications.

When we approach writing code in a minimalist mindset, we strive to have clean code. Let’s take a tip from literary minimalism.

Literary minimalism is defined as:

Literary minimalism is characterized by an economy with words and a focus on surface description. Minimalist writers eschew adverbs and prefer allowing context to dictate meaning. Readers are expected to take an active role in creating the story, to “choose sides” based on oblique hints and innuendo, rather than react to directions from the writer.

The important bit is an economy with words and a focus on surface description. Following similar rules in our code, we should strive to be as terse as possible. We should find solutions that are simple and thorough.

Occam’s razor

Occam’s razor is a principle that states that the simplest solution tends to be the correct one.

As put in this amazing video from 1979, computers are meant to eliminate tedium in life. If the problem you’re solving requires a computer, chances are that you’re looking to solve a tedious problem. We can use this to our advantage! Instead of over engineering solutions, we should all strive to solve problems with as little coding kung-fu as possible, favoring readable and understandable over elegant.

Here are a few tips that are language agnostic, to help you code in a more minimalistic fashion.

  1. Avoid comments. Comments equate to clutter generally, as they become less useful over time
  2. Avoid side effects. Easier said than done in the scope of web programming especially, but libraries like Redux can help us centralize our side effects.
  3. Ask yourself if your solution is over engineered! A good way to tell if the solution is too complicated is by using rubber ducking
  4. Read Clean Code