Sunday, April 15, 2007

How much code do you write?

{

I've previously identified perl as my "night language." In other words, I'm hacking away at it in the off hours trying to get better. Maybe, just maybe, I will find a way to get paid for writing perl code. As of now, however, I write C#/.NET code to put food on the table.

As an exercise in perl, in order to demonstrate how fast it is, I wrote a small script that would count the number of lines of code I was responsible for last year. That's an easy task; I keep all the code I am working on for a given year in the same directory. There are a few projects that span a year's end, but it's okay since there's a lot of code that is written that doesn't make it to my directory, and there is a lot of code I write that isn't C#, which is all I was counting in this instance.

After a little tweaking, I had a script I felt happy enough with to point at my CODE06 directory. I was fairly curious - the folder is about 650MB but a lot of that is binary stuff, everything from installers to compiled bits of projects. My script - or perl, I should say - is unbelievably fast; when I changed output to a file it was able to run in less than a half minute. The first run showed that there were ~160,000 lines of code in the directories *.cs files.

Interesting - not an accurate estimate of things but 438 lines of code per day (160,000 / 365) and if you consider only business days (251), that's on the order of 637.5 per day. I can hear the Herbert song playing Something Isn't Right in my head at this point.

I do use Visual Studio, and one of the points of interest for me was the difference in how much code I actually wrote and how much was generated. Again back to estimating I excluded Visual Studio generated files from my project and that cut the number down to ~30,000 lines of code.

This is very imprecise because there are some *.cs files which are generated but it still has the Something Isn't Right going in my head because a little bit of help and organization from an IDE is fine, but the cost of 84% of output being machine generated is steep.

It's an Ellen Ullman moment; the realization that there are so many layers of abstraction between you and your tool - that you're unaware of all the hiding it does for you. It's a reminder of a moment a while back when I was showing someone how dangerous letting a tool do something for you can really be.



}

No comments: