

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

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&#x27;ve seen.<p>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&#x27;t remember exactly how I&#x27;d done it once I saved it.<p>Have you ever done something like this?
======
mchannon
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.

------
pjungwir
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.

------
rprospero
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.

------
yen223
I once wrote an AI that solves the Sliding Block puzzle:
[https://itunes.apple.com/en/app/unblock-me-
free/id315019111?...](https://itunes.apple.com/en/app/unblock-me-
free/id315019111?mt=8)

The code is still in my PC, but I moved overseas, and didn't bring my PC
along.

------
divs1210
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](http://justaddhotwater.webs.com/oojasic.htm)

~~~
divs1210
I would totally be able to reproduce it though, so it kind of misses the
point. I wouldn't be as dedicated probably.

------
informatimago
It happens. Usually, rewriting the code from scratch will produce a better
version.

------
andersthue
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
:)

~~~
jarcane
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.

~~~
mc_hammer
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.

~~~
griff122
sadly, i use this same technique on the toilet.

