World's Shortest P2P App: 15 Lines 443
soren.harward writes "The New Scientist has an article about TinyP2P, the world's smallest P2P app. It's 15 lines of Python code brought to us by Edward Felten, CS Professor at Princeton and outspoken supporter of the digital rights the Slashdot community holds so dear. He wrote the program as a proof-of-concept that P2P apps are really easy to write, don't have to be complicated, and thus banning them (a la the INDUCE Act) is pointless and silly."
Reported last month (Score:5, Informative)
The last article also mentioned the 9 line Molestar written in Perl - which is now 6 lines [sooke.bc.ca].
A more legible version of tinyp2p.py (Score:5, Informative)
Re: Libraries (Score:1, Informative)
You don't need to install external third-party libraries for this app.
Re:bet i could write a 15 line (Score:3, Informative)
Re:bet i could write a 15 line (Score:2, Informative)
There's the important part, I think. Any measure of a program's simplicity based on how many "lines" it is fails to take into account the level of abstraction the language itself provides. I mean how many instructions are called with those 15 lines?
Simple to program != simple program
Re:bet i could write a 15 line (Score:3, Informative)
I was a subscriber at one point, and I submitted emails when I noticed a duplicate article in the queue, but the duplicate articles were rarely ever removed, and email to "daddypants" frequently bounced.
You missed the point. (Score:5, Informative)
The point is that the DIFFERENCE between a networking application that has nothing to do with P2P and a P2P application is 15 lines. Thus, if you write a law that "bans something that allows peer-to-peer file sharing", you've probably just banned the standard distribution of Python since, being only 15 lines short of being a full P2P app, it pretty much allows peer to peer file sharing.
Re:How does this prove anything? (Score:3, Informative)
And then as soon as they start gunning for your program, 30 others will pop up and at least 5 of them will become just as popular as yours was, thus making it pointless to have gunned down the initial program; you just made the problem worse.
Quoting the author of TinyP2P
"P2P can be simple and written very quickly, so to try to ban or prevent the technology is not feasible."
Re:Python? (Score:2, Informative)
The point was to show how easily something of dubious legality can be made from parts considered legitimate, that SimpleXMLRPCServer and xmlrpclib are 15 lines away from actually being p2p_lib, so if legislators wanted to ban p2p_lib, they'd have to ban SimpleXMLRPCServer and xmlrpclib too. MoleSter [sooke.bc.ca] goes even deeper, threatening that the Perl interpreter is under half a kilobyte away from being a P2P app as well.
Re:How does this prove anything? (Score:3, Informative)
The point is that a ban would be ridiculously hard to enforce as pretty much anyone could write a new P2P app, which could quickly rise to popularity. You'd be fighting an endless battle with no hop of victory unless you start putting serious restrictions on compilers etc. at which stage... well...
Jedidiah.
Re:Reported last month (Score:5, Informative)
No. Perhaps you should have had a look at the TinyP2P web site, which defines a line as follows: "Each line has 80 characters or fewer."
If you really want to compare sizes though, compare the number of characters: TinyP2P has 951 non-whitespace characters; Molster has 436. And the author of Molster also makes the point that almost all the P2P work of TinyP2P is done by an external library. Have a look here [sooke.bc.ca] for more of the author's thoughts on the matter of sizes - they're quite interesting.
Re:1 line? (Score:1, Informative)
Not really. I don't want to be an ass, but Python does have the semicolon; it's just only needed when you explictly want to do more than one statement in a line (like Visual Basic has the ":" separator).
You're right in a thing: TinyP2P does not use any semicolons, but it's still hard to define how many lines exactly it has. Lines 11-13 represent a single line (which was split to conform to the 80-characters-per-line limit), yet it abuses so much of functional programming and multiple variable assignment that I wouldn't say it's a single line (in the sense of a line being a single instruction with one or more auxiliar operations).
For instance, "x, y = 1, 2" defines two variables at the same time. In standard algorithmic notation (aswell as in most languages), this would be two lines, but Python has a special syntax to do two things practically at the same time. Should we still count that as a single line?
Then there's the 11-13 combo, where three lines represent what would normally be two (as "def aug(u):" should be in a separate line from the rest), and create a lambda function inside the aug function while using the list comprehension syntatic sugar to fit a whole loop (which would normally be a couple lines long) into that single return instruction.
IMO the line counting in this code is just bullshit; Python has too many shortcuts to strive from the standard algorithmic code line, making the competition unfair. And if we get into bytes used, Python is too verbose (as for the logical operators which use keywords instead of symbols and the need of whitespace) to compete with Perl and other more compact languages.
Re:Reported last month (Score:2, Informative)
Re:Perl golf goes by the byte (Score:2, Informative)