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].
Re:Reported last month (Score:4, Funny)
Re:Reported last month (Score:5, Funny)
Good tagline for that "New Scientist: Bringing you last weeks Register news through yesterdays Slashdot... Today!
Re:Reported last month (Score:5, Interesting)
Perl golf goes by the byte (Score:5, Interesting)
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 [xs4all.nl] state that a lower score in bytes is better.
What-U-Ban (Score:4, Insightful)
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.
Re:What-U-Ban (Score:4, Funny)
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:Reported last month (Score:5, Funny)
Yep.. here's my own implementation of Microsoft Word in one line... In C! Unfortunately it doesn't work on Linux.
main() { system("msword.exe"); }
Re:Reported last month (Score:4, Interesting)
This (I'm fairly sure...it's been a few months since I've coded up some Perl) prints out 'omg line' for each line (every time, because the
You can have multiple statements on one line.
Interesting implementations (Score:5, Interesting)
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.)
Re:Interesting implementations (Score:3, Funny)
Of course, there are other interesting implementations out there. IIRC, there used to be a web server that was written entirely in Postscript.
So, when can I use filesharing on my Laserjet 4000TN?
Re:Interesting implementations (Score:5, Funny)
then hand them out. end users use OCR and their scanners. reassemble the files by hand.
Warning large files may use lot's of paper.
Re:Interesting implementations (Score:3, Interesting)
Now if you were to use 600x600 DPI, 2 sides of the paper, you'd get 8MB on a single sheet of paper. An optical 2400x2400 scanner should be sufficient to correctly "read" the 600x600 format.
Assuming you can recognize about 16 shades of gray on a paper, you now get (2^4=16, so 4x) 32MB on a single sheet.
Assume you can do the same for the CMY colors too and you have 128MB on a sheet.
I'
Re:Reported last month (Score:2, Insightful)
No, I don't believe this is the "death of slashdot or anything silly like that." But it is conceivable that in that that glorious mound of slashdot web code there could be a way to check the relevant links in the current article against the laready existing articles within the past
Re:Reported last month (Score:3, Funny)
bet i could write a 15 line (Score:5, Funny)
Re:bet i could write a 15 line (Score:2)
Re:bet i could write a 15 line (Score:2)
All slashdot editors have to do is search through their archive to see if there are any similar stories. It wouldn't be difficult to automate.
Re:bet i could write a 15 line (Score:2)
It wouldn't be difficult to automate.
Really? How? Computers have a really hard time parsing human language, and comparing two paragraphs to see if they are about the same subject would be quite difficult. If you could write a program to do that well you'd be a billionare.
The computer could check URLs, but often the URLs in dupe stories are different then in the original story.
Re:bet i could write a 15 line (Score:3, Informative)
Re:bet i could write a 15 line (Score:2)
The editors could do this by hand, and in this case a computer could have caught "15 lines" and "p2p" if it could figure out that those were the keywords...
Now, why is "30 Years of Adventure: A Celebration of D&D" in the results page for "world's shortest p2p app: 15 lines"
Re:bet i could write a 15 line (Score:2)
In this case all the editor would have had to have done is run this slashdot like this [slashdot.org]. When I said it would be easy to automate what I meant was that every time a story is posted a search is automatically run so the editor can check if the story has already been posted.
Re:bet i could write a 15 line (Score:2)
Re:bet i could write a 15 line (Score:2)
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:5, Funny)
Exactly. To wit:
Piece of cake!Re:bet i could write a 15 line (Score:2)
a checker that required human interaction would at least be easy to write, one that would check for potential dupes(seriously, do the mods even _read_ slashdot? stuff like this is easy to remember even 6 months later that you have read about it, thus it probably being a dupe, so you should check....).
Re:bet i could write a 15 line (Score:2, Interesting)
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.
Re:bet i could write a 15 line (Score:3, Funny)
Re:bet i could write a 15 line (Score:3, Funny)
Re:bet i could write a 15 line (Score:5, Funny)
Have you ever tried to find anything on /. with the built in search engine?
Heck, for all we know, the editors ~are~ looking, but the search engine tells them it's a new article!
It's a joke! Laugh! :)
Easier = should be legal? (Score:5, Insightful)
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.
Re:Easier = should be legal? (Score:4, Insightful)
Re:Easier = should be legal? (Score:5, Insightful)
Its the illegal use of your recipe, or the improper use of the p2p that should be dealt with, not the technology ( or information, in your example )..
Re:Easier = should be legal? (Score:2, Insightful)
Re:Easier = should be legal? (Score:2)
Re:Easier = should be legal? (Score:2, Insightful)
Re:Easier = should be legal? (Score:2)
I strongly agree that there are some really great applications for P2P. For example, what if there was a P2P program that would help teachers trade lesson plans and teaching materials (i.e. not materials from a publisher, but materials created by a teacher who chooses to share them). I could imagine that such a system could help find lessons by subject, grade level, what text book it might supplement (or not).
My point is not t
Re:Easier = should be legal? (Score:2, Interesting)
Re:Easier = should be legal? (Score:3, Insightful)
Re:Easier = should be legal? (Score:3, Insightful)
Probably not. Then again, if you published a simple to follow recipe for making crack using nothing but commonly available household items one would have to question the point of banning crack - giving the difficulty in enforcing such a ban. Which is the point.
Jedidiah.
Re:Easier = should be legal? (Score:3, Insightful)
Actually, yes, if the simplification of the method makes the law significantly less enforcable.
Unenforcable laws should be removed from the books and moved from the province of laws to the province of morals. If you can't stop them when they do it, or have a good chance to catch them when they do, it's time to stop polici
Libraries (Score:2, Insightful)
15 lines of code, but linking to libraries that do much of the hard work.
Re:Libraries (Score:5, Insightful)
Regards,
Steve
Re:Libraries (Score:4, Interesting)
You know what happens when you don't totally reinvent a chunk of code but instead write a chunk of code suited directly to your specific goals? The file size shrinks and it does only what you want it to. Sounds good to me.
For a look at what writing everything from scratch gets you, look at this demo:
http://www.pouet.net/prod.php?which=482
I
Imagine what Microsoft could do if they rewrote code more often to directly suit a certain goal, instead of just building up on top of what they already have. I want the next release of Windows to have a *smaller* footprint than XP. heh.
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:Libraries (Score:2)
httpd myServer = httpd(80)
myServer.start();
Easily done in C and C++ too, libhttpd.so, etc. Look at all the good stuff included in the GNOME and KDE environments. No reason to reinvent the wheel if you dont need to.
Re:Libraries (Score:5, Insightful)
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.
Re:Libraries (Score:2, Funny)
I start every coding project with 50 tons of sand, some plastic, some iron ore, and a few other items including zinc.
Re:Libraries (Score:2)
Iron ore? Luxury. When I was a lad, we had to dig t'ore out of t'mines with our bare hands; and pay mine owner t'work there. And when we got home ...
P2P (Score:3, Insightful)
Why TinyP2P when you have MoleSter (Score:3, Interesting)
MoleSter [sooke.bc.ca]
I can do better (Score:5, Funny)
Thank god! (Score:3, Funny)
Re:Thank god! (Score:2)
Re:Thank god! (Score:2)
Instead of talking about the repost (Score:2, Funny)
How does this prove anything? (Score:3, Insightful)
Re:How does this prove anything? (Score:4, Insightful)
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!
Re:How does this prove anything? (Score:2)
And believe me, there is nothing I like more than pointing out flaws in poorly designed analogies.
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
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.
Something else new (Score:2)
I apologize for blatant whoring.
Eh? (Score:4, Insightful)
Re:Eh? (Score:2)
It's about like the gun analogy. P2P doesn't violate copyright. People with P2P apps violate copyright. Just because something CAN be used to break the law doesn't mean it WILL be, and should therefore be banned.
p
Re:Eh? (Score:3, Interesting)
No, but it is one of the reasons that it's a "social infection" that's damn hard to stamp out.
Same with pot. It's a weed, fer chrissakes. It'll find a way to grow through concrete, and in areas where other plants will die. It's practically impossible to eradicate it (until we've got nanotech, but even then I think it would be foolish to attempt; once we have nanotech, there'll be much easier ways to achieve a hig
Shortest lawsuit... (Score:2, Funny)
Re:Shortest lawsuit... (Score:2)
and it still will be 15 pages of double-spaced type
how come no one (Score:3, Funny)
Python? (Score:4, Funny)
Re:Python? (Score:3, Insightful)
My guess is that most of the functionality of the code is in the standard libraries imported at the begining: SimpleXMLRPCServer, xmlrpclib
They could have just as well imported "p2p_lib" if such a thing existed.
The Dr. Said it best (Score:2)
Just because it can be done, doesn't mean you should.
repost comments! (Score:5, Funny)
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
Re:repost comments! (Score:3, Funny)
#!/bin/sh
wget http://www.filefront.com/?filepath=/gnutelliums/g
You'll notice that it weighs in at significantly fewer bytes than your original Perl program.
Re:repost comments! (Score:3, Funny)
#!/bin/sh
wget http://tinyurl.com/3t8mj
Faulty logic (Score:2)
Easy to write therefore ridiculous to ban? (Score:5, Insightful)
Re:Easy to write therefore ridiculous to ban? (Score:2)
The logic is more along the lines of the government attempting to ban salt. You really cannot ban something that is totally beyond your ability to control.
Re:Easy to write therefore ridiculous to ban? (Score:3, Insightful)
Further, you might note that it's not a crime to teach someone how to write a virus, or even a crime to give people virus code, it is only criminal when the recipients of the virus are unwilling to receive it.
Silly (Score:2)
My question is, what is with this need for geeks to "prove" something is innocuous based on the number of lines of code? It's just so stupid. Viruses are easy to write, too (I'm sure someone can do it in 15 lines), but that doesn't mean we shouldn't make those illegal.
Makes me weep for the future when I see college professors being so blind to what the real issues are here.
Re:Silly (Score:2)
Why not just ban TCP/IP networking, and IPX (just in case)?
The application is not the problem. Jackasses trading in copyrighted material is. Get over it.
A more legible version of tinyp2p.py (Score:5, Informative)
# lines isn't important.. (Score:3, Insightful)
Reminds me of a much simpler day on the web (Score:2)
Can you even boot a modern OS with less than 1 MB ram these days ?
Re:Reminds me of a much simpler day on the web (Score:2)
I don't want to brag but... (Score:5, Funny)
import modified_tinyp2p, sys
modified_tinyp2p(sys.argv[1])
dependent libraries? what dependent libraries?!
p2p/drugs analogy (Score:2)
By this reasoning, you could also argue that manufacturing illegal drugs is also too easy and outlawing them is pointless and silly. Oh wait..it is
Re:p2p/drugs analogy (Score:2)
That's nothing...it's one line in bash (Score:2)
RIAA Response (Score:5, Funny)
#1 You are fucked.
#2 See you in court.
466 bytes, no outside libraries (Score:3, Interesting)
Re:Speaking of dupes... (Score:2, Funny)
Re:1 line? (Score:2)
Re:1 line? (Score:5, Funny)
Re:1 line? (Score:4, Funny)
Re:1 line? (Score:5, Funny)
No... (Score:2)
Re:Duplicate... (Score:5, Funny)