Skip to Content
97 Things Every Programmer Should Know
book

97 Things Every Programmer Should Know

by Kevlin Henney
February 2010
Beginner
255 pages
6h 10m
English
O'Reilly Media, Inc.
Content preview from 97 Things Every Programmer Should Know

Chapter 9. Check Your Code First Before Looking to Blame Others

Allan Kelly

image with no caption

DEVELOPERS—ALL OF US!— often have trouble believing our own code is broken. It is just so improbable that, for once, it must be the compiler that’s broken.

Yet, in truth, it is very (very) unusual that code is broken by a bug in the compiler, interpreter, OS, app server, database, memory manager, or any other piece of system software. Yes, these bugs exist, but they are far less common than we might like to believe.

I once had a genuine problem with a compiler bug optimizing away a loop variable, but I have imagined my compiler or OS had a bug many more times. I have wasted a lot of my time, support time, and management time in the process, only to feel a little foolish each time it turned out to be my mistake after all.

Assuming that the tools are widely used, mature, and employed in various technology stacks, there is little reason to doubt the quality. Of course, if the tool is an early release, or used by only a few people worldwide, or a piece of seldom downloaded, version 0.1, open source software, there may be good reason to suspect the software. (Equally, an alpha version of commercial software might be suspect.)

Given how rare compiler bugs are, you are far better putting your time and energy into finding the error in your code than into proving that the compiler is wrong. All the usual debugging advice ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

40 Algorithms Every Programmer Should Know

40 Algorithms Every Programmer Should Know

Imran Ahmad
Five Lines of Code

Five Lines of Code

Christian Clausen

Publisher Resources

ISBN: 9780596809515Errata PageSupplemental Content