top | item 38132016

As I retire, my goal now is to release 40+ years of source code

1227 points| elvis70 | 2 years ago |dunfield.themindfactory.com | reply

323 comments

order
[+] jart|2 years ago|reply
I'm taking a look through DOSUTIL.ZIP and I love all these simple elegant C programs. A lot of these programs somehow only manage to have 1-2 standard c #include lines. How often do you see that? I also love how, out of 20,000 lines of C code, there only exists 24 #if statements. This is how C programming was meant to be. Reading codebases like this is one of the things I drew inspiration from when I started working on Cosmopolitan Libc.
[+] cdchn|2 years ago|reply
If your build targets are 1 then that saves you a lot of #if macros.
[+] thecyborganizer|2 years ago|reply
From STYLE.TXT:

  - True=7 -

  Having lots of very low-level code and hardware experience, I developed a bit
  of tendancy to "minimize what can go wrong at low levels" - C treats 0==FALSE
  and !0==TRUE - most people use 0/1 ... but thats only 1 bit "difference".  I
  sometimes use 7=TRUE as thats 3 bits with no more chars to type (and of course
  foolish as such a 1 bit hardware error would "trash" pretty much any system -
  but I do tend to be a creature of habit :)
I have never heard of this convention before! Was "random bitflips messing with your conditionals" a common problem back in the day?
[+] kqr|2 years ago|reply
Even if it was, are you really going to think of every conditional as a tri-state boolean?

Or will you assume that one of the branches is safe to execute during failure?

Or will you count the number of bits in each conditional and assume more ones than zeroes is a true, with no error correction? Will you log that a bit has flipped or otherwise alert the operator? Will you consider that as evidence that an int has changed value too?

Will you store ints with three bits per bits also?

Error detecting codes have their place, but it takes more than just saying that true is 7.

[+] LastTrain|2 years ago|reply
No, and the author basically admitted it was silly. My counter would be that it makes the intent less clear. I loved reading through his style doc though and I love that he just threw all this stuff out there. Something in his collection is bound to scratch somebody’s itch.
[+] jareklupinski|2 years ago|reply
tangential to 'how can a bit be wrong', when trying to see if a serial data line is working, i write 0xA5 ( 1010 0101 ) to send an alternating bitstream with a twist so i can test the greatest number of things i think can be wrong at once
[+] AnimalMuppet|2 years ago|reply
To the degree that you were worried about such things, this wasn't a real answer. Yes, it saves you if you have a boolean variable... maybe?

  if (var == TRUE)
    ; // It was 7
  else if (var == FALSE)
    ; // it was zero
  else
    ??? what do I do here?
And you need to solve that "what do I do here" for every single conditional on a boolean, and have the extra lines of code to handle it and not crash.

But, you know, what if it was a variable that you used in a switch statement instead? Or just "if (i > 17)"? Bit flips can affect your logic all over the place, not just when it's a boolean variable.

And then, if a bit flip can affect a boolean, it can also affect a pointer. Or the return address on the stack (or the link to the previous stack frame).

Or it can flip a bit in the code.

So this is, at best, a very very partial solution, and it's non-trivial to implement. So this was very much not standard practice or a "convention".

