In many projects these days most of the novel code consists of glue code that helps combine dozens of different libraries, plugins and helpers that are licensed under a variety of open source licenses.

In many cases the licenses are fairly obvious as they carry the name of the license in the license file or comment. In others this is a bit harder and requires memorizing certain wordings to tell the more common licenses apart.

I am wondering: Is there an easy way to recognize particularly the very similar licenses (say, MIT/BSD-2/BSD-3) without having to memorize complete license texts or check out the OSI copies as reference?

  • 1
    I'm probably missing something here, but why is this a problem? You need to know at least the name of the license, and on every project I've used that wasn't hard to find.
    – yannis
    May 5 '12 at 12:16
  • File comparison tool?
    – MarkJ
    May 5 '12 at 12:57
  • Related/possible duplicate of: programmers.stackexchange.com/questions/105344/…
    – Joey Adams
    May 5 '12 at 13:19
  • grep? extra characters because I have to but I shouldn't even need to make this comment.
    – Rig
    May 5 '12 at 13:31
  • 1
    If I understood correctly, the OP is talking about the (very common IMO) situation where a bunch of code has only a file generically named "LICENSE", with no indication of which license it is except for its text. Of course, if you're scanning those files programatically, grep or something similar is the answer, but since the OP mentioned "memorizing" I believe he's doing it manually. And as Jeff Atwood pointed out, it's very common to find code "in the wild" that doesn't clearly state its copyright status.
    – mgibsonbr
    May 5 '12 at 14:09

Just use the most powerful pattern matching tool you have at your disposal: your eyes. I ran into the same problem some time ago (was compiling a big list of Django apps and jQuery plugins, and most of them didn't explicitly name the license they were using), in the beginning I had to compare to a reference text all the time, but it didn't take long for me to become able to identify those licenses in a glimpse. Here's what I see when I look at the MIT license:

Copyright (C) <year> <copyright holders>

Permission is hereby granted, text text text
text text text
text text text

The above copyright notice and this permission notice text text text


And the Modified BSD:

Copyright (c) <year>, <copyright holder>
All rights reserved.

Redistribution text text text
* text text text
* text text text
* Neither the name of the <organization> nor the
  text text text


Notice how the text layout combined with a few key words/phrases are enough to identify those two licenses, and since they are by far the most common (that don't display its own name in the header, like the GPL or the Apache) they're easy to memorize (and obviously, I can tell it's BSD-3 because it has 3 bullet points).

Now, it's always possible - though very unlikely - that the authors used a slightly different license that you could mistake for the MIT/BSD-3, but if they did and they care about the difference, you can reasonably expect them to call attention to it.

Update: check this answer to a SO question about "grepping" a page using JavaScript; maybe with a little work one could write a small tool (a bookmarklet for instance) to search the contents of a page for the text of a license among a small set of known ones (written as a regex, since you'd have to replace the <copyright holder> and such for wildcards). I avoid bookmarkets because of the security implications, but if you either wrote or is hosting (if applicable) them yourself you should be fine. I know no existing tool for that purpose though.

Personally, I don't think it's worth the trouble - the effort to carefully examine a license is only a small part of the decision to incorporate it into a big project. Usually the troublesome parts are the library dependencies, or the relative effort to integrate them with the rest of your code. So I prefer to do a quick classification into "might use" or "definitly won't use" and then, if I decide the library is really promising, take a closer look at the license.

  • 2
    So you're saying rote memorization (of the general layout at least) is currently the only way to recognize them? That's what I feared. I'm working with Django apps and jQuery plugins in this case, too, btw. But I've seen licenses in the wild that seem very similar to MIT, BSD, etc, but contain minor modifications (say, the JSON license, which is not compatible with the GPL).
    – Alan Plum
    May 5 '12 at 17:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.