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."
MoleSter
Your hair look like poop, Bob! - Wanker.
$/=$_;$,=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}
http://ansuz.sooke.bc.ca/software/molester/
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.
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.
Maybe before articles are released to the general public, it should be pre-released to a "dupe checking" circle of readers... :)
The friendliest digital photography forums on the net!
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)
It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
As we saw when the courts tried to ban DeCSS, the code was printed onto t-shirts.
I can see P2P becoming the next DeCSS in the eyes of the courts and receiving similar treatment.
So when can I expect my shirt?
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.
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.
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."
t '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!
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.
Reinvent the wheel only at either a lower cost, greater effectiveness, or your own personal enrichment and satisfaction.
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.
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.
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.