World's Shortest P2P App: 15 Lines
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."
The 15 line P2P has been mentioned before by Slashdot - but the New Scientist article wasn't mentioned last time (as it hadn't yet been written).
The last article also mentioned the 9 line Molestar written in Perl - which is now 6 lines.
The point is, these are standard Python libs.
You don't need to install external third-party libraries for this app.
World's Shortest P2P App: 15 lines just over the middle of the page.
>> excluding libraries.
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
http://request-header.info
./ subscribers can preview articles.
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.
94% of Repubs and 21% of Dems voted to renew the Patriot Act
The point isn't how trivial (or not) a complete P2P solution is.
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.
paintball
However, if that little app becomes as popular as Kazaa or BitTorrent, you can bet they will be gunning for your program; they won't care if it is 15 lines or 150000 lines.
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."
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 goes even deeper, threatening that the Perl interpreter is under half a kilobyte away from being a P2P app as well.
Does anyone want to enlighten me as to how a 15 line P2P app means that it is pointless and silly to ban them?
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.
Craft Beer Programming T-shirts
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.
This argument is either sophistry or stupidity. Perl and python are both interpreted HLLs (although both can also be compiled), so your "466 bytes" of source code is no more intrinsically meaningful a measure than the number of lines in either program: the relationship between bytes of source code and bytes of machine language in this case isn't even in the remote vicinity of 1:1, nor do I know of any simple means to compare the efficiency of perl and python in terms of size of bytecode to size of source code -- or for that matter the runtime overhead incurred by either interpreter.
SIERRA TANGO FOXTROT UNIFORM