P2P In 15 Lines of Code 418
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."
P2P only works if there are other peers (Score:2, Insightful)
P2P Does Not Break the Law (Score:3, Insightful)
People Do
Re:Not a good true complexity issue. (Score:5, Insightful)
Re:Not a good true complexity issue. (Score:5, Insightful)
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.
Re:Not a good true complexity issue. (Score:5, Insightful)
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!
Re:P2P Does Not Break the Law (Score:5, Insightful)
Re:Not a good true complexity issue. (Score:5, Insightful)
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.
Re:Not a good true complexity issue. (Score:4, Insightful)
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.
He could be liable... (Score:5, Insightful)
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.
Re:Not a good true complexity issue. (Score:3, Insightful)
Uh, why? If a person writes a virus in Visual Basic, no one blames Visual Basic (at least, no one outside techies). Yet the virus itself is clearly harmful. The libraries are just a framework for both good and bad apps.
Re:Not a good true complexity issue. (Score:3, Insightful)
Your "web browser" example is just invoking another program, and so it doesn't do anything unique or application specific.
So when he says "done in 15 lines of code", it means that all the programmer has to do is type out 15 lines of code, and that using libraries for support functions is pretty much a given.
Unless you're a pedantic shithead, of course.
I will grant you that putting multiple commands on one line is cheating, though. However if the symantics of the language allow you to shorthand multiple actions in a single command then it'sa fair game!
=Smidge=
Re:Not a good true complexity issue. (Score:4, Insightful)
Import webserver
Run Webserver
----
What, like this?
#!/usr/bin/env ruby
require 'webrick'
s = WEBrick::HTTPServer.new(
trap("INT") { s.shutdown }
s.start
Re:Not a good true complexity issue. (Score:5, Insightful)
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.
Unlikely? (Score:5, Insightful)
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.
Re:P2P Does Not Break the Law (Score:2, Insightful)
If Michael was editing today... (Score:1, Insightful)
Do all Slashdot editors check the comments for criticism of themselves, or is it only Michael Sims? If so, they must have a heap of free time.
Re:Not a good true complexity issue. (Score:2, Insightful)
A little off topic, but yes, you can -- just put the semicolon in between:
$ python
>>> import os; os.listdir(os.getcwd())
Also, the following is nothing else but the multiple statements carefully hidden by the tuple packing/unpacking:
a,b,c = (blah,lambda x:blah,blah-blah)
I agree with the main point, though.
Re:Size complex? (Score:2, Insightful)
Obviously not. You think Perl is an acronym [c2.com].
BTW, even as a novice Perl developer, I can confirm that repeated use of <> and $_ will add several cm to your manhood.
Mickey mouse does not write the Law (Score:1, Insightful)
Um, what point is this trying to make? (Score:3, Insightful)
I thought the real point of p2p, as in file sharing, was the ability to search many hosts for something, even though you do not know what hosts exist, ideally without even requiring a central server the hosts must register with.
Dan East
Re:Size complex? (Score:3, Insightful)
Both these programs are full of BS (Score:3, Insightful)
Its not about code (Score:1, Insightful)
Until they swallow that simple fact and get out of denial a lot of people are gonna waste a lot of money and time paying for unworkable broken laws.
P2P too efficient and useful to MPAA to destroy (Score:3, Insightful)
Hell, the only reason I can see why Apple's iTunes/Quicktime division isn't all over him already is because they're probably cooking up their own software, service, and hardware on their own.
Re:He could be liable... (Score:5, Insightful)
Hrm... like an operating system that enables file duplication and networking [microsoft.com]?
Re:hrm.. (Score:2, Insightful)
It's dishonest to pretend that they're only going after the people who actually infringe when they are going after software publishers for contributary infringement.
LK
Re:Size shouldn't deter regulation (Score:2, Insightful)
The point is the RIAA's argument in the Grokster case isn't about the fact that people trading filed ILLEGALLY is against the law. Their argument is that P2P programs INDUCE people to break the law, and so should be banned--it's not an attack on the people acting illegally but the MEANS to possibly do so.
To go back to your shoplifting argument, this would be the RIAA arguing that shopping malls have to be banned because they create an environment that makes shoplifting easier. See the problem?
Surprize surprize! (Score:4, Insightful)
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".
Re:Duh factor (me, not you) (Score:1, Insightful)
OMG.
Seriously, don't ever post on developers.slashdot.org again.
Re:Um, what point is this trying to make? (Score:3, Insightful)
Re:P2P only works if there are other peers (Score:5, Insightful)
That's perfect! (Score:2, Insightful)
Can we really free P2P? (Score:2, Insightful)
But it is the hardware part of p2p that is scary. All p2p networks can come down if our broadband providers decide to block the ports normally used for it or to take any other restrictive measure.
The right to digitally communicate and associate, is seriously at risk! I have wrote more extensively about it here: http://slashdot.org/~fccoelho/journal/
Re:He could be liable... (Score:2, Insightful)
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.
Well I am glad I didn't invent speach, written word, copy machines, printing presses, casset tapes, floppy disks, etc etc etc
This could be useful in China (Score:3, Insightful)
P2P is the marijuana of the 21st century (Score:3, Insightful)
Now you have a classic situation where a vague law can be focused on a large group of people for political reasons. Individuals can be selected either randomly or because of their unrelated political activities or beliefs and be fed into the legal machinery for the 'criminal' activity of using P2P.
Given the for-profit corporate prison industry in the USA and the oversupply of greedy lawyers, this looks like a new profit center focused on young people in the same way that the marijuana industry turned out to be extremely profitable for the lawyer-corporate prison coalition.
Make P2P vaguely illegal.
Make it incredibly easy to do.
Select 100 young people at random.
Check for P2P activity.
If yes, offer them a deal:
go to prison for your 'crime'
(the corporate prison makes $30,000 per year)
-or-
pay a $10,000 fine to the RIAA and turn in several friends doing P2P. (keeps the chain going).
-or-
pay a lawyer $20,000 and get probation. ($10,000 goes to the lawyer and $10,000 goes to the judge), along with turning in several friends using P2P.
You can see how this can become very profitable for the lawyers, RIAA, and prison corporations. Each will make sizable bribes (campaign contributions) to politicians to keep the laws against P2P quite strict, in the name of fairness to musicians and artists.
Re:Size complex? (Score:3, Insightful)
In all seriousness, I hate the use of $_, implied or not. (Especially if it's omitted and used as the default variable.) Yes, it makes the code short, and maybe even use slightly less memory, but I prefer to just create a named variable and use those, instead of looking at:
while (<>) {
s/\D+//g;
alarm;
reverse log if (exp);
select pop;
foreach (split
print;
s/\d+/ord.hex.oct/e;
s/\A/-/g; s/\Z/\n/g;
print;
}
}
And trying to figure out exactly where $_ gets garbled, or to even figure out what it's doing. Named variables describe what it is. The more you subtract from that, the more unreadable the code becomes. For God's sake, the language was written by a linguist. It was designed to make programs somewhat English-readable. At least take the time to do that, instead of going off on some golfing powertrip.