Hacker News new | ask | show | jobs
by nothanksmydude 2637 days ago
This is a fantastic example of my favorite programming technique:

When nothing makes sense and you're real emotional about it and want to give up... GIVE UP!*

*But you have to write another one from scratch tomorrow because there's good odds you'll do it right on accident and will then be able to diff and understand exactly where you went wrong. Being able to identify this situation and when doing this is useful as early as possible will make you very valuable. The break between attempts is important, go do literally anything else besides code.

I once spent a week going in literal circles because of some degree/radian conversion errors. The rewrite took about 15 minutes.

Never trust anyone's ability to count, not even your own.

It's particularly useful in this exact situation, where the differences are mere +'s and -'s, off by one here or there, maybe a bad copy paste with similar looking variable names. Typically math related

2 comments

This connects to Tim Harford's Ted Talk "A powerful way to unleash your natural creativity." Quitting when you hit the wall and moving on to another task will allow your subconscious to work on the problem, often hand delivering it to you when you jump back on your original task. I think knowing I would have to start from scratch the next day would throw that system into hyperdrive. Thanks for sharing!

https://www.ted.com/talks/tim_harford_a_powerful_way_to_unle....

> going in literal circles because of some degree/radian conversion errors

Hehe, nice.

And thanks for the tip! Retrying tomorrow is nothing new to me, but I never thought to save yesterday's progress and diff it with the next day's rewrite to figure out why I was stuck.

It's especially useful when the changes are so small/subtle that you wouldn't even catch them looking at commit history.