{"id":70,"date":"2004-12-21T22:11:08","date_gmt":"2004-12-21T22:11:08","guid":{"rendered":"http:\/\/gaisan.com\/wordp\/?p=70"},"modified":"2004-12-21T22:11:08","modified_gmt":"2004-12-21T22:11:08","slug":"p2very-smallp","status":"publish","type":"post","link":"https:\/\/gaisan.com\/blogs\/?p=70","title":{"rendered":"p2(very small)p"},"content":{"rendered":"<p>This is getting ridiculous. Following my <a href=\"http:\/\/www.gaisan.com\/blogs\/archives\/2004\/12\/index.html#a000062\">recent post<\/a> about Ed Shelton&#8217;s P2P program in 15 lines of Perl there&#8217;s been a P2P app done in 9 lines of Perl and now <i>(wait for it)<\/i> a full peer-2-peer application in <a href=\"http:\/\/groups.google.ca\/groups?selm=32daf0F3ks5ivU1%40individual.net\">6 lines of Ruby<\/a> with a 3 lines of comments.<br \/>\nJust to show everybody how nuts this has become the code is reproduced below&#8230;<br \/>\n<code># Server: ruby p2p.rb password server server-uri merge-servers<br \/>\n# Sample: ruby p2p.rb foobar server druby:\/\/localhost:1337 druby:\/\/foo.bar:1337<br \/>\n# Client: ruby p2p.rb password client server-uri download-pattern<br \/>\n# Sample: ruby p2p.rb foobar client druby:\/\/localhost:1337 *.rb<br \/>\nrequire'drb';F,D,C,P,M,U,*O=File,Class,Dir,*ARGV;def s(p)F.split(p[\/[^|].*\/])[-1<br \/>\n]end;def c(u);DRbObject.new((),u)end;def x(u)[P,u].hash;end;M==\"client\"&amp;&amp;c(U).f(<br \/>\nx(U)).each{|n|p,c=x(n),c(n);(c.f(p,O[0],0).map{|f|s f}-D[\"*\"]).each{|f|F.open(f,<br \/>\n\"w\"){|o|o&lt;&lt;c.f(p,f,1)}}}||(DRb.start_service U,C.new{def f(c,a=[],t=2)c==x(U)&amp;&amp;(<br \/>\nt==0&amp;&amp;D[s(a)]||t==1&amp;&amp;F.read(s(a))||p(a))end;def y()(p(U)+p).each{|u|c(u).f(x(u),<br \/>\np(U))rescue()};self;end;private;def p(x=[]);O.push(*x).uniq!;O;end}.new.y;sleep)<\/code><br \/>\nI think I&#8217;ve had more than enough of this. Pick a suitably high-level language, use single character variable names and some whacky formatting to exchange a file over a socket and call it P2P. Next someone is gonna write a java programme using SUN&#8217;s JXTA that just inits a class or two, format it all on about 4 lines and say, <b>wow<\/b> it&#8217;s the shortest P2P app ever&#8230; More interesting would be a P2P application written in a declarative language like Prolog or a functional language like Haskell or Hope. Haven&#8217;t done much Haskell programming in a while <i>(damn rusty and for some reason don&#8217;t feel like breaking out the books)<\/i> but prolog looks tempting. Expect a post. I may have to use some file IO\/socket programming but it sounds like an interesting project. I&#8217;ll let readers know how I get on \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is getting ridiculous. Following my recent post about Ed Shelton&#8217;s P2P program in 15 lines of Perl there&#8217;s been a P2P app done in 9 lines of Perl and now (wait for it) a full peer-2-peer application in 6 lines of Ruby with a 3 lines of comments. Just to show everybody how nuts [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/70"}],"collection":[{"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=70"}],"version-history":[{"count":0,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=\/wp\/v2\/posts\/70\/revisions"}],"wp:attachment":[{"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gaisan.com\/blogs\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}