Pages

Wednesday, September 28, 2011

Python libraries should not be licensed under the GPL

GNU General Public License (GPL) is great. It has helped the computing world in huge ways. I don't think Linux would be where it is today if it weren't for the GPL requirement that people who distribute modified versions of Linux also release their modifications. The GPL is what is called a copyleft license, it means modified versions of GPL'd software must be released under the GPL or a GPL-compatible license. In this way the GPL is infectious, like a virus. If you release software that includes any GPL'd code, your software in now under the GPL, or your software is illegal. Your software cannot be licensed under a permissive open source license like the BSD or MIT licenses.

The viral nature of the GPL poses a problem for code libraries, because anything released that uses the library will have to be GPL licensed. Mercurial has a good explanation of how the GPL works. It's really easy to write a little web application to display info about your local Mercurial repositories, all you have to do is import hg and write 50 lines of code. But if you do import hg, and you release your code, it must be released under the GPL. This is fine for a major stand-alone application like Mercurial, but not for libraries that don't function on their own. I have been disappointed by how many Python libraries are licensed under the GPL, for example all the DHCP-related libraries I have found are GPL.

The LGPL

The GNU Lesser General Public License (LGPL) is specifically designed to be used by libraries, it allows a license-incompatible application to link to a LGPL'd library. I personally find the LGPL to be extremely confusing for non-C applications. The terms it uses like "linking" and "header files" don't make sense for most interpreted laguages like Python and Ruby. The confusion has led to the creation of the Lisp LGPL. The Free Software Foundation has tried to clarify this confusion for Java, but even their clarification is confusing.

"Applications use Java's “import” functionality to access classes from these libraries. When the application is compiled, function signatures are checked against the library, creating a link."

So in Java it works correctly because Java compiles and links? What about Python which compiles at runtime? Or combined/minified JavaScript? Twisted was originally licensed under the LGPL, then it was changed to the MIT License. In regards to choosing the LGPL, Glyph Lefkowitz the creator of Twisted, said:

"In that, the confusing wording of the LGPL as it regards Python code was an asset. It would be a halfway accurate statement that I selected the LGPL exactly because it doesn't make any sense."
I'm not a lawyer, but I agree, the LGPL doesn't make sense, if for no other reason than it has created all this confusion.

Real World Example

For a real world example lets look at MySQL. The MySQL database and libraries are licensed under the GPL, with a key exception, it allows linking from OSI-compliant open source software. That linking exception allows MySQLdb, the Python interface to MySQL to be dual-licensed under the GPL and the old Python License. The Python License is a liberal BSD-like license. As a result of the permissive licensing of MySQLdb, the extremely popular Django framework, licensed under a BSD License is able to use MySQLdb. And a cool project like Review Board, licensed under the MIT License is able to use Django. If MySQL didn't have the linking exception, MySQLdb, Django, and Review Board would all have to be GPL licensed.

More realistically if the MySQLdb team had decided to only license it under the GPL, Django and all other frameworks would not use it. Instead they would use a BSD-licensed alternative, and the MySQLdb project would die. The same is true in the Ruby world, Ruby on Rails is MIT licensed. If you are writing some really cool Ruby library, and you hope it's going to become uber popular and included in Rails, you better not license it under the GPL.

Your Choice

The developers of software have the right to choose what license they use, and I don't mean to sound like I'm telling them what to do. I understand many people strongly believe in the GPL, and they choose it knowing the full implications of it. But I think, or at least I hope that most open source developers writing libraries want their libraries to be as widely used and useful as possible. If that's the case, I strongly believe that BSD-like licenses, like the BSD 2-Clause License, MIT License, or ISC License are the way to go.

Sunday, September 11, 2011

My Memories of 9/11

My alarm went off at 5:55am PDT. I used my Aiwa stereo as an alarm, tuned to KGO Newstalk 810. There was some breaking news about an airplane hitting one of the Twin Towers in New York. Some eye witness said it was an airliner, like a Boeing 737. I thought yeah right, airliners don't crash into buildings, it was probably a little Cessna. I went downstairs and turned on the TV. I watch replays of the plane hitting, it was an airliner. At 6:03am PDT I watched live as a plane hit the second tower. The TV anchor didn't notice it was a second plane, he said it was a replay, but I noticed. One tower had smoke coming from it, and a plane hit the other tower. The TV said Live. It was shocking.

It was time to get ready for school. I had a Linux Administration class that morning, the official title of the class was probably something silly like "Introduction to UNIX", but it used Red Hat Linux. I brought a radio into the bathroom and listened to KGO as I got ready. After getting ready for school I went back to watching TV. I saw the people jumping out of the buildings. Then one of the towers collapsed. A wave of dust rushing down the streets. Then another tower collapses. It still brings tears to my eyes to think about it. It was horrific. I went to school.

Some people in class hadn't heard about the attack. It was hard to form the words to explain it. The towers were just gone. It was a very quiet and somber day in my Linux Administration class that morning.

Monday, September 5, 2011

99 Bottles of Beer in CoffeeScript

99 Bottles of Beer is a really fun (for a geek) website that has a huge collection of programs written in different programming languages, that all print the lyrics to "99 Bottles of Beer." It is a great way to show off the basic elements of a language, such as conditionals, loops, variables, string printing, etc.

There are examples of language simplicity, such as this Python version. Or the complete absurdity of a language, like the Perl example the looks like ASCII art of bottles of beer, but is actually executable Perl. Then there are the crazy funny languages like lolcode and COW.

CoffeeScript is a language the compiles to JavaScript, but it is simple and elegant like Python. While I was learning about CoffeeScript I noticed there were no CoffeeScript versions of 99 Bottles of Beer. So I wrote one! It's not fancy, it's the most straight forward way I could think to do it. I submitted it to 99-bottles-of-beer.net, hopefully they will accept it.

If you are using Mac OS X you can use Homebrew to install CoffeeScript and Node.js (required for command-line CoffeeScript).