Ask HN: Have you ever “lost” a clever bit of code you weren't able to reproduce?

9 points by jarcane ↗ HN
Discussing with a friend on Twitter I was reminded that as a lad I once wrote an AI routine for haggling with a shop owner in an RPG that remains probably the best implementation I've seen.

Unfortunately, my brother then proceeded to power-cycle the drive with the disk still in, corrupting the file ... I was never able to reproduce the code because I couldn't remember exactly how I'd done it once I saved it.

Have you ever done something like this?

11 comments

[ 3.3 ms ] story [ 39.2 ms ] thread
I once (while in university) had the awesome idea to write some fantastic code after a night out.

Sadly I had to scrap the project the next day since it did'nt compile anymore :)

My father was the defacto Excel developer in his office and used to have vivid dreams that consisted solely of him writing out the code for some problem he'd been working on.

Then he'd wake up and forget the lot.

this. the trick is when u cant remember to stop there, and dont worry or force it, about 10 mins later the answer will come to u.
sadly, i use this same technique on the toilet.
It happens. Usually, rewriting the code from scratch will produce a better version.
Once, when I was pretty much a noob, wrote a language called OOJASIC which I implemented in Java. It was loosely typed, compiled to Java. I wrote a wrapper over swing as its UI library, and a simplistic visual IDE along the lines of BlueJ, that would show a smiling dino face if the file was compiled, and an anxious one if it wasn't.

All that's left of all this is the compiler code (decompiled using cavaj), and screenshots of the IDE (that I called Rex).

It was the most complicated piece of software I'd written at that point of time, and there's little left to show for it.

Here's a link to the project page, btw. And don't judge. This is from a long, long time ago.

http://justaddhotwater.webs.com/oojasic.htm

I would totally be able to reproduce it though, so it kind of misses the point. I wouldn't be as dedicated probably.
Often I've lost code not permanently but came across it months or years later after I thought I'd lost it.

More often than not, it turned out that the code wasn't clever so much as I had remembered it being clever. The code itself often didn't even do what I thought it had.

Not as much clever as infuriating, but I once had a bit of C++ code that would run perfectly fine, unless you deleted one of the comments, at which point it wouldn't compile. I lost the file in a hard drive failure many moon ago. Mostly, I wish that I still had it simply to prove that the compiler really was that buggy.
When I was a kid I wrote an ascii-art dungeon exploration game in BASIC on our Tandy 1000. I worked on it for months, maybe even a couple years, adding and adding. One day the floppy it was on failed.

I actually did rewrite it, and I remember noticing how much better the code was. I didn't have to think about game design at all, just about the code. In fact it was around that time that I finally understood what GOSUB was for. I wouldn't be surprised if it was that rewrite that brought the realization.