I’ve been hacking on greenlet lately, which has been in dire need of some tender loving care. The upcoming 0.3 release will include an API for extension modules that allows any extension module to create and manipulate greenlets directly in C without jumping through hoops.

I found myself wanting to add a test extension module to bring the C API under test, but it turns out that distutils doesn’t really support building extension modules that you don’t want to ship in the resulting binary distribution. In fact, when you run ”setup.py install”, distutils just copies the contents of build/lib.<platform>-<pyversion> to the target package.

The solution I came up with was pretty lame. greenlet has a tests package that provides a test collector function. Since some of the tests require an extension module to be built, the test collector will call tests.build_test_extensions(), which will manually compile the extension modules using distutils the same way that distutils.command.build_ext will, except that the resulting shared library is staged in build/temp.<platform>-<pyversion> before being copied into the source root.

The end result is similar to just adding the extension to setup.py, except that the test extensions don’t get installed. I’m definitely reporting this as a feature request for distutils2.

Here at Linden Lab, I'm sometimes forced to make sure my
code still works on Windows :P. Today I needed to install greenlet on
Vista, and of course easy_install bailed since it requires
Visual Studio 2003. As luck has it, 2003 doesn't work on
Vista. I miss my shiny Ubuntu laptop!

The workaround
I found with a little googling was to use MinGW to build the
extension module.

Brandon and I are going to Lugradio Live USA 2008 on April 11th and 12th. It is going to kick ass! If you are anywhere near California, you must go. You don’t have any excuses.

As an added birthday bonus, I’ll be attending as a new LindenLab employee! For those of you who might not have heard of them, LindenLab is the creator of the online virtual world Second Life. I was recently offered the position of Release Engineer, and my first day is on the 7th of April. Joy! I am so excited to start that I can hardly think about anything else. It looks like my new avitar is going to be Ambroff Linden, so come see me in-world!

Something Luis Villa posted today reminded me of an experience I had recently with a group of students. I am reminded of a phrase that I heard while discussing software licensing. “If we change 60% of the code, it’s ours.”

I am about to graduate with a BS in Computer Science from CSU Sacramento, which means that I’m currently working on my senior project.

My department’s senior project course is a little different at other schools I suspect, since it is a group project with 3 to 6 members per team, and spans two semesters. Also, rather than just coming up with a proposal for an interesting problem to solve, students compete to get a fake contract with one of several local businesses and government agencies. It’s good I guess, but I’d rather be hacking on GNOME or some other free software than write yet-another-boring-crm for tracking form submissions :-). It usually feels more like an exercise in paper pushing than designing software anyway, since the projects are quite simple and boring.

Anyway, me and a fellow teammate were discussing plans for a rather complicated custom widget we needed to create for this project. He found an example that some Joe Schmo had posted on the Internet without any license information, and wanted to just start with that and modify it where necessary.

My first thought was to ask if he knew anything about the license that the code was released under. His first reaction was to stare blankly at me, which I can understand, but this next part shocked me. I said, “Well, if he didn’t explicitly grant any rights to use and redistribute this code, the safe thing to ask him to release it under MIT X11, GPL, or any other license compatible with our codebase.”

He responded, “Why do we need to do that. If we change more than 60% of it then the code is ours.”

My jaw hit the floor. I didn’t even know how to respond to this. After a discussion about U.S. Copyright law, licensing, Copyleft and the four freedoms, etc., we had things straightened out. But I was still troubled.

I think that he may have been confusing one of his instructor’s plagiarism policies with copyright law. I find this especially disturbing because as a computer science student, he is required to take a course that explicitly covers Copyright, Patent and Trademark law. What is even more disappointing is that he is not alone. From my experience, many, many students in this department make the same mistake.

Maybe a question involving this topic would be a good weed-out question when hiring developers who will be working on free software? I would love to see the responses.

I’ve been hacking on a useless little project lately. My friend Brandon and I have been toying with the idea of designing a new programming language over the last couple of years. We are both compiler nerds, and many of our conversations usually lead to to a discussion about why this feature is great and why that language
sucks.

I’m a pretty big Python fan, and have been using it for years. It is still my go-to language when I just want to get something done. Unfortunately, the more I learn about programming languages like Common Lisp, Scheme, Haskell, etc., the more I run up against the restrictions that Python has.

Unfortunately, many of these are deliberate. It seams that Guido and many others resist features like continuations, macros, non-broken lambdas and proper tail recursion because they like to think of Python as a single-paradigm language. Adding these features means that some Python code could seem foreign or unfamiliar for some programmers.

I understand this argument, but on the other hand I find it extremely frustrating when I have an elegant, easy to understand solution to a problem that I just can’t use because of a seemingly arbitrary restriction.

So I thought I would kill two birds with one stone. I could start designing a language for fun (not profit :-)), and when I am ready to write the compiler, I can just emit Python bytecodes, so that I will have a huge set of libraries to experiment with, and have something usable right away.

This turned out to be extremely easy. Within a few days I had a working compiler that was near feature parity with Python, and some nice features added on. It is still pretty basic at the moment, I don’t have many of the features implemented that I have planned. For now it’s just a simple lisp-like language with similar semantics to
Python. After a couple of afternoons work, I did a google search for similar projects, and it turns out that there are about 10 people that have done something similar. I don’t really care though, this is just for fun.

One of the decisions that I made early on is that Python’s modules are a good idea. I think the module and namespace semantics are extremely well thought out in Python, and have encouraged a lot of really great patterns and idioms. So this language is definitely going to mirror that behavior.

One of the things I struggled with was under what circumstances should I allow myself to add syntactic sugar. I’m usually not a fan of such features, but there is one case where I made a compromise, and that is accessing attributes of an object. I tried to avoid this for as long as I could, but I tended to write a lot of code like this:

