BAM Weblog

Tool Subsumption and Silver Bullets

Brian McKenna — 2017-10-09

I'm going to write some posts about the phrase "there's no such thing as a silver bullet" and why I think it's not a very useful thing to say. I'll write a post about the original paper but first I want to write about an interpretation I've seen:

Everything has trade-offs.

I can go through things that I use and come up with trade-offs:

  • Space vs time
  • Emacs vs Vim
  • Git vs Mercurial
  • JSON vs YAML

Sometimes I need to carefully consider each option and choose. Sometimes I can flip a coin because the differences are insignificant to what I'm solving.

But I think some tools don't have trade-offs.

Functional programming is programming with functions and functions have the property of referential transparency. When we see an expression in a program, we can replace the expression with a binding or vice versa.

An example is that:

var x = 1;
x + x

Has the same result as:

1 + 1

And vice versa.

A counter example is:

var x = prompt("Name:");
x + x

Does not have the same result as:

prompt("Name:") + prompt("Name:")

We gain some useful things when we have referential transparency. We can thoughtlessly refactor, the best kind of refactoring. Equational reasoning with our programs is substitution. Code reuse, testing and optimised compilation are easier.

And what do we lose? When I started doing functional programming, I assumed there must be some trade-offs, because trade-offs in programming are so common.

At first I rationalised this by saying "well sometimes it's awkward to use immutable data" - that must be the problem! Much later I learned tools which make it way less awkward than the alternatives.

Then I thought "well we can't do fast mutation" - performance must be bad if we restrict ourselves to referential transparency. Much later I learned that there are referentially transparent tools for fast mutation.

After iterating a few times I have arrived at: referential transparency is not a trade-off. I'm fairly confident that the only reasons referential transparency isn't used everywhere is:

  1. A lack of awareness
  2. Inaccessibility of resources for learning it

I spend 2 hours a week teaching the Data61 Functional Programming Course at work in an effort to teach referential transparency in my local environment. Please consider helping the cause!

I've come to a similar conclusion on dynamic typing. It is exactly unityping and my experience is that allowing programs with more than one type has no inherent disadvantage. Not a trade-off.

Some tools subsume others. Functional and typed programming subsume all alternatives. When "there's no such thing as a silver bullet" is used to mean something like "everything has trade-offs" then it might be ignoring these cases. They're not a silver bullet to solving all of your problems, but they are a silver bullet for the problems they solve.

Please enable JavaScript to view the comments powered by Disqus.