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

6 of 443 comments (clear)

  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. 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 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?
  3. 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.

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