How Readable? "This" Readable!
December 13, 2019
In October 2019 we went live with the second version of our code readability experiment on howreadable.com. Since the experiment closed in November, I’ve been crunching the numbers - with the help of the inimitable Oskar Holm (@ohdatascience) - and the results are in!
We can finally, somewhat, answer the question “How readable?“.
By comparing the results for pairs of snippets that differed in their use of various coding constructs, we were able to get statistically significant results that point to an objective measure for the readability of the constructs themselves. Our headline findings were as follows:
- Operator precedence: In expressions that are dependent on operator precedence, adding brackets increases both reading speed and accuracy.
- Chaining methods: Chained methods are faster to read, but adding intermediate variables leads to greater accuracy.
- Order of if statements: If statements are faster to read when the positive case is presented first.
- Extracting functions: There is a reading speed overhead when extracting functions.
- Pure functions: There is a reading speed overhead when writing pure functions.
- Boolean algebra: Expanded boolean expressions are faster to read than simplified ones.
This has been a very rewarding but exhausting experience. I’d like to thank everyone who participated in the experiment and especially those who gave their time to help put it together. I don’t know what the future holds for this project, but I’m very proud of the progress we have made so far.
A will post soon in more detail about the experience. In the meantime, have a safe and prosperous holiday season and new year!
The thoughts of Daniel van Berzon, a Brighton-based front-end developer who is a luddite at heart and wishes everything were simpler. @dvberzon