Hacker News new | ask | show | jobs
by sstangl 1850 days ago
In my experience code quality falls out from making mental simulations easier to produce. Abstraction boundaries should be drawn where mental processing starts feeling burdensome.

When running abstract mental simulations, do you assume that I/O operations succeed or fail for knowable reasons? It seems likely. If the code were expressed to match your mental simulation, for example by not performing I/O within the function, but by merely receiving I/O messages from a foreign actor, it seems like you're not far away from offloading the full mental simulation to something like quickcheck and writing down explicit invariants!

1 comments

This is why I say my ADHD has made me a better programmer. I can't mentally simulate more than the most basic state interactions. I have to write code that my rainy-Monday-morning, pre-meds, pre-coffee brain can reason about. And I see that as a win/win. It means someone foreign to the codebase has to put less thought into reasoning about it. My brain handles big picture thinking super well, but I can keep about 1.5 pieces of state in my working memory.

I love my IDE. I love interfaces, type systems, and static checks. ADHD pretty much forced me into a very functional programming style, because mutation is so more to think about.

Conversely, some of the most inscrutable and buggy code I've written was when my meds were a tad high and I could easily reason about really complex interactions.