The surprising offspring of boolean arithmetic
Description
A meme taken from a "Family Guy" scene depicting Noah's Ark. Noah, an elderly man with a white beard and tan robes, looks bewildered and asks, "What the hell is this?". He is gesturing towards a bizarre creature: a small penguin with the head of a blue elephant. This creature is labeled with the number "2". To the right, standing behind the creature, are its "parents": a large, unimpressed-looking blue elephant labeled "true" and a small penguin also labeled "true", with a plus sign between them. The setting is the wooden interior of the ark. A watermark for "t.me/dev_meme" is visible in the bottom-left corner. This meme humorously illustrates the concept of type coercion in weakly or dynamically-typed programming languages like JavaScript and Python. In these languages, boolean values can be implicitly converted to numbers when used in an arithmetic operation. The boolean `true` is treated as the integer `1`. Therefore, the expression `true + true` evaluates to `2`. The strange hybrid creature represents this counter-intuitive but technically correct result, which often surprises developers accustomed to stricter type systems
Comments
7Comment deleted
A statically typed language developer sees this and asks 'What the hell is this?', while a JavaScript developer just calls it another Tuesday and checks if `[] + {}` is still a thing
In the grand design review of creation, JavaScript snuck in a feature flag where booleans autoconvert to integers - now Noah needs a linter before he boards any more animals
After 20 years of explaining to junior devs why JavaScript's type coercion is actually predictable and well-documented, you realize the real bug was defending it in the first place
This perfectly captures the moment a senior engineer realizes their junior just shipped code relying on JavaScript's type coercion where `true + true === 2` because booleans silently convert to numbers. It's the exact face you make during code review when you see production logic depending on `+` instead of `||` or `&&`, and you know the next bug ticket will be 'intermittent calculation errors' that take three days to trace back to this implicit cast. TypeScript evangelists keep this meme in their back pocket for a reason
Explains why my feature flag eval'd true in staging only
JavaScript and Python happily make 2 out of “true + true”; the senior move is stopping the Ark from breeding integers with types and linting before Finance starts counting them
Two truths make 2 in JS and Python - great for SUM() in analytics, catastrophic when your feature-flag math ships to prod