Bug Compatibility
Deliberately preserving or reproducing the bugs and quirks of an earlier system, because existing software has come to depend on them.
Also known as: Bug-for-Bug Compatibility, Bug-Compatible, Quirks Mode
Category: Software Development
Tags: software-development, software-engineering, compatibility, legacy, maintainability, api-design
Explanation
Bug compatibility, also called bug-for-bug compatibility, is what you get when fixing a bug would break more than the bug itself does. Once enough software relies on a defect, the defect is part of the interface. The new version, or the competing implementation, has to copy it.
**Examples**:
- **Excel and the year 1900**: Excel treats 1900 as a leap year, which it wasn't. Lotus 1-2-3 had that bug, and Excel copied it so spreadsheets would import with the same dates. It's still there
- **Windows compatibility shims**: Windows detects specific old applications and reproduces the old behavior they rely on. The famous case is SimCity, which read memory right after freeing it. Windows 95 got a special allocator mode so the game kept running
- **JavaScript**: `typeof null` returns `"object"`. It's a mistake from the first implementation, and fixing it would break too many websites
- **Browser quirks mode**: Browsers still render old pages with the layout bugs of 1990s browsers, because those pages were written against the bugs
- **Emulators and reimplementations**: Wine, game console emulators and API clones have to match the original, defects included
**Why it happens**:
Users build against what a system does, not against what its documentation says. That's Hyrum's Law. Liberal receivers make it worse: when a system accepts sloppy input, the sloppiness spreads until everyone has to accept it (see Postel's Law).
**The cost**:
- The defect has to be documented, tested and maintained forever
- The code fills up with special cases that nobody dares to remove
- New implementers have to reverse-engineer behavior that no specification describes
**What to do about it**:
- Fix bugs early, before anyone depends on them
- Be strict from the first release. It's easy to loosen later, and very hard to tighten
- When a quirk is here to stay, write it into the specification. HTML5 did that for browser error handling
- Isolate the compatibility behavior behind a mode, a shim or a version flag, so the main path stays clean
Related Concepts
← Back to all concepts