(set (getattr (getattr someobject 'propertya) 'propertyb) value)

In this case, I ended up settling for:

(set someobject:propertya:propertyb value)

I’m not really satisfied with that at the moment, but at least it is about the only such compromise I’ve made.

Another thing that is pretty important to me is avoiding any special operators. This is something that really bugs me about common lisp, I hate having to write code like this:

(reduce #'(lambda (x y) (* x y)) '(1 2 3))

Why can’t ‘*’ be a function? Scheme gets this right in most cases, but there are still around 10 special operators. I want zero special operators, or at least as few as possible. I ended up accomplishing this by allowing special operators to behave like functions in contexts where that made sense, and otherwise treating them like special operators. For example, the situations below would generate very different code:

(reduce * '(1 2 3))

This would simply map to a built in function for multiplication, that is only used when ‘*’ is used as a symbol. Otherwise:

(* 1 2)

This emits a normal BINARY_MULTIPLY instruction. This way it appears to have no special operators, but the code that is generated is as efficient as possible. I’ve tried to do this where ever I can.

At this point, it is possible to write just about any program you would write with Python, with a few minor exceptions that would be trivial to fix. Here is a simple pygtk program:

It really is remarkable how much Python resembles a Lisp internally. In some cases, what I thought would take days of hacking turned out to only take 1/2 hour. An example was loops. I wanted to implement something like the Common Lisp loop macro, only not as terrifying :-). It turns out that the behavior isn’t much different from Python list comprehensions, so implementing something like this was pretty trivial:

Although in the end I simplified loop a great deal, it was fun to see it work with so little effort.

I don’t know if I will actually release this code. It isn’t really that useful, it’s just a fun little project to tinker with and an easy way to try out new experimental language features. But if you want to play with what I have now, you can get it from my Bazaar branch.

bzr branch http://codewalking.com/bzr/sketchy.dev

My plan is to continue experimenting with this, and eventually weed out all of the unnecessary features. At some point I imagine having something that would be worth rewriting, maybe targeting another VM with a JIT like the LLVM, the CLR or Java, or writing my own JIT (that would be fun!).

Well, I spent most of my Saturday trying to figure out how to use the
mono bindings for Avahi. They aren't that complicated,
but no one has written any documentation yet. Today I've been
experimenting with a Zeroconf plugin for beagled.

Currently beagled will publish its index, and will keep track of any
remote indexes it finds in the log file. It's a start!

Authentication would be comprised of a cryptographic
challenge/response system using pass-phrases and keys. Once two
nodes have been paired up, they will automatically talk to one
another when they are on the same network. A "Sharing" or "Network"
tab could be added to beagle-settings, which would allow the user to
enable searching on the local network, and sharing local indexes
with other computers.

When beagled finds another host sharing its indexes, the user would be
notified, and given the opportunity to perform an initial
authentication. If the automatic notification is too annoying, then
the user could have some means of finding other computers to pair up
with. Beagle daemons on remote machines will communicate via XML-RPC.

Searching

When searching in beagle-search, a query is sent to beagled, and
beagled forwards the search to any hosts on the network that have been
authenticated in the past and are currently available with shared
indexes. Any nodes that require no authentication will automatically
be searched.

For live queries, any nodes that leave the network or are no longer
available will be removed from the results. Any new node that becomes
available during a live query will be sent the query and any results
will reported. Remote Beagle daemons will treat these live queries
just like a local live query on that machine, and will send new
results to the node that made the initial query until the remote live
query ends, or the node that made the initial query becomes
unavailable.

User Interface

Any remote hits will be displayed in such a way to indicate that
they are from a remote machine. They can also be hidden by a
disclosure triangle, and will only be shown if there are available
results. For example:

Double clicking on a hit from another computer might be tricky. Maybe
using HTTP to download the file from one host to another. The file
could either be copied to a /tmp directory, showing some progress
dialog until it is copied and then opened, or just using
GnomeVFS. Itwould also be useful if the user could also drag and drop
any remoteresults to a nautilus window or the desktop, which would
copy it tothe local disk.

Non-file Data

The original webservices implementation for Beagle only handled
file queries. It would be interesting to find a way to handle remote
chatlogs, webpages and emails.

Me

I am finishing my third year of undergraduate studies at California
State University, Sacramento, where I am majoring in Computer
Science. I've been using GNU/Linux on the Desktop since 1999, and am
passionate about free
software. See my resume for more information.

As for my .NET experience, I have been using Mono since its 1.0-beta
release, have been loving it ever since. I used Mono to develop
several in-house Gtk# applications at work, and a charity raffle
system for a large annual charity
event in California.

As a casual GNOME contributor, and a Beagle user since 0.0.[89] ish, I
would love to have the opportunity to hack on Beaglefull time this
summer. Beagle is one of the most interesting components of the GNOME
Desktop, and I would love nothing more than to help make it more
useful for the community.

Congratulations to all of you other students out there who were also accepted, and thank you so much Google for working so hard to make this happen. And most of all, thank you Joe Shaw and any other mentors for the Beagle project for giving my proposal a high ranking.

Google TalkWhile I am extremely pleased that a corporation as powerful as Google is supporting a free, open standard like Jabber, I'm sort of annoyed that their new Jabber service doesn't allow traffic from other Jabber servers. I have had a jabber id (kwa@jabber.org) for quite some time, and was hoping that this announcement would inspire a good number of my friends who use Gmail to switch to Jabber. It seems that this will change. The sooner, the better.

PhotosI finally got around to posting the pictures from our road trip to Vancouver a couple of months ago. The latest version of F-Spot is broken in the Flickr department, so I used F-Spot to generate a static HTML web gallery. Nothing on bugzilla or the mailing list. I'll have to look into it.