Foreword

“You know, people think mathematics is complicated. Mathematics is the simple bit. It’s the stuff we can understand. It’s cats that are complicated.”

— John Horton Conway

Type TRUE + TRUE into an R console. You get 2. Why? R is not doing arithmetic on the word “true.” It converts a logical value to the number 1, twice, and adds. That conversion follows a rule, and the rule traces back to a design decision that predates R by sixty years and programming itself by two decades. Where did it come from?

In 1936, a logician at Princeton wrote booleans as functions that choose: TRUE takes two arguments and returns the first, FALSE returns the second. His system had no boolean type and no if; a function that picks did the work of both. His name was Alonzo Church, and the notation those booleans were written in, the lambda calculus, is the ancestor of R’s function.

It took four languages to get there. John McCarthy borrowed Church’s notation for Lisp in 1958. Two researchers at MIT, trying to understand a rival theory of computation, stripped Lisp down to Scheme in 1975 and settled where a function looks for the names it uses. At Bell Labs in 1976, John Chambers built S. A statistician could now type an expression and see the result without writing a Fortran program first. And in the 1990s, two statisticians in Auckland reimplemented S, keeping its syntax and giving it Scheme’s rule for looking up names. Their names were Ross Ihaka and Robert Gentleman, and the language they wrote, given away free, is the one running on your laptop right now.

The 2 in your console is the end of that chain, and so is nearly everything else you type into R.