Two hundred and eighty thousand [entries|reading|network|archive]
simont

[ userinfo | dreamwidth userinfo ]
[ archive | journal archive ]

Wed 2004-05-19 16:49
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.

LinkReply
[identity profile] mazzarc.livejournal.comWed 2004-05-19 12:46
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*
Link Reply to this
[identity profile] oneplusme.livejournal.comWed 2004-05-19 13:01
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.)
Link Reply to this | Thread
[personal profile] simontWed 2004-05-19 15:29
Goodness. Hello. Yes, it must have been about ten years, in fact, mustn't it?

No, I haven't got the password file, at least not that I can find. However, I do still have all the tools we used to get hold of it :-) And I've also done a PS2 Linux conversion of the son-of-Tron game we played when we weren't doing that, which has been good for a few laughs round here.
Link Reply to this | Parent | Thread
[identity profile] oneplusme.livejournal.comWed 2004-05-19 22:19
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?
Link Reply to this | Parent | Thread
[personal profile] simontThu 2004-05-20 01:19
The world's certainly pretty small. I discovered last year that a fellow user of Monochrome BBS was Will Dickson's housemate. (And he had only become aware that the two of us knew each other when Will downloaded PuTTY and said "ooh, I know this person", to which Ritchie said "hang on, so do I"...)

I think you mean PS2, not PS/2 :-)

And yes, good grief, of course you can do that trick. It'd be a pretty poor conversion if you couldn't!

(The PS2 version makes use of the ludicrous number of buttons available on the controller to allow you to have multiple weapons and special functions available at one time, rather than only one of each as on the Beeb - there's a configuration screen where each player gets to independently bind weapons and functions to all eight of the fire buttons. This alters the game balance quite a lot if you allow unrestricted choice by both players - suddenly you have to start thinking hard about which weapons are better than other ones, rather than just giving both players the same one and trusting that the intrinsic symmetry will ensure fairness. On the other hand, cloaking and teleportation and extend-range can be a devastating combination...)
Link Reply to this | Parent | Thread
[identity profile] oneplusme.livejournal.comThu 2004-05-20 23:26
Possibly I do mean PS2, yes... (I suspect I've been scarred by my attempts on life at 2 BogoMIPS.)
Link Reply to this | Parent
[identity profile] philipstorry.livejournal.comWed 2004-05-19 15:09
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*)
Link Reply to this | Thread
[identity profile] ewx.livejournal.comThu 2004-05-20 05:13
Saint-Exupéry put it best
Perfection is reached not when there is nothing left to add, but when there is nothing left to take away.
Link Reply to this | Parent | Thread
[identity profile] philipstorry.livejournal.comThu 2004-05-20 08:29
Re: Saint-Exupéry put it best
Yep, that's also in my quotes file. :-)
Link Reply to this | Parent
[identity profile] mooism.livejournal.comThu 2004-05-20 05:09
How much of putty is yours, and how much other people's?
Link Reply to this | Thread
[personal profile] simontFri 2004-05-21 01:26
The vast majority is mine. There have been some valuable contributions, but nothing really enormous.

The biggest two contributions I can think of are the basic structure of PSCP and the Unicode enhancements, each of which is in the region of one or two thousand lines.

Oh, and there's the Mac port, which weighs in at nearly 10,000 lines that I didn't write any of; but that isn't working yet :-)
Link Reply to this | Parent
navigation
[ go | Previous Entry | Next Entry ]
[ add | to Memories ]