Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This is perfectly encapsulated by my favorite joke.

A physicist is showing their friend the computer scientist a thermos.

"This thing is so cool: you can pour something hot into it, and no matter how cold it is outside it stays hot". The friend is duly impressed.

"But that isn't all: you can pour something cold into it, and no matter how hot it is outside it stays cold"!

Now the computer scientist is puzzled. "But how does it know?"

Code like this is the bane of my existance.



I’m sorry I don’t get it.


Apologies if your comment was meant to be witty.

The thermos doesn’t have a toggle (flag) on the outside that the operator sets to “hot” or “cold”. If you want to know you look. And instead of giving it a “hot mode” and “cold mode” you just build it to prevent mutation of the contents.

Likewise its weight or fill level: just look. Having flags is extra work keeping them up to date plus worrying about what to do when they are wrong or in an unexpected combination.

But people write code that way all the time. I do my best to avoid hiring them.


Thanks. That’s very common in weak relational database schemas where people like adding redundant stateful columns.


Wider observation of the possibility for emergent behaviour vs narrow assumption of declarative state programming.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: