LOC

David has inspired me to look closely at LOC (Lines Of Code), and trying to keep the numbers low. Why? Less code means less code to read, write, maintain, understand, keep in your head, and especially modify when you realize that something else would be better for users or business.

Rails already has a built-in Rake stats target, but OpenACS does not, so last night I wrote this quick shell script to count the number of lines of code:

find . -name \.tcl -print | xargs grep “][#[:space:]]” | wc -l

Current LOC for my CMS project: 9545.

Current LOC for our intranet project: 1146.

I think real project size would account for the CMS to be about twice the size of the intranet, but no more. The rest—7253 LOC, or 75%—would be due to differences in language and platform.

If I ever get a chance to rewrite the CMS in Rails, I would be happy to report.

3 comments

Mark Aufflick

Not that I dislike Ruby or Rails (<a href="http://mark.aufflick.com/dev-blog/one-entry?entry%5fid=1881">as one of my recent blog entries are showing</a>), but I'm not sure that's a fair comparison. An intranet project written using Rails, or Maypole or whatever, contains only code for that project and nothing else. In an OpenACS package (even a custom one), you are making use of some very highly engineered sub-systems. While it takes effort to use them, these subsystems give you a lot of power and functionality now, and more in the future. Of course that benefit is not always needed or suitable. Ideally, sets of functionality will be developed for Rails and other frameworks, but it was the drive of ArsDigita that made OpenACS what it is compared to, say, Zope.
Read more
Read less
  Cancel
Actually, this is a pretty fair comparison. I'm only counting LOC in my package, not the whole framework, and what matters is how many additional lines of code it takes to deliver what I need to deliver. Those subsystems, whether part of the framework, or add-ons, should be judged on how easy they make it for me to deliver what I need to deliver. One way to measure that ease is LOC.
Read more
Read less
  Cancel
Mark Aufflick

True.<p> On a side-topic, one of the things that often amazes me about Java IDEs is how much template code they auto-generate. It doesn't matter how good the framework is, you just need a lot of LOC to get started.<p> Another side-topic, by properly implementing inheritance, we cut out a third of the LOC in a client project. Without OO (and multiple inheritance or similar) there would be no easy way to shave off those 20,000 lines. (The language was Perl fwiw).
Read more
Read less
  Cancel

Leave a comment