{"id":43,"date":"2005-07-20T14:28:21","date_gmt":"2005-07-20T05:28:21","guid":{"rendered":"https:\/\/regex.info\/blog\/2005-07-20\/43"},"modified":"2005-07-20T14:33:04","modified_gmt":"2005-07-20T05:33:04","slug":"memory-lane-looking-at-code-i-wrote-almost-20-years-ago","status":"publish","type":"post","link":"https:\/\/regex.info\/blog\/2005-07-20\/43","title":{"rendered":"Memory Lane &#8212; looking at code I wrote almost 20 years ago"},"content":{"rendered":"<p>I had the most interesting peek into my past recently, when the\nRootstown Water Company asked me to look at <span class='nobr'>a small<\/span> issue with their\nbilling software. <span class='nobr'>I originally<\/span> wrote it back in 1986 (19.5 years ago!).\nThey're still using it, unaltered except for one bill-formatting routine\nwhich needed to be updated for <span class='nobr'>a new<\/span> printer some years back.<\/p>\n\n<p>It's really pretty much in the state <span class='nobr'>I left<\/span> it, except that the machine\nis running <span class='nobr'>Windows 3.11<\/span> now (it had been running only DOS 2.11 when <span class='nobr'>I was<\/span>\nthere &mdash; <span class='nobr'>I know<\/span> the version number because they still have the original\n&#8220;IBM DOS 2.11&#8221; manual). Yes, they still boot <span class='nobr'>Windows 3.11<\/span> every\nday (with <b>win<\/b> at the end of <b>autoexec.bat<\/b> &mdash; remember those\ndays?)<\/p>\n\n\n\n\n\n<p>My code was written in <b>C<\/b> and compiled with the Mark Williams C\ncompiler version 3.0.6 (has <span class='nobr'>a copyright<\/span> date of 1982-1985). <span class='nobr'>You really<\/span> got\n<span class='nobr'>a lot<\/span> with this compiler. <span class='nobr'>It was modern<\/span> enough at the time to be on 5.25&quot;\nfloppies instead of 8&quot; floppies. Everything came on two 5.25&quot; floppies,\nincluding all system header files, the pre-processor, compiler, assembler,\nlinker, all libraries, <span class='nobr'>a debugger,<\/span> some Unix utilities (make, egrep,\nbanner, etc.), and even an editor &mdash; MicroEMACS. In fact, they even had\nenough room (on the two 5.25&quot; floppies, mind you) left over for the source\nto MicroEMACS. My, how times have changed.<\/p>\n\n<p>The problem that had cropped up in the software was reduced\nfunctionality in <span class='nobr'>a non<\/span>-critical reporting area due to some integer\noverflow. They shouldn't have run into the problem in the first place, but\nhad neglected to run some maintenance programs for <span class='nobr'>a few<\/span> years. <span class='nobr'>A log file<\/span>\ngrew unchecked, and its size eventually eclipsed the 16 bits the compiler\nalloted to an INT. (Had <span class='nobr'>I had<\/span> the foresight to make it an UNSIGNED INT, the\nproblem would not have shown itself in my lifetime, so <span class='nobr'>I accept<\/span> some of the\nblame \ud83d\ude42 )<\/p>\n\n<p>The fix &mdash; making one variable UNSIGNED &mdash; would have been easy except\nthat for whatever reason, the compiler no longer worked properly. They had\nmoved everything to new hardware from backups after <span class='nobr'>a disk<\/span> crash some years\nback (to the 333MHz <span class='nobr'>Celeron 64<\/span>-meg of memory they're using now), and\nperhaps that has something to do with it. <span class='nobr'>The build<\/span> process would end with:<\/p>\n\n<pre>LD: \\bin\\libc.olb(printf.o): bad reloc type 41<\/pre>\n\n<p>Although the compiler's two-volume hardcover manuals have 20 pages\ncovering build errors, <span class='nobr'>I could<\/span> find nothing about &#8220;bad reloc&#8221;\nof any type, much less type 41.<\/p>\n\n<p>They still had the full backup of the <b>C:<\/b> drive that <span class='nobr'>I made<\/span> on\n9\/6\/86, on nine floppies, and in theory <span class='nobr'>I could<\/span> have pulled the compiler\nfrom that, but either the 19-year-old floppies no longer worked, or the\nfloppy drive didn't work. After inserting <span class='nobr'>a floppy<\/span> into the drive, seeing\nthat the drive reported an error, and pulling it back out, it was hard not\nto notice the thick layer of dust the process had imparted onto the disk.\nEven after putting in many floppies, they still came out with somewhat of <span class='nobr'>a\nlayer<\/span> of dust, making me wonder if the &#8220;dust&#8221; is really disk\nmaterial flaking off.<\/p>\n\n<p> So, <span class='nobr'>I decided<\/span> to move to <span class='nobr'>a more<\/span> modern OS where <span class='nobr'>I could<\/span> use modern\ntools to rebuild things. They had some Win2K computers for other reasons,\nso that was good enough. <span class='nobr'>I installed<\/span> the <b>wonderful<\/b> <a\nhref=\"http:\/\/www.delorie.com\/djgpp\/\">DJGPP<\/a> system (gcc, gmake, and lots\nof GNU tools like bash and emacs) and recompiled there. Considering that my\nsource was written in pre-ANSI C, and considering that <span class='nobr'>I had<\/span> written it\nwhen <span class='nobr'>I had<\/span> no considerable programming experience, well, there were <span class='nobr'>a lot<\/span>\nof little things to clean up. <span class='nobr'>I used many<\/span> of gcc's command-line options to\nturn on <span class='nobr'>a lot<\/span> of warnings (including <b>-Wall<\/b>), and so spent <span class='nobr'>a few<\/span>\nhours going through everything updating to ANSI-C and cleaning up unused\nvariables and dangerous typecasts.<\/p> <p>In doing the heavy linting, a few\nbugs turned up and were fixed, although <span class='nobr'>I seriously<\/span> hesitated to change\nanything about how things worked, since they'd been using it as is for 19\nyears. My <a href=\"http:\/\/www.unixwiz.net\/blog\/\">brother<\/a> suggested <a\nhref=\"http:\/\/www.gimpel.com\/\">PC Lint<\/a> would be more insightful than\ngcc, as he says it's unparalleled in its ability to point out\n&#8220;issues&#8221;, but the aforementioned desire not to change much &mdash;\ncombined with my limited time and energy &mdash; caused me to set this idea\naside.<\/p>\n\n<p>It's always a little scary to look at old code, but this is by far the\noldest code that <span class='nobr'>I know<\/span> to still exist. (<span class='nobr'>I wrote<\/span> some very nifty stuff, in\n<a href=\"http:\/\/en.wikipedia.org\/wiki\/FORTH\">FORTH<\/a> no less, to control\na <a href=\"http:\/\/en.wikipedia.org\/wiki\/Flow_cytometry\">flow-cytometer<\/a>\nduring the early 80s when <span class='nobr'>I worked<\/span> at a <a\nhref=\"http:\/\/neoucom.edu\/\">medical school<\/a>, but <span class='nobr'>I don't<\/span> think it's still\nbeing used.) It certainly felt odd to look at it, since <span class='nobr'>I knew<\/span> <span class='nobr'>I wrote<\/span> it\nall (the one formatting routine aside), yet <span class='nobr'>I remembered<\/span> nothing about\nit.<\/p>\n\n<p>In once sense I was pretty happy with the code. Even though it was\nwritten in 1986 before &#8220;Y2K&#8221; was on anyone's mind (or, at least\nnot yet on my mind), <span class='nobr'>I still<\/span> engineered it to work fine through the end of\n2079. <span class='nobr'>The DOS on<\/span> the system now (likely the version that came with <span class='nobr'>Windows\n3.11<\/span>) isn't so graceful about dates: files <span class='nobr'>I edit<\/span> today show up with the\ndate &#8220;7-20-105&#8221;.<\/p>\n\n<p>In some other senses, <span class='nobr'>I shake<\/span> my head about some of my programming\ndecisions. <span class='nobr'>The way I<\/span> grouped things into files was very dorky, particularly\nWRT header files. Rather than have FOO.C's declarations in FOO.H, <span class='nobr'>I tended<\/span> to replicate the needed declarations in each file that needed it. <span class='nobr'>And my use<\/span> of global\/extern variables was... unsound.<\/p>\n\n<p>People tell me &#8220;hey, but it works&#8221;, and the current issue\naside, it has been working quite well for more than 19 years, but &#8220;it\nworks&#8221; has always been only the most basic starting point to measure\nsuccess, not the ending point. <span class='nobr'>I would<\/span> certainly do it quite differently\nnow, but then, <span class='nobr'>I'd charge<\/span> <span class='nobr'>a lot<\/span> more than $5\/hr to do it!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had the most interesting peek into my past recently, when the Rootstown Water Company asked me to look at a small issue with their billing software. I originally wrote it back in 1986 (19.5 years ago!). They're still using it, unaltered except for one bill-formatting routine which needed to be updated for a new printer some years back.<\/p> <p>It's really pretty much in the state I left it, except that the machine is running Windows 3.11 now (it had been running only DOS 2.11 when I was there -- I know the version number because they still have the [...]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/posts\/43"}],"collection":[{"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/comments?post=43"}],"version-history":[{"count":0,"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/posts\/43\/revisions"}],"wp:attachment":[{"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/media?parent=43"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/categories?post=43"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/regex.info\/blog\/wp-json\/wp\/v2\/tags?post=43"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}