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

78 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 nxtr · · Score: 4, Funny

      Maybe New Scientist editors read Slashdot for their news, which then Slashdot user read for more news. I wouldn't be surprised if I saw this article in New Scientist next month.

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

    3. Re:Reported last month by dcarey · · Score: 2, Insightful

      The REALLY sad part is that I don't read slashdot but maybe twice a week on average and ever *I* remember the dupe story ... the link color is already darkened from where I visited precisly the same link the the very short past.

      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 yada yada yada, such that the "TinyP2P" link would be automatically flagged since it was referenced a short while ago. That way, editors can double check for dupes. I bet you could even do it in 15 lines (har har, hardy har har, har).

      Or mebbe use teh "search feature."

      keke.

      --

      -- (Score:i , Imaginary)

    4. Re:Reported last month by Seumas · · Score: 3, Funny

      Did anyone else initially pronounce "Molestar" the same way I did, before realizing it was "molestar" as in the burrowing rodent and the heavenly object?

    5. Re:Reported last month by shellbeach · · Score: 4, Informative

      Molestar uses a very loose defintion of "lines" ... So as far as line count is concerned TinyP2P is around half the size as Molestar.

      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 for more of the author's thoughts on the matter of sizes - they're quite interesting.

    6. Re:Reported last month by Fishstick · · Score: 2, Interesting

      well, then 'lines' would be pretty meaningless as a measure of code complexity/simlicity. When I hear about how many 'lines of code', I might reasonably assume one 'statement' (whatever that is) to occupy one or more lines, not how many statements one can cram on together before a cr/lf without any whitespace within a given screen width.

      Hey, I like compact perl scripts as much as the next guy. I've done some fun things in "one line", and part of the appeal is having someone look at it for a couple minutes before going "ah, I see. slick". But I can't see taking something that would be on the order of 30 lines or so of reasonably formatted script and taking out all the white space to fit as much as possible into an 80 column display and claiming it is 3 lines. That doesn't impart any useful information about how compact the code is relative to the task it performs.

      --

      There is much cruelty in the universe, John.
      Yeah, we seem to have the tour map.

    7. Re:Reported last month by BlueCodeWarrior · · Score: 3, Interesting
      To elaborate slightly, (I agree with you), ...

      ...

      ...aww hell, let's use some Perl!

      #!/usr/bin/perl

      #set your input to $_ somewhere in here

      print "omg line\n" if(/.*/);
      print "omg statement\n" while(/[^;]*;/);

      1;


      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 .* is optimized away) and 'omg statement' for each statement. A line is whatever (though usually considered less than 80 columns) up to a newline, and a statement is, well, a statement.

      You can have multiple statements on one line.
    8. 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,
    9. Re:Reported last month by Punboy · · Score: 2, Informative

      Um, sorry but there are no ';' anywhere in the program. It's python, we don't need them unless we are stating multiple code "lines" in a single ASCII line. Perhaps you were referring to the commas, which were not specifying separate strings, but were instead specifying the list of modules to import. Do you not know how to read python code? Or would this seriously take one separate line for each module, thus showing Python is far superior in that aspect?

      --
      If you like what I've said here, and want to read more, go to http://www.krillrblog.com
    10. Re:Reported last month by maunleon · · Score: 4, Funny

      >> TinyP2P is done by an external library

      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"); }

    11. Re:Reported last month by aichpvee · · Score: 2, Insightful
      I know mine are!

      1. Molesting... over-18 consenting Asian girls.
      2. Molesting... over-18 consenting Asian girls in schoolgirl outfits.
      3. Molesting... over-18 consenting Asian girls dressed as Sailor Mars.

      See, now there's something EVERYONE can enjoy.

      --
      The Farewell Tour II
  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 realdpk · · Score: 2, Informative

      World's Shortest P2P App: 15 lines just over the middle of the page.

    2. Re:bet i could write a 15 line by Arngautr · · Score: 2

      Actually it isn't that hard, a few more than 15 but I'll bet I could do it in under 500, excluding libraries.

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

    4. Re:bet i could write a 15 line by cuteseal · · Score: 2, Interesting

      Maybe before articles are released to the general public, it should be pre-released to a "dupe checking" circle of readers... :)

    5. Re:bet i could write a 15 line by Anonymous+Luddite · · Score: 2, Informative

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

    6. Re:bet i could write a 15 line by EnronHaliburton2004 · · Score: 2, Informative

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

    7. Re:bet i could write a 15 line by lukewarmfusion · · Score: 2, Funny

      Yeah, and we could use a meta-dupe-checking group to ensure that the dupe-checkers were honestly and accurately checking for duplicates. And it would be a real success, just like the other checks and balances here on Slashdot!

    8. Re:bet i could write a 15 line by EnronHaliburton2004 · · Score: 2, Funny

      ok, fine. I owe you a beer.

    9. Re:bet i could write a 15 line by BorgCopyeditor · · Score: 4, Funny
      fails to take into account the level of abstraction the language itself provides

      Exactly. To wit:

      import java.net.p2p.*;
      class Dukester {
      ..public static void main (String[] args) throws IOException {
      ....new java.net.p2p.Client();
      ..}
      }
      Piece of cake!
      --
      Shop as usual. And avoid panic buying.
  3. Easier = should be legal? by nizo · · Score: 4, Insightful
    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.

    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.

    1. Re:Easier = should be legal? by Skepparn · · Score: 4, Insightful

      i follow your point, but i think that his point is that banning ONE program is pointless, since "anyone" (not me though) easily could program a new p2p app..

      --
      ... Disclaimer: I barely know how to Read, please dont expect me to spell right!
    2. Re:Easier = should be legal? by nurb432 · · Score: 4, Insightful

      But the act of publishing your recipe should remain legal. As should the existance P2P apps. I think is the point everyone is making, in their own way.

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

      --
      ---- Booth was a patriot ----
    3. Re:Easier = should be legal? by JustAnotherBob · · Score: 2, Insightful

      The inherent ingredient in Crack, Cocaine, which egal to begin with. A P2P app inheriently is not illegal, but illegal acts can be commited by the use of the application though. The point of making the P2P app in 15 lines of code is to prove that legislation regulating and restricting the development/dissemination of P2P applications would be pointless.

    4. Re:Easier = should be legal? by Class+Act+Dynamo · · Score: 2, Insightful

      But simply using p2p should not be illegal. There are legitimate uses for it. Your argument is like saying crack houses are bad, so let's ban houses.

      --
      My other computer is a Jacquard loom.
    5. Re:Easier = should be legal? by Derekloffin · · Score: 2, Interesting
      I think the real point is how do you enforce such a think meaningfully. The compiler isn't illegal, and if the code is a mere couple lines, you need no real expertise to code one, a simple internet search could easily yield a viable codebase. So, any joe shmoe with a text editor, a PC, and the appropriate compiler installed can create a P2P app and replicate it endlessly, not to mention quite easily distribute it too. At that point enforcement of any law banning such apps becomes really difficult to justify.

      However, that said, the same can often be said of viruses, worms, and other malicious software. The only difference I think is the complexity involved, but not being a virus writer I can't really speak to that :P.

    6. Re:Easier = should be legal? by blonde+rser · · Score: 2, Insightful

      I think the point is not that it's just easier but 15 lines impies that it is very easy in which case there might be an argument for making it legal. Your example happens to be the best example I can think of. What if crack could be made with a handful of household ingredients and the method was simple enough that an average person could not only implement it but think it up. Sure crack wouldn't become any less harmful but any law against would be a joke. It would be unenforcable since anyone could make it anytime they wanted in the privacy of their own homes.

      Once something becomes that easy society needs to change its focus to how to integrate it in the least harmful way. In that world crack would become a fact of life. In this world p2p programs are.

    7. Re:Easier = should be legal? by Coryoth · · Score: 2, 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?

      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.

    8. Re:Easier = should be legal? by Ungrounded+Lightning · · Score: 2, 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?

      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 policing and start preaching voluntary behavior change.

      Leaving such laws on the books leads to selective enforcement (down the slippery slopes toward a police state and/or discrimination), massive civil disobedience, disrespect for laws in general (by both the population and the law enforcement perdonnel), more violation of IMPORTANT laws, and more strain on enforcement resources.

      The government should stick to trying to control only those things that meet three criteria:
      They CAN be controlled in a fair manner,
      the general population agrees they SHOULD be controlled, and
      the Constitution gives government the POWER to control them.

      --
      Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
  4. Libraries by flossie · · Score: 2, Insightful
    import sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac

    15 lines of code, but linking to libraries that do much of the hard work.

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

    2. Re:Libraries by flossie · · Score: 4, Insightful
      of course you link in libraries doing lots of work for you. That's what allows modern apps to have many more features.

      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.

    3. Re:Libraries by Neil+Blender · · Score: 2, Funny

      Yes, and as we all know, code reuse is a disgusting practice. As far as your logic goes, perhaps it should have been written entirely in machine language. Even assembler pneumonics obsfuscate the inner workings through abstraction. Please, get a clue.

      I start every coding project with 50 tons of sand, some plastic, some iron ore, and a few other items including zinc.

    4. Re:Libraries by syukton · · Score: 3, Interesting

      In writing a hello world program, all you need is direct access to the framebuffer, which any language worth its salt will provide. Regarding your "thousands of drivers" remark, again, you don't really need all this: just the framebuffer and a screen. You don't need sound or floating point support, just you and the framebuffer. I know you were being a smartass, but everything you need for "Hello World" is in the BIOS, from the character set to interfacing with the framebuffer, and "Hello World" can be accomplished but a few dozen more bytes than there are in the string "Hello World."

      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
      It 's a flythrough of the first level of Descent (remember Descent?) in 4096 bytes, including a MIDI soundtrack. Not 4096k, but 4096 bytes, or 4 kilobytes. 4k. Four K!

      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.

      --
      Reinvent the wheel only at either a lower cost, greater effectiveness, or your own personal enrichment and satisfaction.
  5. P2P by tuxter · · Score: 3, Insightful

    NApster, kazaa, bittorrent, Whatever you use and they then ban will be replaced with another app. There is always someone smarter than the last guy, therefore you will never get rid of P2P altogether.

  6. Why TinyP2P when you have MoleSter by OverlordQ · · Score: 2, Interesting
    Dr. Edward Felten recently posted a piece of code called TinyP2P, which demonstrates how easy it is to create a peer-to-peer filesharing application by doing it in just 15 lines of Python. However, TinyP2P uses a ready-made XMLRPC server library, which seems to me to be taking the easy way out. Here's my response: MoleSter, a non-trivial filesharing application in 6 lines of Perl, using no protocol library more sophisticated than TCP.


    MoleSter
    --
    Your hair look like poop, Bob! - Wanker.
  7. I can do better by krbvroc1 · · Score: 5, Funny

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

  8. Thank god! by ozric99 · · Score: 2, Funny

    I've been waiting for a suprnova replacement for a while!

  9. Instead of talking about the repost by ian+rogers · · Score: 2, Funny

    Why don't you guys just write a 15 line program that checks the first 50 replies to stories, and filter out 49 of them that say anything about it being a repost.

  10. How does this prove anything? by nt7s · · Score: 3, Insightful

    Does anyone want to enlighten me as to how a 15 line P2P app means that it is pointless and silly to ban them? TPTB are not going to care if you hack together a little P2P app that you and your buddies use. 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.

    1. Re:How does this prove anything? by anum · · Score: 4, Insightful

      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.
    2. Re:How does this prove anything? by BobPaul · · Score: 2, Informative

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

    3. Re:How does this prove anything? by Coryoth · · Score: 2, Informative

      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.

  11. Re:Speaking of dupes... by Anonymous Coward · · Score: 2, Funny

    I can't wait for all the dupe posts in this story.

  12. Eh? by ZSpade · · Score: 4, Insightful

    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.
    1. Re:Eh? by Thing+1 · · Score: 2, Interesting
      Meth is simple to make, but I don't see anyone using that as excuse to make it legal.

      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 high with far fewer side effects; and it can be maintained indefinitely while being ultra-productive as well).

      --
      I feel fantastic, and I'm still alive.
    2. Re:Eh? by RexRhino · · Score: 2, Interesting

      How easy it is to break the law has a lot to do with should a law be passed. What happens if the government decided to ban oral sex? It wouldn't be very effective, unless the government decided to put cameras in everyones bedroom, and that would cost billions.

      Same thing with p2p. If anyone can whip up a peer to peer in 5 minutes, then it does little good to ban peer to peer. Sure, the government could monitor all bandwidth, have encrypted packets decrypted by supercomputer, have a log of every packet of information going across the internet. But the expense would be more than whatever the percieved economic damage of file sharing is.

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

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

  14. Shortest lawsuit... by dogmatixpsych · · Score: 2, Funny

    And to go along with this the MPAA and RIAA will quickly hit the programmer with the world's shortest lawsuit. It will be written in English.

  15. how come no one by geekoid · · Score: 2, Funny

    has mentioned that this story is a dupe?

    --
    The Kruger Dunning explains most post on /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  16. Python? by Psychor · · Score: 4, Funny

    Python? That code is so hard to read I thought it was Perl!

    1. Re:Python? by Doppler00 · · Score: 2, Insightful

      This is the ugliest, hardest to read python code I've ever seen. How can someone abuse such a wonderful language like this?

      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.

    2. Re:Python? by tepples · · 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 goes even deeper, threatening that the Perl interpreter is under half a kilobyte away from being a P2P app as well.

  17. Re:Duplicate... by thhamm · · Score: 4, Funny

    your dupe post is da dupe too. ugh.

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

    1. Re:repost comments! by hkb · · Score: 2, Funny

      Always the hacker, I've ported your 2 line Perl program to sh:

      #!/bin/sh
      wget http://www.filefront.com/?filepath=/gnutelliums/gt k-gnutella/gtk-gnutella-0.92.1c.tar.gz

      You'll notice that it weighs in at significantly fewer bytes than your original Perl program.

      --
      /* Moderating all non-anonymous trolls up since 2004 */
    2. Re:repost comments! by hkb · · Score: 2, Funny

      Version 2.0:

      #!/bin/sh
      wget http://tinyurl.com/3t8mj

      --
      /* Moderating all non-anonymous trolls up since 2004 */
  19. Easy to write therefore ridiculous to ban? by maynard · · Score: 4, Insightful

    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

    1. Re:Easy to write therefore ridiculous to ban? by mark-t · · Score: 2, Insightful
      A virus is a program that is presumably unwanted by its recipient. A P2P program is unwanted by a small but wealthly and potentially controlling segment of our society that doesn't want _anyone_ to have them.

      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.

  20. A more legible version of tinyp2p.py by dstone · · Score: 4, Informative
    Code is left intact, but here is the whitespace massaged into a more widely-accepted (and readable) convention. You see, Python isn't -that- sensitive to whitespace! ;-)
    # tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html)

    impo rt sys, os, SimpleXMLRPCServer, xmlrpclib, re, hmac # (C) 2004, E.W. Felten

    ar, pw, res = (
    sys.argv,
    lambda u:hmac.new(sys.argv[1], u).hexdigest(),
    re.search)
    pxy, xs = (
    xmlrpclib.ServerProxy,
    SimpleXMLRPCServer.SimpleXMLRPCServer)

    def ls(p=""):
    return filter(
    lambda n: (p == "") or res(p, n),
    os.listdir(os.getcwd()))

    if ar[2] != "client": # license: http://creativecommons.org/licenses/by-nc-sa/2.0
    myU, prs, srv = (
    "http://"+ar[3]+":"+ar[4],
    ar[5:],
    lambda x:x.serve_forever())

    def pr(x=[]):
    return ([(y in prs) or prs.append(y) for y in x] or 1) and prs

    def c(n):
    return ((lambda f: (f.read(), f.close()))(file(n)))[0]

    f = lambda p, n, a: \
    (p == pw(myU)) and \
    (((n == 0) and pr(a)) or ((n == 1) and [ls(a)]) or c(a))

    def aug(u):
    return ((u == myU) and pr()) or pr(pxy(u).f(pw(u), 0, pr([myU])))

    pr() and [aug(s) for s in aug(pr()[0])]

    (lambda sv: sv.register_function(f, "f") or
    srv(sv))(xs((ar[3], int(ar[4]))))

    for url in pxy(ar[3]).f(pw(ar[3]), 0, []):
    for fn in filter(lambda n:
    not n in ls(),
    (pxy(url).f(pw(url), 1, ar[4]))[0]):
    (lambda fi: fi.write(pxy(url).f(pw(url), 2, fn)) or
    fi.close())(file(fn, "wc"))
  21. # lines isn't important.. by dustinbarbour · · Score: 2, Insightful

    It's about file size or byte count. That's it. Why there is such a hoopla over the number of lines I don't know.. It's an arbitray definition.

  22. I don't want to brag but... by revery · · Score: 4, Funny

    I wrote a 2 line p2p app in python:

    import modified_tinyp2p, sys
    modified_tinyp2p(sys.argv[1])

    dependent libraries? what dependent libraries?!

  23. Re:1 line? by Saint+Aardvark · · Score: 3, Funny
    I can do better than that:

    $ su root -c "echo '/ (ro,insecure,root_squash)' > /etc/exports && exportfs -a && iptables -P INPUT ACCEPT && iptables -P OUTPUT ACCEPT"
  24. RIAA Response by Indy+Media+Watch · · Score: 4, Funny

    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

  25. Interesting implementations by jd · · Score: 4, Interesting
    One of the best-publicised (amongst the geek community) protests against the ITAR regulations on encryption was the DES encryption algorithm on a t-shirt. What would be really cool, though, would be to have a P2P on a t-shirt and then have a CCD-based device that could "run" it when you walked into the room. "Me? No, I never loaded the computer with that."


    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)
    1. Re:Interesting implementations by wertarbyte · · Score: 2, 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?

      --
      Life is just nature's way of keeping meat fresh.
    2. 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.
    3. Re:Interesting implementations by beware+of+the+robot · · Score: 2, Funny

      Ok, that's 6,5 lines. Or 2,5 - depending on how we're counting...

    4. Re:Interesting implementations by mwvdlee · · Score: 3, Interesting

      Actually if you were to print out black/white "bits" on an A4-sized paper at 300x300 DPI you could fit rougly 1MB per side.

      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'd like to see if anybody could write a program which could "store" and "read" such information. If it could store about 5-6MB per page it could contain most MP3 files :)

      Talk about sheet music ;)

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
  26. 466 bytes, no outside libraries by hummassa · · Score: 2, Interesting
    At http://ansuz.sooke.bc.ca/software/molester/:
    $/=$_;$,=shift;$w=$a=shift;$k{+shift}=1;socket S,2,1,6;bind S,for(listen S,5;$SIG{ALRM}=\m! (\S+) ([e-i])([^/]*)/!s&&($k{$w=$1}=$,eq$`)&&&$2){alarm 9;(accept(C,S),alarm 0)?read C,$_,1e6:($_="$, $a f".shift)}sub i{}sub t{socket C,2,1,6;$k{$w}&&=(connect C,&a)?print C"$, ".pop:0;close C}sub h{t"$_ i/"for keys%k}sub a{$w=~/:/;pack'CxnC4x8',2,$',split'\.',$`}sub f{$w=$_,t"$1 $3/"for keys%k}sub e{open C,'>',$3;print C $'}sub g{open(C,';&h}
    --
    It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
  27. 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.

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

    1. Re:Perl golf goes by the byte by uhlume · · Score: 2, Informative

      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
  29. Re:1 line? by glassesmonkey · · Score: 4, Funny

    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.

  30. What-U-Ban by tepples · · 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.

    1. Re:What-U-Ban by Anonymous Coward · · Score: 4, Funny

      'bout bloody time too ;-)