5 Dec 2008, 11:38 p.m.

Copyright/License Comment Blocks Considered Harmful

Peter Griffin - What Really Grinds my Gears?

Rant alert. You know what really grinds my gears?

It's those epically long license/copyright notice comment blocks with which some developers, particularly those behind open source PHP projects, insist on prepending source code files.

You've all seen this kind of thing. I'm using Wall4PHP to illustrate my point, but they're by no means the only offenders.

So tell me, why do I have to scroll down a whole page every time I open up a file to check out the source? That essay there tells me absolutely nothing of any value about the code in that file. Worse still is that this type of comment tends to prepend code that lacks useful, meaningful comments - as if the developer thought that copy-and-pasting the copyright notice would get them off the hook.

To me, this is an utterly inappropriate use of comments; an abuse of the very syntax that makes it possible.

Really, why is this stuff in every single file of your project? One would assume that this kind of epic duplication ("multiplication"?) would be anathema to any developer worth their salt, but apparently not.

Screenshot of a Superfluous Comment Block

Guess what? If you release code under a particular licence, that license applies to all of the code, regardless of whether you state it at the top of the file. Furthermore, if you create something original, you automatically own the copyright on it, regardless of whether you state it anywhere.

If you really must, why not just include a LICENSE.txt file in the root of your project's document tree, and be done with it? Do you really think that some nefarious good-for-nothing is going to follow this particular train of thought?

  1. Man, this library is sweet, I'm going to steal me some of this code right here for some highly evil purposes
  2. Opens file, spots the 50-line copyright notice
  3. Denied! Guess I can't steal that code after all :( I think I'll go and help out at the homeless shelter instead

You know what, (s)he's just going to steal it anyway.

I suspect the habit stems from a Well, we've always done it this way, and Project X always did it this way, so it must be sort of ok mindset. It's probably worth taking the time to question that mindset.

Ok, I'm done now. I'm sure the eagle-eyed will spot that, for bonus irony points, I've illustrated this post by including an image which probably violates every copyright law out there.

Posted by Simon at 01:53:00 PM