Slashdot Mirror


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."

12 of 443 comments (clear)

  1. Reported last month by joeldixon66 · · Score: 5, Informative

    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.

    1. Re:Reported last month by thrift24 · · Score: 5, Interesting

      Molestar uses a very loose defintion of "lines". A line in perl is ussually where the ; is, which in readable code should be at the end of the actual line. I counted 5 ;'s in the first line of Molestar with a briefscan. A brief estimation would tell us Molestar is more like 30 actuall lines. (I don't see why Molestar doesn't just claim to be one line as all of this code, could work just fine in 1 "line" as they define.) I've never used Python before, but I would imagine by looking at the code to TinyP2P that python's lines truely end at the end of the line. So as far as line count is concerned TinyP2P is around half the size as Molestar.

    2. Re:Reported last month by grub · · Score: 5, Funny


      Good tagline for that "New Scientist: Bringing you last weeks Register news through yesterdays Slashdot... Today!

      --
      Trolling is a art,
  2. bet i could write a 15 line by catbutt · · Score: 5, Funny

    dupe checker for slashdot

    1. Re:bet i could write a 15 line by jarich · · Score: 5, Funny
      All slashdot editors have to do is search through their archive

      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! :)

  3. I can do better by krbvroc1 · · Score: 5, Funny

    10 wget http://localhost/warez/\* 20 pause 10 30 goto 10

  4. Re:1 line? by prodangle · · Score: 5, Funny

    Lines cannot be longer than 80 chars - it's the law :)

  5. repost comments! by Anonymous Coward · · Score: 5, Funny

    heres some +5 comments for your viewing pleasure!

    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/gt k-gnutella/gtk-gnutella-0.92.1c.tar.gz`;

    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". ;) http://www.perlmonks.org/index.pl?node=golf [perlmonks.org]

    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

  6. Re:Libraries by LnxAddct · · Score: 5, Insightful

    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

  7. You missed the point. by raehl · · Score: 5, Informative

    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.

  8. Perl golf goes by the byte by tepples · · 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 state that a lower score in bytes is better.

  9. Re:Interesting implementations by peragrin · · Score: 5, Funny

    It's easy you can do it now. Just dump the raw hex of the files into a postscript and print. use a photocopier to make as many copies as you like.

    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.

    --
    i thought once I was found, but it was only a dream.