[+] layer8|2 years ago|reply
No, this is more a case of “this could conceivably happen, so why not guard against it where it’s easy to do”. Though personally I would have used -1.
[+] dboreham|2 years ago|reply
No. Random bitflips (aka hardware that doesn't work) are a relatively new thing. Bit flips due to buggy software was a thing though. This is why most database engines checksum the payload data even in memory. I've also seen network packets corrupted because a bridge (former name for switch) trashed data in flight, then reconstructed its CRC for the corrupt data on the onward leg.
[+] wrs|2 years ago|reply
I’ve been involved with systems where 0xffff… was canonical “true”, but not something as specific as 7! If you’re going to turn on more bits, why not all of them? Though I think this was because the NOT instruction was used for logical inversion, so the bit flip theory doesn’t apply.
[+] egometry|2 years ago|reply
Still is. And there's little to be done about it.

Unless you can stop cosmic rays.

Luckily it doesn't happen THAT often. I forget the exact metric but I recall various Google Engineers saying that something like one out of a million test run failures is a random bitflip?

[+] scottlamb|2 years ago|reply
> I have never heard of this convention before! Was "random bitflips messing with your conditionals" a common problem back in the day?

Due to RAM/CPU failures? I don't think so (though I have seen it, fwiw). With weird serial protocols that don't have proper checksums/digests, running over sketchy wiring? Yeah, and that might be part of "very low-level code and hardware experience".

[+] rendaw|2 years ago|reply
This doesn't make any sense even if the system isn't trashed.

If 7 == true and anything other than 7 == false, then one bitflip will still change the meaning. If 7 == true and 0 == false, then you could have code that does `if (mybool == 7) { ... }` and later `if (mybool == 0) { ... }` and end up with a situation where code path invariants are broken (i.e. mybool is neither true nor false.

If you use `>= 7` to mean true and `< 7` to mean false, while a 0 false value won't randomly become true if one of 3 bits randomly flips, a `7` true value will become false if any of those bits flip. And if any of the other bits flip, 0 will become > 7.

[+] kortilla|2 years ago|reply
It’s a problem even now if you have software security checks dealing with adversarial actors with hardware access.
[+] benj111|2 years ago|reply
Slightly off topic, but why did 1 become the truthy value and not -1?

Logical nots would then work.

And youre still an inc/Dec away from the opposite.

[+] varjag|2 years ago|reply
I regret not archiving my early code for good so much. First non trivial program (a snake game). First utility in assembly. First device driver (for a Centronics printer). That perpetual calendar in Pascal for a uni assignment, written with enormous hangover within an hour and still my only program written entirely bug-free to the date. All seemed trivial and not worthy of preservation then but in the end I have no code surviving from before late 1990s.

Take good care of your code kids!

[+] legends2k|2 years ago|reply
This is a problem only we'd to face. Kids these days use Git in some hosting hub or the other that it's a rarity that their code gets lots. Of course if these "free" services go down... it matters. Self-hosting has its uses.
[+] gpcz|2 years ago|reply
I have a lot of my old code, but I never want to look at it because it's super-cringe.
[+] xtracto|2 years ago|reply
Same here. I made a DOS spreadsheet program (with modeX charting! And formulas), a couple of games and a couple of viruses (aaaa TSR looked like magic)... I think they might be in some floppies in my mom's basement.
[+] golem14|2 years ago|reply
Worth reading the Author's recollections of his almost dying in 2019:

https://dunfield.themindfactory.com/2019.htm

[+] haolez|2 years ago|reply
That was intense. It made me think about my father in law, who had a heart attack in 2015 that compromised 90% of his heart. His exams are so ugly that one of his physicians refused to threat him, probably worrying that he might die any minute during the appointment.

He is still alive today, he has a normal life and he even manages to go for a run in the beach every saturday. His exams haven't improved, he is always out of breath, but he just refuses to die. It's like what the physician said in the link above: "You look a lot better than what's in the paper".

[+] winrid|2 years ago|reply
> "Hug his children. Sleep in his own bed. Eat his meals. and Work a little with his hands." in her words "They shot everything she said down"

Anyone know why doctors do this? They did the same thing with my father when he wasn't getting better (leukemia with pneumonia) and they couldn't get him off the breathing tube. They were very adamant he'd be disabled for life.

[+] hnthrowaway0315|2 years ago|reply
Strangely reminds me of "The Shadow out of the time" by the reverent HPL.
[+] m3kw9|2 years ago|reply
Grim af but that looks like a happy ending
[+] jandrewrogers|2 years ago|reply
I love this. It has crossed my mind more than once to do something similar at some point in the future.

This is a bit like receiving an inheritance from your grandparents. There will be true gems and novelties mixed in with a lot of knick knacks and rubbish. But the totality of that tells a story of real people living rich and interesting lives that only a handful of highlights would not do justice to.

[+] albertzeyer|2 years ago|reply
Why only when you are retired? Why not just right now?
[+] coldcode|2 years ago|reply
I wish I had saved something from my 40 years of programming, but I alwayds left everything behind when I moved to a new job. I did manage to keep my commercial memory allocator from the late 90's (single threaded, only supported Metrowerks CodeWarrior and the old MacOS), it was the fastest allocator on the Mac, and bug-free, but became obsolete with MacOS X. Not sure anyone would care today. I lost my source code to Trapeze as I mentioned yesterday ( https://en.wikipedia.org/wiki/Trapeze_(spreadsheet_program) ). I guess I never throught about saving most of my work for a day when no one cared if I shared it.
[+] nihiven|2 years ago|reply
This is really cool. It seems very 'pure' in comparison to what my code history will look like. In 2040, a lot of my code will show how I used a bunch of libraries and frameworks that nobody uses 'these days'. This doesn't seem good or bad, just a reflection of the times.
[+] swatcoder|2 years ago|reply
And unless you put in the effort to archive those dependencies yourself, nobody may be able to truly read or build your code anyway.

Today’s trendy development practices are shockingly ephemeral and fragile. Very little of today’s projects would survive one decade left fallow, let alone four.

[+] myth_drannon|2 years ago|reply
all these `pip install` and `npm install` will be useless
[+] jhallenworld|2 years ago|reply
I think his most impactful utility is ImageDisk: used to archive floppy disks from many different types of computers using IBM PCs.

Much of the old software found on bitsavers.org (and archive.org) was recovered using this utility.

[+] TMWNN|2 years ago|reply
Vernor Vinge's A Deepness in the Sky depicts a human society thousands of years in the future, in which pretty much all software has already been written; it's just a matter of finding it. So programmer-archaeologists search archives and run code on emulators in emulators in emulators as far back as needed. <https://garethrees.org/2013/06/12/archaeology/>

You've made a contribution to the hoard that someone will benefit from, whether tomorrow or in 5,000 years.

[+] bilekas|2 years ago|reply
This is brilliant.. It's so interesting too because over the years I've built up a few "Bibles" that I always need on hand when working in a particular language or even just automation, I've learnt some very good organising processes (from HN to be honest), I never thought to 'release' them as they feel quite personal and specific for my mental process.

Looking through some of these though, I think I'm inspired. Super cool idea, I would donate to the retirement project financially to say thanks if possible.

[+] razster|2 years ago|reply
Another link from DDS is Dave's Old Computers http://dunfield.classiccmp.org/ , a nice treasure of old pc reviews and images, (Left, right, front and back). This is amazing as I've been working on making 3D assets for a project of mine.
[+] yndoendo|2 years ago|reply
Any one catch the out of memory comment?

# we require more vespene gas; unix consensus; kNtErrorOutofmemory;

[+] pbhjpbhj|2 years ago|reply
elvis70 are you Dave Dunfield (the source author)?

[It might be more a ShowHN if you are?]

I'm interested if all of the code is self-written? If you wrote any of it under contract and so had special terms to allow you to eventually release it? Which piece of code there that you are most proud of and/or gonna most useful?

[+] bilekas|2 years ago|reply
Quick question because I can't actually find any info on it, but what license are these released with ?
[+] vitiral|2 years ago|reply
It's in COPY.txt, although it's homespun.

If you're the author, please please release into the public domain (CC0) if your purpose is educational. That makes it so anyone can learn from it and build on it without any fear of infringement.

[+] fallat|2 years ago|reply

[deleted]

[+] LastTrain|2 years ago|reply
This is great - add them to github!
[+] megous|2 years ago|reply
Or maybe don't feed the machine...
[+] snvzz|2 years ago|reply
Not using a standard license but rather a bespoke one is a major legal roadblock.

The presence of use restrictions does also disqualify it from being Open Source (OSI trademark) or Free Software (GNU/FSF).

If a standard license was adopted instead, such as MIT (permissive and I believe well-aligned with the intent of the author), then any concern would go away.

[+] accrual|2 years ago|reply
I downloaded RINGSW.ZIP to check it out.

> This file is NOT included in the demo version of this product.

> For more information, please contact Dunfield Development Systems

I admire the effort, but if you're not going to make the source freely available, what's the point? What is somebody going to do 100 years from now when they get your .zip off archive.org and you're long gone?

[+] legends2k|2 years ago|reply
> what's the point? What is somebody going to do 100 years from now when they get your .zip off archive.org and you're long gone?

The author seems quite aware of this. He calls it out specifically: it's for learning and curiosity purposes.