simont: A picture of me in 2016 (Default)
simont ([personal profile] simont) wrote2004-05-19 04:49 pm

Two hundred and eighty thousand

Yesterday I had occasion to implement a clone of an existing piece of software. It took me about 20 minutes, just by bolting together pieces of code I'd already written. This struck me as odd, not because it's unusual, but precisely because it isn't; I increasingly seem to be finding that when I want to write a program I usually have quite a few already-written bits and pieces that I can use to make the job easier. That's bits I've written, not including any third-party libraries.

Last week, someone told me that when he writes new programs, he often finds himself reaching for bits of code I've written which happen to be the right tool for the job. So I got to thinking: I must have written quite a lot of code in my time for this to happen so often.

So I've now gone through my source code directory on my main computer, catalogued everything in it, and counted how much there is. The result is a rather staggering two hundred and eighty thousand lines of code. That's around 280,000 lines of code that I've not only written, but still have and can re-use at need; it doesn't count stuff I wrote on Spectrums, BBCs, Amigas, strange CP/M machines my dad brought home from work, and suchlike.

280,000 is a hell of a number. I recently wrote 3000 lines of good working code in three days (while on holiday from work, so that was full time rather than evenings), and at the end of that time I could tell I'd achieved a peak of coding performance which I rarely hit at all, and I could also tell that I couldn't have sustained that rate for much longer than those three days. So 280,000 lines of code would have taken me the best part of a year to write, even if I'd been coding at that flat-out rate constantly! In fact this stuff is code I've written over about the last ten years, which makes it a believable figure; but even then, I have to take into account the fact that this is only code I've written on my own time, and doesn't count stuff I was employed to do or did as part of a university course. The bottom line is, I wonder how I ever managed to have a social life at all! :-)

Of those 280,000 lines of code, 150,000 are in programs I've actually released. A further 71,000 are in programs that are basically usable, perhaps lacking a little polish and full documentation or (in one case) unpublishable for copyright reasons, but not too far off being release-quality. That accounts for nearly 4/5 of the total, which is a rather satisfying thought; only about a fifth of my free-time coding output is seriously unfinished, flawed, abandoned or otherwise unusable. I call that a pretty good percentage: I was expecting a far higher proportion of write-offs.

Of course, now I find myself wondering whether I ought to polish up the 71,000 lines of nearly-releasable code for publication, just in case anyone might find it useful for something. Perhaps I should at least make a list of all the things I could publish if there were a sudden need for me to do so.

[identity profile] mazzarc.livejournal.com 2004-05-19 12:46 pm (UTC)(link)
I bow down in awe at your geekness... I am but a geek in training compared to you! I would sacrifice a small rat in your name.. but i don't have any handy. Would a CD do? *grins*

[identity profile] oneplusme.livejournal.com 2004-05-19 01:01 pm (UTC)(link)
I can't help but wonder if you've still got a copy of the LP Econet password file in there somewhere...

(Oh, and "hello", by the way. Very long time, no see.)

[identity profile] oneplusme.livejournal.com 2004-05-19 10:19 pm (UTC)(link)
Damn nigh ten... certainly eight or nine.

For the past few years I've kept bumping into people on the periphery of the Cambridge crowd who've claimed to know you (I stumbled onto your LJ via [livejournal.com profile] damerell's), which was giving me a worrying case of small-world syndrome...

(That and my brain immediately said "I know this person" when I was downloading PuTTY - for which thank you very much, by the way.)

Can you still do the "lob a cage backwards over your shoulder" trick on a PS/2 controller?

[identity profile] oneplusme.livejournal.com 2004-05-20 11:26 pm (UTC)(link)
Possibly I do mean PS2, yes... (I suspect I've been scarred by my attempts on life at 2 BogoMIPS.)

[identity profile] philipstorry.livejournal.com 2004-05-19 03:09 pm (UTC)(link)
Two quotes spring to mind immediately.

"I tend to break up a subprogram when there are too many local variables. Another clue is [too many] levels of indentation. I rarely look at length." -- Ken Thompson

This sprang to mind because your code is obviously very modular, if you can just reach for it and re-use it. Which is a good thing - I'm sure a lot of my code is crap, because I'm a sysadmin at heart and not a developer. I develop for fun, not as a career, so I don't get much time to develop anyway. :-(

The quote also reminds me that LOC is a poor quantifier of code quality. In a program of mine, I recently replaced ten lines of code with five (or thereabouts) - and it became not only faster, but also far simpler to maintain in the future. If my code can be tuned like that and remain functional, then your code must be quite phenomenally functional by comparison. And the fact that you're re-using it would suggest that its functionality is far more impressive than its LOC count.

That gave me a thought which brought me onto the second quote, really:
"One of my most productive days was throwing away 1000 lines of code." -- Ken Thompson

You must have had some phenomenaly productive days and weeks, just throwing away code you've long since forgotten about so that you can re-write it. That'll bump up your total a bit, too.

Hmm. The accolade of "Best developer I ever met" used to go to a Director at a company I worked for. But now I think about it, you're at least as strong a candidate as he is...

(Don't get that excited. I don't meet many developers. *grins*)
ext_8103: (Default)

Saint-Exupéry put it best

[identity profile] ewx.livejournal.com 2004-05-20 05:13 am (UTC)(link)
Perfection is reached not when there is nothing left to add, but when there is nothing left to take away.

Re: Saint-Exupéry put it best

[identity profile] philipstorry.livejournal.com 2004-05-20 08:29 am (UTC)(link)
Yep, that's also in my quotes file. :-)

[identity profile] mooism.livejournal.com 2004-05-20 05:09 am (UTC)(link)
How much of putty is yours, and how much other people's?