mskala's home page : lawpoli : copyright
Dr. Edward Felten has posted the source code for TinyP2P, "a functional peer-to-peer file sharing application, written in fifteen lines of code, in the Python programming language." I have three thoughts.
First of all, without meaning to diminish his accomplishment, on the very first non-comment line this code imports a ready-made XMLRPC server library, which then does almost all the work. The rest of the code is just the minor tweaks needed to turn XMLRPC into a file-sharing protocol. I would be more impressed, and I think the code would prove more, if it implemented the protocol on a lower level. Sure, the XMLRPC library probably ships with Python and so could be called "part of the language" and fair game to use, and it's true that someone who has Python would be able to get file sharing running by writing these 15 lines of code; but instead of proving "Look, file sharing is easy to implement, so you can't ban it!" I think this could instead be taken as proving, "Look, Python comes with a library of file-sharing tools included, so you should ban that!"
If we were going to have a contest for shortest file-sharing code (which might be fun), I think I would want the rules to forbid use of libraries that implement protocols at or above whatever protocol layer XMLRPC is considered to be. I'm not sure exactly where it fits into the OSI layer cake; it feels like an application-layer protocol just because it's complicated and runs on top of HTTP, but I imagine some of its proponents would claim it's lower-level because it isn't meant to be exposed to the user.
My second thought: 15 lines is nice, but it won't fit into a Usenet signature. For real coolness, I want to see one of these in whatever language that can fit into 4 lines of 72 characters. It might be necessary to compromise on the "no high-level protocol libraries" rule for that to be possible. There were all those RSA-in-a-sigfile programs floating around back in the export control days, so we know that very concise code is possible; but on the other hand, some of them depended upon bignum support in the language, and that's an analogous situation: if your language lets you do modular exponentiation on bignums, then that pretty much is RSA. The rest is glue logic. So maybe it's not unreasonable to allow high-level protocol libraries.
My third thought: How good is "we can do this with very few lines of code" as a proof of "this is easy" anyway? If you try to write one of these you'll discover very quickly that it actually is a lot easier to write a 50-line file sharing application than a 15-line file sharing application. That's what makes the 15-line version an interesting challenge. So waving around the 15-line version as proof that it's easy to write file sharing applications, doesn't ring true to anyone with programming experience; it's only useful for impressing non-programmers who might naively assume that shorter programs are simpler. The 50-line version, with comments and verbose variable names and clear program flow, might actually be better if we want to explain in detail how easy it is to write file sharing code. On the other hand, if we want to instead make the point "Look, we can distribute this widely, for instance in Usenet signatures and on t-shirts," then brevity becomes important and readability less so.
Copyright © 2004 Matthew Skala
Updates to this entire site:
Updates to this category (copyright) only:
Site search: