Book Review: The Programmer's Brain - What every programmer needs to know about cognition by Felienne Hermans
There are some books which make you feel smarter just by having them on your shelf. This is one of them! I would consider it essential for anyone working with code - whether a wide-eyed newbie or grizzled veteran.
How do human brains understand code? What neurological quirks do we all have? Which common mistakes can be easily avoided? Only by understanding our puny hardware ("Isn’t it a miracle that humans can do anything with no more than 1 byte of memory") can we understand how we should read, write, and think about code.
It is a relatively quick read - I burned through it on a 4 hour flight - but there are lots of practical exercises to do. And it is worth taking the time to think about the process of thinking about code.
Some of the insights are a little obvious - but it is worth spelling them out. For example:
when debugging, many programmers prefer to make small changes to their code (tweaks) and run it again to see if the bug is fixed rather than spending the energy to create a good mental model of the problem
It me! Why do I do that? Why do I think bashing around on a keyboard is more productive than taking 15 minutes to investigate my assumptions about what I'm trying to do - and what the previous programmer was trying to do? The book has answers - and some practical guides for helping you correct your behaviour.
Even "simple" things like naming conventions get a thorough examination, with plenty of academic references:
8.3.2 Snake case or camel case? The results of Binkley’s study show that the use of camel case leads to higher accuracy among both programmers and non-programmers 8.4.1 Code with bad names has more bugs Butler’s study found statistically significant associations between naming issues and code quality.
There are lots of footnotes if you want to go wandering into the academic studies - and there are many.
The book - rightly - throws a bit of shade on those of us who have got into bad habits, but haven't reflected on whether they're actually working for us.
11.2.5 Some thoughts on multitasking The interesting thing is that people who multitask often feel very productive
Ha! True. The book goes into the studies of why people feel the way they do - and whether the data bears out those feelings.
I urge you to read this book. If you are just getting started, it will help you develop good habits. If you're an occasional coder, it will keep you from straying. If you've been doing this for so long that your code is indecipherable to anyone else - it will give you a much-needed reality check.
The book is available DRM free from publisher in PDF, ePub, and Mobi. At about £25, it's probably worth charging it as a business expense.
Thanks to the publishers for the review copy.
Verdict |
---|
- Buy the eBook on Amazon Kindle
- Get the paper book from Hive
- Author's homepage
- Publisher's details
- Borrow from your local library
- ISBN: 9781617298677
Adam Fowler 🇬🇧🇺🇦 said on twitter.com:
There was something I read once that said humans don't multitask, they time slice. Old school mainframe style. That's why it takes so long to switch focus between coding projects/problems/convos. Can't remember the paper reference though sorry.
HackerNewsTop10 said on twitter.com:
Book Review: The Programmer's Brain Link: shkspr.mobi/blog/2022/04/b… Comments: news.ycombinator.com/item?id=308961…
DinoNerd says:
Note that the book is also available in paperback, which increases the odds that I'll read it. (Other people following this blog may feel the same way about ebooks, even those that are DRM-free.)
Smutchings said on twitter.com:
If only we could use the power of the computers we have to negate these arguments entirely - with IDEs that could switch casing and spacing based on user preferences.
Lea Verou said on twitter.com:
Yeah I've heard of these studies but I'm highly suspicious. Remember the science went back and forth about serif vs sans serif, line lengths etc. So many studies are rife with confounds and biases that I'm skeptical when they conclude something so obviously wrong.
Zoë Rose said on twitter.com:
Curious about screen readers - I've seen tweets that say camel case make it easier for the screen reader, but I've not seen that compared with _.