P2P In 15 Lines of Code
nile_list writes "Edward Felten of the very fine Freedom to Tinker has written a 15 line P2P program in Python. From the post on Freedom to Tinker, "I wrote TinyP2P to illustrate the difficulty of regulating peer-to-peer applications. Peer-to-peer apps can be very simple, and any moderately skilled programmer can write one, so attempts to ban their creation would be fruitless." Matthew Scala, a reader of Freedom to Tinker, has responded with the 9 line MoleSter, written in Perl."
Freedom to Tinker has written a 15 line P2P program in Python
Does anyone have a
Trolling is a art,
Do Perl developers have some kind of reverse size-compensation complex?
Anything you can do I can do smaller?
P2P Does Not Break the Law
People Do
...but it only worked with 1 dimension. I'm working on scaling it up, but I'm worried it might get longer.
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?
I'm Matthew Skala, the author of MoleSter, and my name was spelled correctly in the item I submitted about this.
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.
...are dedicated to spyware if its anything like kazaa.
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.
Trolling is a art,
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!
From the webpage: Every time I look at the word "molester" my brain tries to parse it as "mole-ster" instead of the agentive of "to molest", and now I have an excuse to name a piece of software MoleSter, so I'm going to use it.
I think that the RIAA and MPAA are going to get a lot of positive spin when people start reading that they're going after all the MoleSters on the Internets.
"What do you think?" "I think 'What, do you think?!'"
I think you are missing the point. The point isn't that you can write a library called p2p and write a a two line python program:
import p2p
p2p.run()
the point is that using standard built in libaries of these languages you can build a fully working p2p system in a very short amount of code.
I do agree though that 15 lines is a bit misleading, although the python program is not putting multiple statements on one line, you can't do that in python. Instead he has removed all whitespace, put all defs and the following body on one line etc.
Again though, the point *isn't* trying to make a program that is highly "pythonic", it isn't. The point is that using basic libraries that have been in Python for years, you can roll a p2p server in 20 minutes.
Doug Tolton
"The destruction of a value which is, will not bring value to that which isn't." -John Galt
#!/bin/bash
### ToDo: Write P2P app here
I think the point he was trying to make, is that it is too late to ban. Yeah, it would have been more impressive if he had coded it out of 15 lines of 1's and 0's, however, I think showing that you can take a bunch of embedded functions, and write a script that acts as a P2P app is a worthwhile example.
If you are one in a million, then there are six thousand people who are just like you.
But according to this article from a story that was posted on Slashdot yesterday:
But if next July's anticipated Supreme Court ruling in the MPAA/RIAA vs Grokster/Streamcast goes in favour of the movie and music industries, the heat is going to be on any technology, no matter how benign the intentions of its developer, that nevertheless makes piracy possible.
Which is rather stupid and obtuse. If you're trying to pioneer a novel way to transfer data, then it could be used for piracy. Anything that transfers bits and bytes around can be held liable. So setting this precedent is just PLAIN STUPID. How far will *AA go? Let's say this precedent had already been established... then they could go after Brian Cohen. They could hold him responsible for create an application "makes piracy possible, regardless of his benign intentions". This way the *AA could crush anything that they see as a potential threat.
Vivin Suresh Paliath
http://vivin.net
I like
#! /bin/bash
/src/mldonkey/distrib/
cd
# --- start mldonkey ---
./mlnet
Buy Steampunk Clothing Online!
An Indian-American Hindu committed to non-violent thought/speech/action alarmed by the global explosion of radical Islam
Buy Steampunk Clothing Online!
#!/UpperlevelProgrammingLanguage :Port => 80, :DocumentRoot => File.join(Dir.pwd, "htdocs")
Import webserver
Run Webserver
----
What, like this?
#!/usr/bin/env ruby
require 'webrick'
s = WEBrick::HTTPServer.new(
trap("INT") { s.shutdown }
s.start
Why not fork?
It's commonly referred to as "golf". ;)
http://www.perlmonks.org/index.pl?node=golf
I only post comments when someone on the internet is wrong.
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.
While what you say is true, I think you are partially missing the point, because what you say is part of the point.
None of the components included in the Python program are specifically P2P. But each of these components are common, powerful, and widely available; almost every, if not every, mainstream language you can think to name has each of these libraries easily available. This isn't news to Prof. Felten, it's an integral part of his point: These readily available libraries, for which no reasonable grounds can be come up with to eliminate them, are trivially combined into a P2P program.
It is not the same as "import webserver; webserver.run()".
Moreover, there is nothing XML-RPC or HMAC specific about the code, really, and you can't ban all RPC libraries, all hashing libraries, etc.
This isn't really a demonstration of the power of Python or anything, and I think Molester sort of misses that point, though turning it into a Perl Golf contest is cool and nerdy and all. (Besides, Pythonistas like me are generally not impressed with such hyper-concision, since one of the reasons we use Python is readability and maintainablity; as a game it is great fun though.) Prof. Felten's point needs to be understood more like an academic proof that a problem is intractable; reduce the problem to something like the halting problem with a 1-to-1 mapping, and you're done. Here, Ed Felten reduces "P2P" to (taking it generically) a language and OS (absolutely vital, can't be banned without banning computers entirely), networking/communication, a bit of string processing (re is convenient but any turing complete language can do that), and a hashing algorithm which probably isn't even vital to the process.
The point is to show that at the core, P2P can't be banned because there really isn't a "P2P" technology, it is an incredibly simple and straightforward application of the basic capabilities of a computer and a network connection. It has already been shown a rough equivalent can be written in Perl, and any number of others will probably pop up now. Languages like C++ or Java probably can't get down to 10 lines, but they will still be simple programs as programs in those languages go.
Until it's required to have DRM in the OS... And, bans on malicious code... Perhaps a ban on compilers...
Unlikely isn't the word I'd use when we have people who have no clue as to what they're talking about. They'd think they were banning viruses!
Moderate funny ha ha.
Our lawyers are currently perfecting a new TinyLawsuit specifically to defeat your invention. You will like it- Only _10_ lines of legalese!
The ball is now in your court, Mr. Felten!
Regards, The RIAA/MPAA
There goes my argument that Python promotes readable code....
"First you gotta do the truffle shuffle."
Both these programs remind me of the obfuscated C program contest of years ago. They put multiple lines of code on one text line and use cryptic variable names to save space. They try to be cute to be small. Let's see how small a program can really be written if it is written in a decent style understandable by all. Not everyone knows the more arcane python and perl syntax. But a competent programmer could decipher it if written in a good style. The comment that "any moderately skilled programmer can write one" is BS if it has to be written so cryptically that only the interpreter/compiler can decipher it.
I guess the people who wrote them are "appers" or "scripters" or "serverers" or "clienters". Certainly not "programmers", since they're not writing "programs".
OK, I'll stop now. I'm sure you've had the error of your ways pointed out many times. It's OK to make a mistake; what I'm really amused by is the fact that your post has been modded "Interesting".
The CB App. What's your 20?
If you'd read Skala's website, you'd see he already addresses your weak argument:
You're using Socket.pm, and it's huge, that's cheating!
Read the fucking code. I'm only using Socket.pm for its defined constants (such as SOCK_STREAM). I could easily eliminate Socket.pm, and save probably another 20 bytes or so, by replacing those constants with the numbers they represent; I have not done so yet only for portability's sake - it might make my code Linux-specific and I'd like to avoid that.
"Truth is not decided by majority vote" consensus gentium -- Norman Geisler
no one blames Visual Basic
Believe me, VB has ALOT to answer for.. *shakes fist*
"So there he is, risen from the dead. Like that fella, E. T." - Father Ted Crilly
Do the words 'proof of concept' mean anything to you?
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
± 29 dB
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! ;-)
myU, prs, srv = ("http://"+ar[3]+":"+ar[4], ar[5:], lambda x:x.serve_forever())
# tinyp2p.py 1.0 (documentation at http://freedom-to-tinker.com/tinyp2p.html)
import 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
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"))