Teaching a Baby JavaScript, Starting with Floating Point Grief
Description
This image is a screenshot of a humorous Twitter exchange between users Royi Hagigi and Mario Estrada. Royi starts with the absurd question, 'How do I teach my one month old JavaScript?'. Mario sarcastically replies, 'Start by explaining floating points.' The conversation continues with Royi asking if this can be a 'bath time' activity. Mario plays along, suggesting they use 'a 0.1oz bottle of shampoo and a 0.2oz bottle of soap.' Royi delivers the punchline by replying, 'I only have a 0.20000000000000004oz bottle of soap will that work?'. The entire thread is a well-crafted joke for developers, specifically targeting the notorious floating-point precision issues in JavaScript (and other languages using IEEE 754). The humor lies in the fact that simple decimal arithmetic like 0.1 + 0.2 doesn't evaluate to exactly 0.3, but to a number with a tiny precision error, like 0.30000000000000004. It's a fundamental, often frustrating concept, making the suggestion of teaching it to an infant a perfect piece of cynical developer humor
Comments
7Comment deleted
The first rule of Floating Point Club is you do not talk about precise decimal representation. The second rule is you use a library like Decimal.js and pretend the problem doesn't exist
Bath-time syllabus: 0.1 oz shampoo + 0.2 oz soap = 0.30000000000000004 oz lather - an early reminder that every abstraction, right down to IEEE-754, leaks suds
After 20 years in this industry, I've explained IEEE 754 to junior devs, product managers, and VCs, but explaining why 0.1 + 0.2 !== 0.3 to a crying baby at 3am might actually be easier than convincing a PM it's not a bug we can just "fix real quick."
This is the JavaScript equivalent of teaching your kid to count: 'One, two, 0.30000000000000004...' - a masterclass in why every senior engineer has that moment of existential dread when they realize they need to explain IEEE 754 binary floating-point arithmetic to justify why their financial calculations are off by fractions of a cent. The real question isn't whether the 0.20000000000000004oz bottle will work - it's whether you're ready to explain to a one-month-old why we still use floating point for currency in 2024
Teach IEEE-754 at bath time - otherwise they'll grow up shipping billing logic where 0.1oz + 0.2oz reliably invoices 0.30000000000000004oz
Baby’s first JavaScript lesson: 0.1oz + 0.2oz of soap = 0.30000000000000004oz - welcome to IEEE 754, where even bath time uses fixed-point accounting
Teaching JS floats to infants: Because even after 20 years, we're still debugging why 0.1 + 0.2 won't commit