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.
dupe checker for slashdot
Umm, if I publish a recipe for crack that uses 2 less ingredients than the normal recipe and takes only half the time to make, why would that be a valid argument for making crack legal? Don't get me wrong I think the act is idiotic, but I don't follow Mr. Felton's reasoning here.
I Am My Own Worst Enemy
10 wget http://localhost/warez/\* 20 pause 10 30 goto 10
How does the fact that they're simple to make have any ramifications on whether or not they should be banned? Meth is simple to make, but I don't see anyone using that as excuse to make it legal. "P2P can be simple and written very quickly, so to try to ban or prevent the technology is not feasible." What he fails to mention is that while they may be simple and quick to write, they take months to gather serious steam, giving ample time to stop them, at least from becoming mainstream like bit torrent, Kazaa, or edonkey. It honestly makes no sense. I don't agree that they should be made illegal, but this is not really a decent supporting argument as to why.
Go ahead and call me unreliable; reliable is just a synonym for predictable.
Lines cannot be longer than 80 chars - it's the law :)
Python? That code is so hard to read I thought it was Perl!
your dupe post is da dupe too. ugh.
heres some +5 comments for your viewing pleasure!
t k-gnutella/gtk-gnutella-0.92.1c.tar.gz`;
;) http://www.perlmonks.org/index.pl?node=golf [perlmonks.org]
The point is that a person/entity can create a P2P program with a very small amount of custom code. If someone is going to ban P2P for "inducing" copyright infringement, they'd look stupid for banning a program this small or they'd have to ban the libraries that are used too which is pretty unlikely.
A p2p app is pretty pointless without a network stack but no one counts that as part of the app or supporting code. Don't pick the nits too much.
Umm, you're missing the point. The fact is with commonly available tools, and I'd consider Perl and Python (or Java) with their massive stock libraries "commonly available", one can easily write a p2p app (heck, BitTorrent is written in Python, so I think it's a very valid example).
Hell, by your logic, the following application:
int main(int argc, char **argv)
{
printf("Hello World");
}
is cheating, since I'm using printf, and god knows how complicated that call is, not to mention all the code in the OS to make the text appear on stdout!
Those are both cheating.
Okay, here's p2p in two lines of perl:
#!/usr/bin/perl
`wget http://www.filefront.com/?filepath=/gnutelliums/g
It also uses files, which is totally cheating. Without fi.write(), this guy would have to do a lot more work to have the computer convert a virtual address into the a device real address and accessing the filesystem implementation specific rules to carry out the necessary data and metadata operations to complete the task. And thats just the half of it.
Do Perl developers have some kind of reverse size-compensation complex?
Anything you can do I can do smaller?
It's commonly referred to as "golf".
I have just created a zero line P2P program which I have entitled "Walking to the Neighbor's House to Borrow a Movie".
I could be evil and patent it, but I have decided to release it under the GPL.
I have discovered a truly marvelous demonstration of P2P that this margin is too narrow to contain.
--Fermat's Second-to-Last Conjecture
I've added some new features to your wonderful program, which I too am releasing under the GPL. I call it:
"Breaking in to the Neighbor's House to steal a Movie".
Oh yeah, I got it in 2 lines of shell: (Score:5, Funny)
by Anonymous Coward on Wednesday December 15, @01:10PM (#11096822)
#!/bin/bash
### ToDo: Write P2P app here
There goes my argument that Python promotes readable code....
Matthew Scala, a reader of Freedom to Tinker, has responded with the 9 line MoleSter, written in Perl.
There have been discussions recently about potential employers doing a Google search on job applicants, so the way I see it Mr. Scala's either very smart or very stupid.
Very stupid, for the fact a lot of searches will put "Matthew Scala" and "molester" together on the same page.
Very smart, because this tactic will bury any evidence of his pedophilia under a pile of MoleSter links and pages.
=P
--
± 23 dB
I don't understand this. Yeah, it's pretty cool to write a fifteen line P2P app, but just because the concept is simple to implement doesn't mean it's unworthy to ban. Not that I'm arguing for banning P2P apps, I'm just critiquing the logic used here. It's also fairly easy to write a simple virus or trojan. Should law enforcement give up pursuing computer criminals who write viruses and such as a result? Better put: shouldn't the amount of damage to society be the valuation for enacting a ban or chasing criminals, not the ease with which criminals obtain or create their tools of trade? Maybe his original statement was taken out of context or more nuanced than the quoted text... --M
In that case, next time you write a hello world program, make sure you write a custom OS with it and don't forget the thousands of drivers you'll need. Sharing or reusing code is a common and necessary practice.
Regards,
Steve
Quite. But the implication of the article is that the code is trivial because it takes so few lines to write. I could easily write a fast fourier transform program in just a few lines by linking to FFTW, but that doesn't mean that FFT is trivial.
flossie
Write now. Defend liberty
POOR ANALOGY ALERT:
The nearest analogy I can think of is Prohibition. You can make alcohol illegal and you can punish people for making it or selling it or drinking it, but there are a lot of people who want to drink and alcohol is VERY easy to make. So every time you close down one source another pops up. There is a demand and you can't control the supply because anyone with enough time can create a new supply.
Now feel free to argue the inappropriate nature of my analogy. Have fun!
I don't think, Therefore I'm not.
I wrote a 2 line p2p app in python:
import modified_tinyp2p, sys
modified_tinyp2p(sys.argv[1])
dependent libraries? what dependent libraries?!
In response to development of the World's shortest P2P Application, the RIAA has weighed-in with the World's shortest lawsuit, coming in at a mere 2 lines:
#1 You are fucked.
#2 See you in court.
Indy Media Watch-Proctologist of the Internet
Of course, there are other interesting implementations out there. IIRC, there used to be a web server that was written entirely in Postscript. Although not written in Postscript, one of the early rivals to X - InterViews - used Postscript as the graphics language.
The winner of the 50th Anniversary of the Manchester Mk. 1 programming contest was a program written in something like 20 words of assembly a programmable timer for chicken soup. (When you consider that the assembly language for the MM1 had 8 instructions, no add operation, and no real-time clock, that's not bad going.)
It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
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
Machine language, the bytecode form of assembly language that microprocessors interpret, doesn't really have "lines" either. The point isn't that MoleSter is 6 lines as much as it is 466 bytes, and programming golf rules state that a lower score in bytes is better.
I thought all you had to do was install Windows unpatched and it became it's own P2P program sharing worms & the such with clients all around the world.
Perl and python are both interpreted HLLs ... so your "466 bytes" of source code is no more intrinsically meaningful a measure than the number of lines in either program
The existence of MoleSter proves that Perl is 466 bytes away from being a P2P program, that in order to ban decentralized search (the key point of P2P file sharing), you'd almost have to ban Perl itself.