<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <title>print "Me" - Home</title>
  <id>tag:www.riffraff.info,2009:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.7.3">Mephisto Noh-Varr</generator>
  
  <link href="http://www.riffraff.info/" rel="alternate" type="text/html" />
  <updated>2009-04-09T16:25:12Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/printme" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2009-04-09:910</id>
    <published>2009-04-09T16:20:00Z</published>
    <updated>2009-04-09T16:25:12Z</updated>
    <category term="google app engine" />
    <category term="java" />
    <category term="scala" />
    <link href="http://feedproxy.google.com/~r/printme/~3/RuOPKD2qdoA/using-scala-with-google-app-engine" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2009/4/9/using-scala-with-google-app-engine#comments" thr:count="0" rel="replies" type="text/html" />
    <title>Using Scala with Google App Engine</title>
<content type="html">
            &lt;p&gt;I just got access yesterday to the new Google App Engine for Java SDK, and I thought it would be fun to check if Scala works on it. &lt;/p&gt;

&lt;p&gt;Well, it does. &lt;/p&gt;

&lt;p&gt;Fow what is worth, I followed the standard procedure outlined in the &lt;a href='http://code.google.com/appengine/docs/java/tools/eclipse.html'&gt;google documentation&lt;/a&gt; and I was able to run my small servlet from eclipse, in java.&lt;/p&gt;

&lt;p&gt;Simple steps to get your scala app on google app engine&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;download the GAE plugin for ecplise&lt;/li&gt;
&lt;li&gt;download, if necessary, the scala plugin&lt;/li&gt;
&lt;li&gt;create a new Google Web app project&lt;/li&gt;
&lt;li&gt;add "scala nature" to the project&lt;/li&gt;
&lt;li&gt;define a new Scala class as an ancestor to the existing servlet, letting the former implement the servlet behaviour&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After this the basic servlet that was managed as the main run configuration from eclipse still worked correctly,  meaning I could run it, stop it and deploy everything correctly. Adding a few other Scala classes still let the thing work nicely. &lt;/p&gt;

&lt;p&gt;At this point, I'd have loved to build a tiny online REPL (at least I know that nothing bad will happen as google took care of the sandboxing) but while I was trying to use the existing &lt;tt&gt;scala.tools.nsc.Interpreter&lt;/tt&gt; class I hit a problem causes by that same sandbox: it seems that the Scala code accesses the file system  (mostly calls to &lt;tt&gt;File.isDirectory&lt;/tt&gt; and similar), and those are caught by the &lt;tt&gt;SecurityManager&lt;/tt&gt; who raises an &lt;tt&gt;AccessControlException&lt;/tt&gt;. Eh, just what I asked for :)&lt;/p&gt;

&lt;p&gt;Probably it is possible to work around this issue somehow, but it seems It would require more knowledge than that I currently have, so I'm leaving it until I have more time and experience. &lt;/p&gt;

&lt;p&gt;For those not interested in using eclipse a nice writeup of the steps necessary to use Scala with GAE are &lt;a href='http://froth-and-java.blogspot.com/'&gt;here&lt;/a&gt;, it is again pretty simple, and it is probably a better approach.&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/printme?a=RuOPKD2qdoA:eScxHPwT3mE:HJ0Xzr5LD4E"&gt;&lt;img src="http://feeds.feedburner.com/~ff/printme?d=HJ0Xzr5LD4E" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/printme?a=RuOPKD2qdoA:eScxHPwT3mE:7-xXWRdcw6c"&gt;&lt;img src="http://feeds.feedburner.com/~ff/printme?i=RuOPKD2qdoA:eScxHPwT3mE:7-xXWRdcw6c" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/RuOPKD2qdoA" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2009/4/9/using-scala-with-google-app-engine</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2009-03-18:907</id>
    <published>2009-03-18T08:02:00Z</published>
    <updated>2009-03-18T08:03:35Z</updated>
    <link href="http://feedproxy.google.com/~r/printme/~3/pAjJTrZ8zdM/seeking-rockstar-programmers" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2009/3/18/seeking-rockstar-programmers#comments" thr:count="0" rel="replies" type="text/html" />
    <title>Seeking Rockstar Programmers</title>
<content type="html">
            &lt;p&gt;Premise:
I just graduated (yay), and so did a friend of mine. The only difference is I already have a job while he's looking for it. 
I never had to look for a job lately, but I did remember some online thingies existed. What I did not remember was the amount of &lt;em&gt;rockstar programmers&lt;/em&gt; required. &lt;/p&gt;

&lt;p&gt;I am linking some offers, cause if I did not you may get a wrong picture. I am not questioning the job offer per se, they may be good and I am in no position to judge. I just wonder what the hell rockstar means. &lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;the leading website builder for bands, is looking for a rockstar RoR developer to join our team on a freelance basis.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(&lt;a href='http://jobs.37signals.com/jobs/4954'&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;They seem to be a music-related company. Oh, I get the joke.&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;company seeking a freelance, part-time, highly productive, jack-of-all trades "rock-star" developer, software architect, systems engineer and DBA to run all of our development, including client-side, server-side, databases and infrastructure.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(&lt;a href='http://jobs.37signals.com/jobs/4874'&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;In this other case though.. I do not? It seem to me massively qualified in everything.&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;.. is seeking a rockstar Interaction Designer to join our growing UX/Product Strategy department &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(&lt;a href='http://jobs.37signals.com/jobs/4922'&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Here again.. what does rockstar mean in this context? Heavy on drugs? Biting off bats' heads? Having a mass of followers? &lt;/p&gt;

&lt;p&gt;It seems that other job boards also have these kind of proposal, for example on career builder&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;Software Product Comp seeks Sr. .NET Rockstar!  &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(&lt;a href='http://www.careerbuilder.com/JobSeeker/Jobs/JobDetails.aspx?IPath=QHKCV&amp;amp;amp;ff=21&amp;amp;amp;APath=2.21.0.0.0&amp;amp;amp;job_did=J8B5K470XH0WV0T72PQ'&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Hell, yeah! I love the bang. &lt;/p&gt;

&lt;p&gt;On monster.com, you can get even more&lt;/p&gt;

&lt;blockquote&gt;
    &lt;p&gt;Rockstar Developers (Java/C++ or .NET!) Sought!!!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;(&lt;a href='http://jobview.monster.com/getjob.aspx?JobID=78905698&amp;amp;amp;brd=1&amp;amp;amp;q=rockstar&amp;amp;amp;cy=us&amp;amp;amp;lid=316&amp;amp;amp;re=130&amp;amp;amp;AVSDM=2009-01-26+09%3a35%3a00&amp;amp;amp;pg=1&amp;amp;amp;seq=1&amp;amp;amp;fseo=1&amp;amp;amp;isjs=1&amp;amp;amp;re=1000'&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;three bangs&lt;/em&gt;, this is what rock is all about!&lt;/p&gt;

&lt;p&gt;Anyway, not only programming jobs in fact. I noticed a "rockstar secretary". I thought for a moment it meant being a secretary for a rockstar, but no, it actually means being able to juggle appointments and phone calls like Mick Jagger.&lt;/p&gt;

&lt;p&gt;At some point, companies that were young, fun and creative (or at least felt so) must have thought that to attract similarly talented people they should use these kind of expressions. &lt;/p&gt;

&lt;p&gt;Well, my tiny suggestion is: please don't.  If you are cool you don't usually need an extra step to look so. &lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/printme?a=pAjJTrZ8zdM:ykR5Ey9LEZU:HJ0Xzr5LD4E"&gt;&lt;img src="http://feeds.feedburner.com/~ff/printme?d=HJ0Xzr5LD4E" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/printme?a=pAjJTrZ8zdM:ykR5Ey9LEZU:7-xXWRdcw6c"&gt;&lt;img src="http://feeds.feedburner.com/~ff/printme?i=pAjJTrZ8zdM:ykR5Ey9LEZU:7-xXWRdcw6c" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/pAjJTrZ8zdM" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2009/3/18/seeking-rockstar-programmers</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2009-01-16:840</id>
    <published>2009-01-16T20:14:00Z</published>
    <updated>2009-01-16T20:53:15Z</updated>
    <category term="life" />
    <category term="polyglot" />
    <category term="python" />
    <category term="ruby" />
    <link href="http://feedproxy.google.com/~r/printme/~3/9nGHQDfxi9Y/life-polyglot-ruby-python" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2009/1/16/life-polyglot-ruby-python#comments" thr:count="0" rel="replies" type="text/html" />
    <title>Life polyglot (ruby,python)</title>
<content type="html">
            &lt;p&gt;&lt;a href='http://dablog.rubypal.com/'&gt;dblack&lt;/a&gt; recently published &lt;a href='http://dablog.rubypal.com/2009/1/14/10-things-to-be-aware-of-in-moving-to-ruby-1-9'&gt;a nice article&lt;/a&gt; about things rubyists need to think about when the long awaited 1.9 release finally appears (plus, &lt;a href='http://dablog.rubypal.com/2009/1/16/son-of-10-things-to-be-aware-of-in-ruby-1-9'&gt;a follow up&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Of course I'm happy of the changes, but I'd like to point out that as of today, 16 january 2009, we are still allowed to play with ruby in a way that is not going to be possible again in the future. 
For example, the following code implements a tiny &lt;a href='http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life'&gt;game of life&lt;/a&gt; engine:&lt;/p&gt;

&lt;pre&gt;
#! dunno how to [python,ruby].pick(random) in sh

ON = 1
OFF= 0
WIDTH          = 40    # WIDTH of "board"
HEIGHT         = 20    # HEIGHT of "board"


"""
# " 
def range(a,b) a...b end
def len(x) x.size end
def sum(x) x.inject{|a,b|a+b} end
def init() Array.new(HEIGHT){[0]*WIDTH} end
def spawn(board, left, top, shape)
"""
end=0
def gets(): raw_input()  
init=lambda :[[0 for x in range(WIDTH)] for x in range(HEIGHT)]
def spawn(board, left, top, shape):
  """
  "
  """
  # puts a new thingy on  board, at position (left, top),
  for y in range(0,len(shape)):
      for x in range(0, len(shape[0])):
          board[top + y][left + x] = shape[y][x]
      end
  end
end

t=init()
n=init()

#blinker
spawn(t,20,12,[[1,1,1]])
#glider
spawn(t,9,3,[[0,0,1],[1,0,1],[0,1,1]])
while 1:
  for y in range(1,HEIGHT-1):
    for x in range(1,WIDTH-1):
      c=sum([t[y-1][x-1],t[y-1][x],t[y-1][x+1],
            t[y][x-1],           t[y][x+1],
            t[y+1][x-1],t[y+1][x],t[y+1][x+1]])
      n[y][x]=OFF
      if c== 2:
        n[y][x]=t[y][x]
      end
      if c== 3:
        n[y][x]=ON
      end
    end
  end
  line = ""
  for y in range(0, HEIGHT):
      for x in range(0, WIDTH):
          if t[y][x]==0:
            line += '-'
          end
          if t[y][x]==1:
            line += 'O'
          end
      end
      line = line + "\n"
  end
  print line, "Life - press button for next generation\n"
  gets()
  t,n=n,t
end
&lt;/pre&gt;

&lt;p&gt;Admittedly, the two effect are not 100% compatible, because python's print behaves differently from ruby's.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why does it work?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Few reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ruby and python syntax are really similar&lt;/li&gt;
&lt;li&gt;Even if nobody uses it, ruby allows a colon after &lt;tt&gt;if&lt;/tt&gt;, &lt;tt&gt;while&lt;/tt&gt; and &lt;tt&gt;for&lt;/tt&gt; statements. Yet, it is forbidden after a function signature definition, so I have to conditionally define the function signature line &lt;/li&gt;
&lt;li&gt;The top block is parsed differently from ruby and python: the latter sees a triple-quoted string, while ruby sees a sequence of normal strings, which are implicitly concatenated. In both cases the other language's code is inside a non used string&lt;/li&gt;
&lt;li&gt;Some additional function definitions, some reordering (no &lt;tt&gt;else&lt;/tt&gt; is possible) and everything works. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, &lt;em&gt;works&lt;/em&gt; for some values of the word, since it executes correctly  with ruby 1.8.7 and python 2.5, which are the two interpreters I have on my box, and it should work with any ruby 1.8.x and python 2.x.&lt;/p&gt;

&lt;p&gt;But this code will not work with either python 3  or ruby 1.9. 
Well, just enjoy this tiny spot in time when we still were allowed to have multilingual code :)&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=4ePDPhXL"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=97BrCLnC"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=97BrCLnC" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/9nGHQDfxi9Y" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2009/1/16/life-polyglot-ruby-python</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2009-01-12:826</id>
    <published>2009-01-12T15:53:00Z</published>
    <updated>2009-01-12T15:58:32Z</updated>
    <category term="parrot" />
    <category term="perl6" />
    <category term="programming" />
    <category term="shakespeare" />
    <link href="http://feedproxy.google.com/~r/printme/~3/rzCtQA7ck7U/writing-a-shakespeare-interpreter-with-parrot" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2009/1/12/writing-a-shakespeare-interpreter-with-parrot#comments" thr:count="4" rel="replies" type="text/html" />
    <title>Writing a Shakespeare interpreter with Parrot</title>
<content type="html">
            &lt;p&gt;During the winter holidays I thought it would be fun to start learning something more about &lt;a href='http://www.parrotcode.org'&gt;Parrot&lt;/a&gt;, and see how hard it would be to write an interpreter using it. &lt;/p&gt;

&lt;p&gt;I thought that it could been nice to try implementing something simple but fun, and so I decided to try with the &lt;a href='http://sheakespearelang.sourceforge.net'&gt;Shakespeare Programming Language&lt;/a&gt; (SPL).&lt;/p&gt;

&lt;p&gt;Shakespeare is a beautiful language, as you can see from the &lt;a href='http://www.bitbucket.org/riffraff/shakespeare-parrot/src/tip/example/fibonacci.spl'&gt;code for printing fibonacci's numbers&lt;/a&gt; and the task proved interesting. Since parrot provides tools to generate a language skeleton it was damn fast to be up and running. &lt;/p&gt;

&lt;h1&gt;Parsing&lt;/h1&gt;

&lt;p&gt;Writing &lt;a href='http://www.bitbucket.org/riffraff/shakespeare-parrot/src/tip/src/parser/grammar.pg'&gt;the grammar&lt;/a&gt; with PGE is pretty easy, for example this is the code to parse constants in the form &amp;quot;a pretty lady&amp;quot; &lt;/p&gt;

&lt;pre&gt;
rule immediate {
  &amp;lt;article&amp;gt;? [&amp;lt;adjective&amp;gt; ]* &amp;lt;noun&amp;gt; {*} 
}
token noun {
  |&amp;lt;positive_noun&amp;gt;
  |&amp;lt;negative_noun&amp;gt;
  |&amp;lt;neutral_noun&amp;gt; 
  |&amp;lt;nothing&amp;gt;
}

token adjective {
  |&amp;lt;positive_adjective&amp;gt;
  |&amp;lt;neutral_adjective&amp;gt;
  |&amp;lt;negative_adjective&amp;gt;
  |&amp;lt;first_person_possessive&amp;gt;
  |&amp;lt;second_person_possessive&amp;gt;
  |&amp;lt;third_person_possessive&amp;gt;
}
&lt;/pre&gt;

&lt;p&gt;(the grammatical parts (nouns, adjectives etc) were easily generated from a script and some wordlists)&lt;/p&gt;

&lt;p&gt;The only problem was understanding that rules and tokens in PGE have the &amp;quot;ratchet&amp;quot; property of never backtracking and that longest-token-matching is (still?) not working in PGE. 
This mean that for example the string &amp;quot;an empty house&amp;quot; would not parse correctly  when the adjective rule is &lt;tt&gt;['a' | 'the' | 'an']&lt;/tt&gt; because 'a' would match and the rule would never backtrack. Some reordering fixed the issue.&lt;/p&gt;

&lt;p&gt;Generating the AST is again pretty easy: you basically associate a callback method in &lt;a href='http://www.bitbucket.org/riffraff/shakespeare-parrot/src/tip/src/parser/actions.pm'&gt;the actions file&lt;/a&gt;  to each rule that you want to transform and use the standard PAST::* classes to generate it, which can be as simple as this&lt;/p&gt;

&lt;pre&gt;
# generating constants
method immediate($/) {
  my $value := 1;
  if $&amp;lt;noun&amp;gt;&amp;lt;negative_noun&amp;gt; {
    $value := -1;
  }
  elsif $&amp;lt;noun&amp;gt;&amp;lt;nothing&amp;gt; {
    $value := 0;
  }
  for $&amp;lt;adjective&amp;gt; {
    # &amp;quot;your&amp;quot; and &amp;quot;my&amp;quot; ignored
    unless $_&amp;lt;first_person_possessive&amp;gt; || 
       $_&amp;lt;second_person_possessive&amp;gt; || 
       $_&amp;lt;third_person_possessive&amp;gt; {
      $value:= $value*2;
    }
  }
  make PAST::Val.new( :value( $value ) );
}

method test($/, $k) {
  my $test := PAST::Var.new(:name('condition'));
  make PAST::Op.new( $test, 
                 $($&amp;lt;sentence&amp;gt;),
                 :pasttype($k)); # $k = &amp;quot;if&amp;quot; or &amp;quot;unless&amp;quot;
}
&lt;/pre&gt; 

&lt;p&gt;The actions file is written in &lt;a href='http://search.cpan.org/~chromatic/parrot-0.8.2/compilers/nqp/README.pod'&gt;Not Quite Perl&lt;/a&gt; which is a pretty basic language although it lacks sme things that would be useful in general IMHO, such list flattening.
If needed though they can be used by associating the NQP classes with classes of another parrot language, such as perl6's or ruby's or lua's. &lt;/p&gt;

&lt;p&gt;Another small issue I had was trying to conflate capture of single and multiple occurrences of a string, such as &lt;/p&gt;

&lt;pre&gt;
|'exit'  &amp;lt;character&amp;gt;**{1} {*} #= exit
|'exeunt' &amp;lt;character&amp;gt; ['and' &amp;lt;character&amp;gt;]+ {*} #= exit
&lt;/pre&gt;

&lt;p&gt;without explicit quantification (&lt;tt&gt;**{1}&lt;/tt&gt;),  the action method would get a scalar reference for the first case and a list reference for the second, and since I cannot write @($character) (NQP does not know about this) I needed an additional conditional in the action code.  By explicitly quantifying I always get a list and everything is nice.&lt;/p&gt;

&lt;h1&gt;The runtime&lt;/h1&gt;

&lt;p&gt;Basic runtime functions can be written using the PIR intermediate representation, a form of high level assembly that knows about objects, namespaces, exceptions and more. Some of &lt;a href='http://www.bitbucket.org/riffraff/shakespeare-parrot/src/tip/src/builtins/base.pir'&gt;the code&lt;/a&gt; is slightly involuted because of the shakespeare language nature: most operations actually refer to both the speaker and the other character currently on stage, but it is usually quite simple to follow&lt;/p&gt;

&lt;pre&gt;
.sub 'enter'
    .param string char
    get_global $P0, char
    unless null $P0 goto fin
    die &amp;quot;no such character in the cast!&amp;quot;
  fin:
    $P0['onstage'] = 1
.end
&lt;/pre&gt;   

&lt;p&gt;I also tweaked a little the &lt;a href='http://www.bitbucket.org/riffraff/shakespeare-parrot/src/tip/shakespeare.pir'&gt;main routine&lt;/a&gt; (autogenerated) to add an additional stage to the compiler. Namely, since I could not set a global &amp;quot;case insensitive&amp;quot; flag for the grammar, I introduced a pre-parsing pass to transform the input in lower case. There are probably better ways to do this, but it seems to work. &lt;/p&gt;

&lt;h1&gt;Testing&lt;/h1&gt;

&lt;p&gt;Obviously, I needed to test this. Parrot provides some tools to manage this, namely checking that the compiler outputs the right things at each stage, or that the program output is the one expected. 
I decided to go through another route, again wonderfully supported, of supporting &lt;a href='http://en.wikipedia.org/wiki/Test_Anything_Protocol'&gt;TAP&lt;/a&gt; natively in the language. &lt;/p&gt;

&lt;p&gt;This means you have test support builtin in the shakespeare language, bringing it up to date to the best software engineering practices. &lt;/p&gt;

&lt;p&gt;This was admittedly extremely easy: I just added some syntax and a couple of runtime functions to print the plan (&amp;quot;1...10&amp;quot;) and
the test result (&amp;quot;ok 2&amp;quot;, &amp;quot;ok 3&amp;quot; etc). Parrot's test harness knows how to manage that and so everything works fine.&lt;/p&gt;

&lt;p&gt;Since I did not want to copy the existing source code I wrote everything from scratch (bar the wordlists) and used the supplied examples as reference. So I also added those to the test suite. &lt;/p&gt;

&lt;p&gt;It seems, though, that parrot's Parrot::Test does not manage program input, so I used a ruby script as a driver. Which gets actually executed from perl, who knows about the &amp;quot;#!/usr/bin/env ruby&amp;quot; header better than me. &lt;/p&gt;

&lt;p&gt;I was trying to port it to perl, but I'm not satisfied with the outcome, I must investigate a bit more&lt;/p&gt;

&lt;h1&gt;Conclusions&lt;/h1&gt;

&lt;p&gt;You can get the code &lt;a href='http://www.bitbucket.org/riffraff/shakespeare-parrot/'&gt;through bitbucket&lt;/a&gt;, and it should work with today's (january '09) Parrot. 
All in all this was fun, people in #parrot and #perl6 are nice and helpful, parrot already offers great support for writing your own language and, well, you should try it too :)&lt;/p&gt;

&lt;p&gt;Oh, and I passed my last university exam. too :D &lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=6ZZyYjj5"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=f0JkhcXR"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=f0JkhcXR" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/rzCtQA7ck7U" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2009/1/12/writing-a-shakespeare-interpreter-with-parrot</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2008-02-22:638</id>
    <published>2008-02-22T10:16:00Z</published>
    <updated>2008-02-22T10:20:54Z</updated>
    <category term="self" />
    <link href="http://feedproxy.google.com/~r/printme/~3/jTuR_QySu50/leaving-in-3-2-1-again" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2008/2/22/leaving-in-3-2-1-again#comments" thr:count="0" rel="replies" type="text/html" />
    <title>Leaving in 3,2,1 (again)</title>
<content type="html">
            &lt;p&gt;So, your host in this place is going to leave you for a while, again. &lt;/p&gt;

&lt;p&gt;Two years ago, it was to move to Hungary, best time of my life. &lt;/p&gt;

&lt;p&gt;This time, it's to move to Galway, Ireland where I'll be working &lt;a href='http://sindice.com/general/about'&gt;with this people&lt;/a&gt; on some cool stuff. &lt;/p&gt;

&lt;p&gt;I'm a bit afraid about finding a home, and I wish I'll not be completely useless in the project, but well, better to try and fail then never try.&lt;/p&gt;

&lt;p&gt;See you, Dear Reader, I can't understand why you're still around this place, but thank you for doing so. &lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=yyTosqka"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=F5Ghnd7h"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=F5Ghnd7h" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/jTuR_QySu50" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2008/2/22/leaving-in-3-2-1-again</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2008-02-18:634</id>
    <published>2008-02-18T21:04:00Z</published>
    <updated>2008-02-21T19:41:31Z</updated>
    <link href="http://feedproxy.google.com/~r/printme/~3/lAhEhq4knuo/both-my-languages-suck" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2008/2/18/both-my-languages-suck#comments" thr:count="1" rel="replies" type="text/html" />
    <title>Both my languages suck</title>
<content type="html">
            &lt;p&gt;Over at &lt;a href='http://unenterprise.blogspot.com/2008/02/tell-us-why-your-language-sucks.html'&gt;desperately unenterprise&lt;/a&gt; there is a nice article about the things the author dislikes about haskell, and an invitation to share your own quirks about your favourite language. 
Well, I almost equally like ruby and python. so here is a double rant.&lt;/p&gt;

&lt;h1&gt;Why ruby sucks&lt;/h1&gt;

&lt;p&gt;First, i can reopen classes but so can the others. It's all nice, and the usual idea that this will make development impossible is dumb, but it's true that it can get annoying. Matz once used to say this could be fixed by namespaces in ruby2 but I haven't heard anything about it in years and I'm not sure it will happen. Meanwhile, I still got the occasional &lt;em&gt;oh, damn why isn't this working?&lt;/em&gt; moments, and it sucks. 
People may remember that nice &lt;a href='http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/153380'&gt;chainsaw infanticide logger maneuver&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Modules as namespaces also suck. They rely on a wrong assumption, that everyone else &lt;em&gt;will&lt;/em&gt; use modules as namespaces, which of course is not always true, so if you happen to use something poorly designed you may end hupo with their &lt;code&gt;User&lt;/code&gt; class conflicting with your. 
Python got it right, namespaces are implicitly defined by files/directories and you have to explicitly import stuff in the current one.&lt;/p&gt;

&lt;p&gt;But not just that, you can also import a single name from a python module. Try that with ruby's &lt;code&gt;require&lt;/code&gt; if you can. You're either forced to split every single method in it's own file, like &lt;a href='http://facets.rubyforge.org/'&gt;facets&lt;/a&gt; does or you impose on the end user namespace pollution.&lt;/p&gt;

&lt;p&gt;And it's not even that namespaces are cheap to define. The usual way is&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;create a &lt;code&gt;foo.rb&lt;/code&gt;main file&lt;/li&gt;
&lt;li&gt;create a &lt;code&gt;foo/&lt;/code&gt; directory&lt;/li&gt;
&lt;li&gt;create many &lt;code&gt;foo/xyz.rb&lt;/code&gt; files&lt;/li&gt;
&lt;li&gt;in every single file define the module
And it gets much worse with nested namespaces. And yeah I know I can do &lt;code&gt;class Module::ClassName&lt;/code&gt; except that then I can't load that single file separately. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(I also dislike the thing about constants being lexically scoped to be fair, but probably it's just my disliking of class variables and the fact that I'd like to use constants for that)&lt;/p&gt;

&lt;p&gt;What is nice about ruby modules is their usage as mixins, and even though I'd like them a bit different they are cool. But so under used. &lt;/p&gt;

&lt;p&gt;The core classes in ruby are so fat that they are almost impossible to subclass. 
Have you ever tried subclassing &lt;code&gt;String&lt;/code&gt; so that you can, for instance have a &lt;code&gt;TextileString&lt;/code&gt;  where you can do substitution without considering the markup? 
You'll never get it right enough, just &lt;code&gt;String#[]&lt;/code&gt; has 7 different behaviors depending on th arguments, and &lt;code&gt;String#[]=&lt;/code&gt; has 8 of them. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Comparable&lt;/code&gt; mixin rocks, everybody loves &lt;code&gt;Enumerable&lt;/code&gt; but go figure how to make an Hash-like or File-like object without subclassing&lt;/p&gt;

&lt;h1&gt;Why python sucks&lt;/h1&gt;

&lt;p&gt;The problems with python are, well, what makes it pythonesque. 
Yeah, I understand why you need to explicitly define &lt;code&gt;self&lt;/code&gt; in a function, I just believe it's dumb and too verbose. But why can't I have a bit of syntax sugar ? Make &lt;code&gt;.foo&lt;/code&gt; be a shortcut for &lt;code&gt;self.foo&lt;/code&gt; ? 
At least that would also enforce the convention!&lt;/p&gt;

&lt;p&gt;Python has such a big set of conventions that are not supported by the language. Do not use global variables, but look, there is a useful &lt;code&gt;global&lt;/code&gt; keyword, even though you have nested namespaces. &lt;/p&gt;

&lt;p&gt;On the other hand, it enforces some ugly conventions, suchs as the avoidance of assignments in conditionals by splitting statements and expressions.
That distinction is so annoying that as time passes more and more things become both. Conditions are statements, so here is also the expression version. Functions are statements so here is the crippled lambda expression. Assignment is a statement so here are a handful of setters that avoid using the evil &lt;code&gt;=&lt;/code&gt; symbol. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;update: sorry, this got published by error, it was still largely incomplete, so I'll juust add some more comments&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A lot of things that I dislike are in the "kernel library" design, and not syntax.  &lt;tt&gt;len&lt;/tt&gt;, &lt;tt&gt;map&lt;/tt&gt; and so do not make the language less OO, I know, but they are ugly and polluting the top namespace, why can't they be made part of proper abstractions?  And I hate not being able to use mutable values as key for dictionaries, even java manages to do that, it should not be that hard. &lt;/p&gt;

&lt;p&gt;Something that I miss syntax wise instead is the lack of a case statemente, especially of a destructuring/pattern matching one. Python people will usually tell you that you just use a dictionary. Yeah, but why I have to? I can remove &lt;tt&gt;else-if&lt;/tt&gt; from the language too, but it does not mean it makes sense. 
case/switch statements are actually a place where the language can provide very useful behaviours once someone get past the C/Java versions of it. Take a look at ruby, SML or Scala. &lt;/p&gt;

&lt;p&gt;And, pet peeve: why I have to type "&lt;tt&gt;:&lt;/tt&gt;" in definitions? the parser does not need that, and come on, it adds nothing readibility-wise.&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=hriSaPI2"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=qECwuEgJ"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=qECwuEgJ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/lAhEhq4knuo" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2008/2/18/both-my-languages-suck</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2007-12-22:478</id>
    <published>2007-12-22T12:20:00Z</published>
    <updated>2007-12-22T12:25:02Z</updated>
    <category term="acts_as_authenticated" />
    <category term="crypto" />
    <category term="rails" />
    <category term="security" />
    <link href="http://feedproxy.google.com/~r/printme/~3/gCTijJ0Jh24/actsasauthenticated-insecure-by-default" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2007/12/22/actsasauthenticated-insecure-by-default#comments" thr:count="8" rel="replies" type="text/html" />
    <title>ActsAsAuthenticated, insecure by default?</title>
<content type="html">
            &lt;p&gt;&lt;a href='http://technoweenie.stikipad.com/plugins/show/Acts+as+Authenticated'&gt;ActsAsAuthenticathed&lt;/a&gt; is probably the most widely used (and deployed) plugin for managing user registration/authentication in a rails application.&lt;/p&gt;

&lt;p&gt;As everything coming from &lt;a href='http://weblog.techno-weenie.net/'&gt;Rick Olson&lt;/a&gt; it's great, giving you a complete authentication system in few steps, with a lot of tweaking points that allows you to make it suitable to your setup. &lt;/p&gt;

&lt;p&gt;But I think the default configuration is a bit insecure. &lt;/p&gt;

&lt;p&gt;Point is, the default encryption routine (done in &lt;a href='http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated/generators/authenticated/templates/model.rb'&gt;#encrypt in model.rb&lt;/a&gt;) uses a SHA1 digest to cypher the password. But SHA1 is designed to be a fast digest function, not a password cypher.  Moreover, the default password length is restricted in the &lt;tt&gt;4..40&lt;/tt&gt; range.&lt;/p&gt;

&lt;p&gt;Thus, supposing a user has a password with the standard characters in the &lt;tt&gt;[_-a-zA-Z0-9]&lt;/tt&gt; range, the number of different combination for an acceptable password is &lt;tt&gt;64^4&amp;lt; 17 milions&lt;/tt&gt;. &lt;/p&gt;

&lt;p&gt;This may seem a lot, but if you think about it is not so much, using a dumb ruby script on my old box I can find all the hashes for this kind of password in about three minutes. Yeah, in ruby, with gc kicking in and everything. Having a salt is of no importance, it just avoids finding multiple passwords at once. &lt;/p&gt;

&lt;p&gt;Now, if you think that there are things like &lt;a href='http://nsa.unaligned.org/'&gt;NSA@Home&lt;/a&gt; that will try &lt;em&gt;all&lt;/em&gt; the possible passwords of 8 characters in one day (&lt;tt&gt;64^8 =~ 3e14&lt;/tt&gt;), this does not sound really secure. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;I'm not a security expert&lt;/em&gt;, but I believe this should not be like that. 
I'd say that to make it a bit more secure you could change the Model#encrypt method to do multiple iterations, say &lt;/p&gt;

&lt;pre&gt;
def self.encrypt(password, salt)
  cypher = password
  1000.times do 
    cypher= Digest::SHA1.hexdigest("#{salt}#{cypher}")
  end
  cypher
end
&lt;/pre&gt;

&lt;p&gt;But even there, I'm not a cryptanalist so I don't know if there is something like &lt;em&gt;"the n iteration of SHA1(string of k elements) may be computed in time O(log(n*k))"&lt;/em&gt;. 
Cryptopeople may do stuff like that, all the time, for what I know.&lt;/p&gt;

&lt;p&gt;So this is basically a question: is AAA slightly insecure by default? 
If that is true, what would you use as the encrypt function?&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=eZkR50tH"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=xkEHkQYj"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=xkEHkQYj" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/gCTijJ0Jh24" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2007/12/22/actsasauthenticated-insecure-by-default</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2007-10-25:352</id>
    <published>2007-10-25T19:55:00Z</published>
    <updated>2007-10-26T13:29:32Z</updated>
    <category term="ecmascript" />
    <link href="http://feedproxy.google.com/~r/printme/~3/fFy06kl09IE/ecmascript-4-the-fourth-system-syndrome" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2007/10/25/ecmascript-4-the-fourth-system-syndrome#comments" thr:count="16" rel="replies" type="text/html" />
    <title>ECMAScript 4, the fourth system syndrome</title>
<content type="html">
            &lt;p&gt;The second system syndrome is that evil effect that often happens when redesign a small, working system so that it becomes a huge leviathan built by piling new features over new features. &lt;/p&gt;

&lt;p&gt;Today I was reading the &lt;a href='http://www.ecmascript.org/es4/spec/overview.pdf'&gt;overview of ECMASCript 4&lt;/a&gt; from ecmascript.org, and I got this very bad feeling that maybe the fourth version of ES, is suffering of an extremely strong case of this problem.&lt;/p&gt;

&lt;p&gt;I believe that part of the success of ES in its current incarnation is that it is quite simple. Yeah, it has its shortcomings and oddities, but in general it is simple enough that everyone can learn it in no time. &lt;/p&gt;

&lt;p&gt;ES4, on the other hand, seems to have included almost everything that came out from programming languages in the last 50 years, save Prolog and APL.&lt;/p&gt;

&lt;p&gt;For example, it has prototypes, interfaces, classes, metaclasses, higher order types and generic functions, which for what I can tell entails all the work ever done on object-orientation (maybe &lt;a href='http://c2.com/cgi/wiki?PredicateClasses'&gt;predicate classes&lt;/a&gt; are missing,  but they may be there too). &lt;/p&gt;

&lt;p&gt;The argument list of a function may have named arguments, rest/variadic arguments, optional arguments, optional types including: non-nullable arguments, &lt;code&gt;like&lt;/code&gt; arguments (this seems the same as in Eiffel, used to link the type of an object to another), &lt;code&gt;wrap&lt;/code&gt; arguments that perform automatic conversion of an object of type X into another of type Y, &lt;/p&gt;

&lt;p&gt;Whereas many languages I know provide a concept of Module or Package to handle namespacing issues, ES4 provides &lt;code&gt;packages&lt;/code&gt; and &lt;code&gt;namespaces&lt;/code&gt; and &lt;code&gt;program units&lt;/code&gt; to support name hiding and modularity. 
Not only this, but you can introduce variables with &lt;code&gt;var&lt;/code&gt; to have it in the object scope or with &lt;code&gt;let&lt;/code&gt; to have it in a block, so even more namespace separation :-) &lt;/p&gt;

&lt;p&gt;Finally, ES4 incorporates some cool features such as list comprehensions, a kind of destructuring assignment/pattern matching, python-like slicing, triple-quotes  and generators (&lt;del&gt;though AFAICT this are only one way generators like in older python releases, where you can yield but you can't receive values&lt;/del&gt; &lt;ins&gt;Thanks to &lt;a href='http://www.neilmix.com/'&gt;Neil Mix&lt;/a&gt; for pointing out that they are complete coroutines, and support bidirectional value passing&lt;/ins&gt;).&lt;/p&gt;

&lt;p&gt;And operator overloading, program pragmas, required tail call elimination, a host of interesting keywords suchy as &lt;code&gt;intrinsic&lt;/code&gt; to reify operators, &lt;code&gt;dynamic&lt;/code&gt; to have classes that allow adding of new fields, &lt;code&gt;static&lt;/code&gt; to have class-level functions, &lt;code&gt;final&lt;/code&gt; to avoid inheritance and &lt;code&gt;override&lt;/code&gt; to use it, &lt;code&gt;internal&lt;/code&gt;, &lt;code&gt;public&lt;/code&gt; and so on. 
And of course, 6 different values of falsity, with &lt;code&gt;NaN&lt;/code&gt;, &lt;code&gt;""&lt;/code&gt;, &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;false&lt;/code&gt;, &lt;code&gt;null&lt;/code&gt; and &lt;code&gt;undefined&lt;/code&gt;, but not &lt;code&gt;{}&lt;/code&gt; and &lt;code&gt;[]&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;ECMAScript 4 seems cool, I want to use a lot of those things (yay for multi method dispatch!), but maybe it is changing the language &lt;em&gt;a little bit too much&lt;/em&gt; . &lt;/p&gt;

&lt;p&gt;How many of the current user of ES in one of its incarnations have ever heard of product types?
Will they grasp at once the logic behind the subtyping relation between functions, with all that &lt;em&gt;covariant&lt;/em&gt; and &lt;em&gt;contravariant&lt;/em&gt; stuff? Will they need it at all? &lt;/p&gt;

&lt;p&gt;I hope the internet pipes will resist to the number of &lt;em&gt;"metaclass vs meta namespace vs prototype vs superclass"&lt;/em&gt; questions on usenet.&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=2RzcB7ey"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=UcDng8CP"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=UcDng8CP" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/fFy06kl09IE" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2007/10/25/ecmascript-4-the-fourth-system-syndrome</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2007-10-07:289</id>
    <published>2007-10-07T15:08:00Z</published>
    <updated>2007-10-07T16:10:23Z</updated>
    <category term="ruby" />
    <link href="http://feedproxy.google.com/~r/printme/~3/1Dds2cKRpas/more-obscure-features-of-ruby" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2007/10/7/more-obscure-features-of-ruby#comments" thr:count="4" rel="replies" type="text/html" />
    <title>More Obscure Features of Ruby</title>
<content type="html">
            &lt;p&gt;First go look at &lt;a href='http://blog.nicksieger.com/articles/2007/10/06/obscure-and-ugly-perlisms-in-ruby'&gt;Nick Sieger's post about strange perlisms in ruby&lt;/a&gt;, cause it may be interesting for you.
But talking about strange features in ruby, I believe there are some that may result even stranger, cause they are not even  inherited from other languages, but are matz' own creation, I believe.&lt;/p&gt;

&lt;h3&gt;super on builtin methods&lt;/h3&gt;

&lt;p&gt;if you're redefining a builtin method you can use &lt;tt&gt;super&lt;/tt&gt; to access the original one:&lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt; def puts(*args)
&amp;gt;&amp;gt;  super(*args)
&amp;gt;&amp;gt;  super(*args)
&amp;gt;&amp;gt; end
=&amp;gt; nil
&amp;gt;&amp;gt; puts 123
123
123
&lt;/pre&gt;

&lt;p&gt;yet if you try with your own:&lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt; def foo() puts "foo" end
=&amp;gt; nil
&amp;gt;&amp;gt; def foo() super end
=&amp;gt; nil
&amp;gt;&amp;gt; foo
NoMethodError: super: no superclass method `foo'
        from (irb):8:in `foo'
        from (irb):10
&lt;/pre&gt;

&lt;h3&gt;super without arguments&lt;/h3&gt;

&lt;p&gt;I knew this feature for long, but never used it in real coding, even if I keep thinking it's handy. &lt;tt&gt;super&lt;/tt&gt;, when used without arguments, passes all the arguments, so the above example would become:&lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt; def puts(a,b)
&amp;gt;&amp;gt;  super
&amp;gt;&amp;gt;  super
&amp;gt;&amp;gt; end
=&amp;gt; nil
&amp;gt;&amp;gt; puts 345, 567
345
567
345
567
=&amp;gt; nil
&lt;/pre&gt;

&lt;h3&gt;The evil context-sensitive while and until modifiers:&lt;/h3&gt;

&lt;p&gt;Can you tell the difference between this two lines?&lt;/p&gt;

&lt;pre&gt;
 puts 'hello' while false
 begin puts 'hello' end while false
&lt;/pre&gt;

&lt;p&gt;Well, the difference is that the latter will print "hello", because the &lt;tt&gt;while&lt;/tt&gt; modifier always does at least one evaluation of the expression when preceded by a &lt;tt&gt;begin..end&lt;/tt&gt; block. The same happens with the &lt;tt&gt;until&lt;/tt&gt; modifier.
Luckily, this evil behaviour is supposed to disappear.&lt;/p&gt;

&lt;h3&gt;do something, handle exceptions.. or else?&lt;/h3&gt;

&lt;p&gt;Did you know that ruby's &lt;tt&gt;begin&lt;/tt&gt; allows the definition of an &lt;tt&gt;else&lt;/tt&gt; clause?
The else clause is actually part of the &lt;tt&gt;rescue&lt;/tt&gt; part of the block,. and is executed whenever an exception is not raised:&lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt; def check(x)
&amp;gt;&amp;gt;  begin
?&amp;gt;   raise if x==2
&amp;gt;&amp;gt;  rescue
&amp;gt;&amp;gt;   "error"
&amp;gt;&amp;gt;  else
?&amp;gt;   "ok"
&amp;gt;&amp;gt;  end
&amp;gt;&amp;gt; end
=&amp;gt; nil
&amp;gt;&amp;gt; check(1)
=&amp;gt; "ok"
&amp;gt;&amp;gt; check(2)
=&amp;gt; "error"
&lt;/pre&gt;

&lt;h3&gt;..and of course, you do not need begin..&lt;/h3&gt;

&lt;p&gt;because, I believe you know this, you can write:&lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt; def check(x)
&amp;gt;&amp;gt;   raise if x==2
&amp;gt;&amp;gt;  rescue
&amp;gt;&amp;gt;   "error"
&amp;gt;&amp;gt;  else
?&amp;gt;   "ok"
&amp;gt;&amp;gt; end
=&amp;gt; nil
&amp;gt;&amp;gt; check(1)
=&amp;gt; "ok"
&amp;gt;&amp;gt; check(2)
=&amp;gt; "error"
&lt;/pre&gt;

&lt;h3&gt;methods with whitespace, yay!&lt;/h3&gt;

&lt;p&gt;I find this quite useful, actually. If you define a method bypassing the ruby parser with &lt;tt&gt;define_method&lt;/tt&gt; you can give it any name you want. &lt;/p&gt;

&lt;pre&gt;
&amp;gt;&amp;gt; class K
&amp;gt;&amp;gt;  define_method("method: hard to get") { 'got!' }
&amp;gt;&amp;gt; end
=&amp;gt; #&amp;lt;proc:0xb768d1b8&gt;
&amp;gt;&amp;gt; K.new.send 'method: hard to get'
=&amp;gt; "got!"
&lt;/pre&gt;

&lt;p&gt;You won't be able to call the method with normal ruby syntax, which makes it less or more useful depending on your problem space. &lt;/p&gt;

&lt;p&gt;And finally, there is a whole slant of strange things that I believe are remnants of matz' experimenting with the language (is &lt;tt&gt;alias $global $other_global&lt;/tt&gt; used somewhere outside of english.rb?), and even if some of them are quite frightening (&lt;tt&gt;if /regex/&lt;/tt&gt; anyone?) they will be phased out, so it's ok. 
If I recall correct ruby also had a glob operator ( &amp;lt;*.c&amp;gt; ) that was killed in the early days, so I trust matz to fix the oddities of the language sooner or later :)&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=KXNExmwH"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=yOODh4J6"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=yOODh4J6" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/1Dds2cKRpas" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2007/10/7/more-obscure-features-of-ruby</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2007-09-19:236</id>
    <published>2007-09-19T21:56:00Z</published>
    <updated>2007-09-19T22:13:07Z</updated>
    <category term="alice" />
    <category term="ml" />
    <category term="spell corrector" />
    <link href="http://feedproxy.google.com/~r/printme/~3/tiy9nmeMxd8/spell-corrector-in-aliceml" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2007/9/19/spell-corrector-in-aliceml#comments" thr:count="0" rel="replies" type="text/html" />
    <title>Spell Corrector in AliceML</title>
<content type="html">
            &lt;p&gt;It seems that writing a spell correcor is becoming my new &lt;em&gt;post hello world&lt;/em&gt; program, so well, after  having this in my hard disk for a while I thought I would publish my new solution, wrote using AliceML.&lt;/p&gt;

&lt;p&gt;I'm really not good at ML, so this code must not be considered a good example of how to code, but I thing it's a good thing to keep track of my learning :)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
import structure MkRedBlackSet  from "x-alice:/lib/data/MkRedBlackSet";
import structure MkRedBlackMap from "x-alice:/lib/data/MkRedBlackMap";

structure Set = MkRedBlackSet String;
structure Map = MkRedBlackMap String;

val wordlist = "/home/rff/wordlist.txt";
val alphabet = String.explode "abcdefghijklmnopqrstuvwxyz";

open List;

fun take2(i1,i2) = (fn cl =&gt; (take (cl,i1), drop (cl,i2)))

fun delete cl i = 
  let
    val (first, second) = take2 (i,i+1) cl
  in
    String.implode (first @ second)
  end

fun deletions cl = tabulate ((length cl), (delete cl));


fun substitute cl i = 
  let 
    val (first,second) = take2 (i, i+1) cl
    fun sub_char c = String.implode (first @ [c] @ second)
  in  
    map sub_char alphabet
  end 

fun substitutions cl =  concat( tabulate ((length cl), (substitute cl)));

fun insert cl i = 
  let 
    val (first, second) = take2 (i,i) cl
    fun ins_char c = String.implode (first @ [c] @ second)
  in  
    map ins_char alphabet
  end 

fun insertions cl =  concat( tabulate ((length cl)+1, (insert cl)));

fun transpose cl i = 
  let 
    val (first,second) = take2 (i,i+2) cl
    val c1 = nth (cl,i)
    val c2 = nth (cl,i+1)
  in  
    String.implode (first @ [c2] @[c1] @ second)
  end 

fun transpositions cl =  tabulate ((length cl)-1, (transpose cl));


fun edits1 word = 
  let 
    val w = String.explode word 
    val ws = deletions w @ transpositions w @ insertions w @  substitutions w
  in 
    foldl (Fn.flip Set.insert) (Set.empty) ws
  end 

fun insertOrUpdate map key = 
  case Map.lookup (map, key) of
     NONE =&gt; Map.insert (map, key, ref 1)
    |SOME value =&gt; (value := (!value +1) ; map)


(* train *)
fun train io =
  let 
    val chop = fn str =&gt; String.substring (str, 0, (String.size str) - 1)
  in
    case TextIO.inputLine io of
       NONE =&gt; Map.empty
      |SOME line =&gt; insertOrUpdate (train io) (chop line)
    end  

val nwords = train ( TextIO.openIn wordlist);

fun known_edits2  word = 
  let 
    fun set_edits set = Set.fold (fn (str,set) =&gt; Set.union (set, known (edits1 str))) Set.empty set
  in
    set_edits (edits1 word)
  end

fun look k = !(valOf (Map.lookup  (nwords, k)));


fun correct word =
  let 
    val candidates = find (not o Set.isEmpty) 
                           [ known (Set.fromList [word]),
                             known (edits1 word),
                             known_edits2 word]
     val sort = sort (fn (a,b)=&gt;Int.compare ((look b), (look a))) o Set.toList
   in
     case candidates of
       SOME words =&gt; hd(sort words)
      |NONE     =&gt; word
   end  

correct "ciao" (*ciao match*);
correct "cao"  (*ciao edit 1*);
correct "mioo" (*miao edit 1*);
correct "miaoo"(*miao edit 1*);
correct "mooo" (*mao  edit 2 max value*);
correct "quux" (*quux no match*);

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The worse part is the string manipulation, I think, and maybe the fact that I use references (aka mutable variables) when building the frequency count Map, but in the end I'm quite satisfied.
Feel free to point out obvious errors, if you see them.&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=h9BEVgJ7"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=6D8Uq0ok"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=6D8Uq0ok" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/tiy9nmeMxd8" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2007/9/19/spell-corrector-in-aliceml</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2007-09-15:193</id>
    <published>2007-09-15T09:42:00Z</published>
    <updated>2007-09-15T09:44:47Z</updated>
    <category term="darcs" />
    <category term="git" />
    <link href="http://feedproxy.google.com/~r/printme/~3/Y4jVs_kPKqg/darcs-pull-vs-git-pull" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2007/9/15/darcs-pull-vs-git-pull#comments" thr:count="0" rel="replies" type="text/html" />
    <title>darcs pull vs git pull</title>
<content type="html">
            &lt;p&gt;I mean, I'm not going to say that you should use $VCS1 over $VCS2, I'm not proficient enough with either. I just think that:&lt;/p&gt;

&lt;pre&gt;
rff@ut:~/ramaze$ darcs pull
Pulling from \&amp;quot;http://manveru.mine.nu/ramaze\&amp;quot;...

Wed Sep 12 14:52:55 CEST 2007  Michael Fellinger &amp;lt;mail@foo.com&amp;gt;
  * Adding path for OSX to tool/tidy and improve readability of the spec for it a bit.
Shall I pull this patch? (1/1)  [ynWvpxqadjk], or ? for help: v
[Adding path for OSX to tool/tidy and improve readability of the spec for it a bit.
Michael Fellinger &amp;lt;mail@foo.com&amp;gt;**20070912125255] {
hunk ./lib/ramaze/tool/tidy.rb 18
+        /usr/lib/libtidy.dylib
hunk ./spec/ramaze/tidy.rb 10
-    Ramaze::Tool::Tidy.tidy(\&amp;quot;&amp;lt;html&amp;gt;&amp;lt;/html&amp;gt;\&amp;quot;).should =~ %r{&amp;lt;html&amp;gt;\\s+&amp;lt;head&amp;gt;\\s+&amp;lt;meta name=\&amp;quot;generator\&amp;quot; content=\&amp;quot;HTML Tidy (.*?)\&amp;quot; /&amp;gt;\\s+&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;\\s+&amp;lt;/head&amp;gt;\\s+&amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;\\s+&amp;lt;/html&amp;gt;}
+    Ramaze::Tool::Tidy.tidy(\&amp;quot;&amp;lt;html&amp;gt;&amp;lt;/html&amp;gt;\&amp;quot;).
+      should =~ %r{&amp;lt;html&amp;gt;\\s+&amp;lt;head&amp;gt;\\s+&amp;lt;meta name=\&amp;quot;generator\&amp;quot; content=\&amp;quot;HTML Tidy (.*?)\&amp;quot; /&amp;gt;\\s+&amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;\\s+&amp;lt;/head&amp;gt;\\s+&amp;lt;body&amp;gt;&amp;lt;/body&amp;gt;\\s+&amp;lt;/html&amp;gt;}
}

Wed Sep 12 14:52:55 CEST 2007  Michael Fellinger &amp;lt;mail@foo.com&amp;gt;
  * Adding path for OSX to tool/tidy and improve readability of the spec for it a bit.
Shall I pull this patch? (1/1)  [ynWvpxqadjk], or ? for help: y
Finished pulling and applying.


&lt;/pre&gt;

&lt;p&gt;is &lt;em&gt;slightly&lt;/em&gt; more clear than:&lt;/p&gt;

&lt;pre&gt;
rff@ut:~/rubinius$ git pull
Fetching refs/heads/master from http://git.rubini.us/code using http
got 2fb92489ed4a0e58ea3d941a6f2ff8c7b8b44c2d
walk 2fb92489ed4a0e58ea3d941a6f2ff8c7b8b44c2d
got 6ae85832a699f3048ee260d9091aacc05c686fe4
got 6c0e0e63c0bb5979e2dd2b3df6e511b031656ef4
walk 6c0e0e63c0bb5979e2dd2b3df6e511b031656ef4
Getting alternates list for http://git.rubini.us/code
Getting pack list for http://git.rubini.us/code
Getting index for pack cf217ebdaa4f745cc827450e9cac23ec258d45f9
Getting pack cf217ebdaa4f745cc827450e9cac23ec258d45f9
 which contains cf987cd736618331bf421603c1491030b0fc8e35

got c77671cc8a43049bd61dd22f13fbbbc1ab4f96ec
... many more.. 
got 933282575047f8924edc6cc426c0a234bdbe16a3
* refs/remotes/origin/master: fast forward to branch \'master\' of http://git.rubini.us/code
  old..new: e85ecf8..2fb9248
Updating e85ecf8..2fb9248

Fast forward
 .gitignore                            |    1 +
 Makefile                              |    2 +-
 bin/sirb.rb                           |    1 -
 compiler/bytecode/compiler.rb         |   22 +-
 compiler/bytecode/primitive_names.rb  |    2 +-
 compiler/bytecode/rubinius.rb         |    1 +
 compiler/bytecode/system_hints.rb     |   20 +-
 compiler/translation/local_scoping.rb |    7 +-
 compiler/translation/normalize.rb     |   24 ++
 compiler/translation/states.rb        |   30 ++-
 kernel/core/compile.rb                |    6 +-
 kernel/core/compiled_method.rb        |    7 +-
 kernel/core/context.rb                |   26 ++-
 kernel/core/io.rb                     |    3 +
 kernel/core/string.rb                 |   91 ++++++--
 lib/bin/compile.rb                    |  176 ++++++++++++---
 lib/bin/sirb.rb                       |   22 +-
 lib/ext/syck/build.rb                 |    6 +
 lib/ext/syck/rbxext.c                 |   12 +-
 lib/stringio.rb                       |  413 +++++++++++++++++++++++++++++++++
 runtime/bootstrap.rba                 |  Bin 29758 -&amp;gt; 29986 bytes
 runtime/compiler.rba                  |  Bin 79208 -&amp;gt; 81314 bytes
 runtime/core.rba                      |  Bin 162952 -&amp;gt; 168854 bytes
 runtime/loader.rbc                    |  Bin 12565 -&amp;gt; 12651 bytes
 shotgun/lib/cpu.h                     |   13 +-
 shotgun/lib/cpu_primitives.c          |   18 ++
 shotgun/lib/cpu_task.c                |   11 +
 shotgun/lib/instructions.rb           |   13 +-
 shotgun/lib/methctx.c                 |    5 +-
 shotgun/lib/methctx.h                 |    2 +-
 shotgun/lib/primitives.rb             |   75 +++----
 spec/mini_rspec.rb                    |    8 +-
 32 files changed, 849 insertions(+), 168 deletions(-)
 delete mode 120000 bin/sirb.rb
 create mode 100644 lib/ext/syck/build.rb
 create mode 100644 lib/stringio.rb
&lt;/pre&gt;

&lt;p&gt;But, hei, maybe it's just me :) &lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=Xsionkdz"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=gTL6Vh55"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=gTL6Vh55" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/Y4jVs_kPKqg" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2007/9/15/darcs-pull-vs-git-pull</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2007-07-28:173</id>
    <published>2007-07-28T17:13:00Z</published>
    <updated>2007-07-28T17:15:27Z</updated>
    <category term="bologna" />
    <category term="event" />
    <category term="tetramine" />
    <link href="http://feedproxy.google.com/~r/printme/~3/cNv8xSJyClA/join-the-tetris-day" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2007/7/28/join-the-tetris-day#comments" thr:count="1" rel="replies" type="text/html" />
    <title>Join the Tetris day</title>
<content type="html">
            &lt;p&gt;Just a quick note: if you are an italian reader, or if you're in italy in the end of september pick your piece and join us in the &lt;a href='http://tday.ptumpa.com/'&gt;tetramine day&lt;/a&gt; :)&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=QXukclEl"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=DS7VftV0"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=DS7VftV0" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/cNv8xSJyClA" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2007/7/28/join-the-tetris-day</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2007-07-04:141</id>
    <published>2007-07-04T08:42:00Z</published>
    <updated>2007-07-04T09:00:41Z</updated>
    <category term="alice" />
    <category term="concurrency" />
    <category term="ml" />
    <link href="http://feedproxy.google.com/~r/printme/~3/opWJdyVZ7hw/aliceml-concurrency" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2007/7/4/aliceml-concurrency#comments" thr:count="0" rel="replies" type="text/html" />
    <title>AliceML concurrency</title>
<content type="html">
            &lt;p&gt;In these days it seem that Erlang is considered the end of all concurrency debates. and it actually seem to provides a very nice environment for concurrent programming, possibly because it was designed to do so :)&lt;/p&gt;

&lt;p&gt;Yet there is another environment that was designed to provide good support for concurrent programming and that I find very interesting, but is not as "hyped". I'm thinking of &lt;a href='http://www.ps.uni-sb.de/alice'&gt;AliceML&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I'll try to explain the basic concepts, but I'm not really proficient in ML and I may be wrong about something, so please feel free to correct my code.&lt;/p&gt;

&lt;p&gt;A simple echo server in Alice is something like this &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
import structure Socket from "x-alice:/lib/system/Socket"

fun serve (socket, host, port) =
   let 
      val lineOpt = Socket.inputLine socket
   in
      case lineOpt of
          (* read something *)
           SOME(line) =&gt; print line
          (* read nothing *)
         | NONE =&gt; ()
      ;

      Socket.close socket
   end


val port = SOME 8802;
val (socket, port) = Socket.server (port, serve);

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;(&lt;em&gt;I know the case line is somewhat strange, but keep in mind that Alice is a completely type safe programming language. Yes, no type declarations in the above code, Yay for type inference!&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;Anyway, the above code will impose an ordering on the serving of clients, because client Y will be waiting for client X to finish before the &lt;code&gt;serve&lt;/code&gt; function is called for it.&lt;/p&gt;

&lt;p&gt;Now, in AliceML to make an expression concurrent you just need to prefix it with &lt;code&gt;spawn&lt;/code&gt;, so for example you can write:
&lt;code&gt;&lt;pre&gt;
spawn print ( complex_calc () )
&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And you'll have the calculation happen in a concurrent thread.&lt;/p&gt;

&lt;p&gt;So, how does this relates to our &lt;code&gt;serve&lt;/code&gt; function? 
Simple, you can declare a function as being always computed in a different thread replacing &lt;code&gt;fun&lt;/code&gt; with &lt;code&gt;fun spawn&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;By adding one word you have completed your transition from a serial server to a multithreaded uber-responsive concurrent HTTP server that competes with lighttpd, YAWS and ngix. 
Or, actually, not, but you have a concurrent echo server, which is nice.&lt;/p&gt;

&lt;h1&gt;Getting values&lt;/h1&gt;

&lt;p&gt;As of now there is little  difference with pthread-style or unix-processes concurrency at all. 
The real difference is in the presence of &lt;em&gt;a result in the spawned expression&lt;/em&gt;. 
Basically whenever a spawned expression is evaluated it returns a &lt;em&gt;Future&lt;/em&gt; value, meaning something that is not yet a real value, but will become soon. 
It's like  your &lt;code&gt;void&lt;/code&gt;-ish concurrent stuff in C/Java/Ruby/Python suddenly could return something. the question is: what?&lt;/p&gt;

&lt;p&gt;Well, a spawned expression will return something called &lt;em&gt;a Future&lt;/em&gt;,  that works as a placeholder for the real value. &lt;/p&gt;

&lt;p&gt;The main computation will work concurrently with the spawned computation and it will lock just when it needs the actual value of the spawned computation. 
At that point:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the main computation waits&lt;/li&gt;
&lt;li&gt;the concurrent computation finish its work&lt;/li&gt;
&lt;li&gt;the Future in the main computation is replaced with the concurrently produced value &lt;/li&gt;
&lt;li&gt;the main computation can resume its work and go on&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means that, for example, to concurrently transform a list you may do:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
map (fn x =&gt; spawn calc x) [1,2,3,4]
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And it will not lock as long as you don't access the list elements. 
Given the ease you can write this stuff, it is also ultra-simple to define your own parallel &lt;code&gt;map&lt;/code&gt; like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
fun pmap f l = map (fn x =&gt; spawn f x) l;
&lt;/code&gt;&lt;/pre&gt;

&lt;h1&gt;When trouble strikes&lt;/h1&gt;

&lt;p&gt;But wait: what happens if a Thread fails for some reason?
Simple, the Future it returns will be a &lt;em&gt;Failed Future&lt;/em&gt; and it will do exactly what you expect: it will cause a failure whenever it is accessed. 
So you have two chances: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the result is actually important, and a failure means the global result is invalid (i.e. using the values in a concurrently computed list). Then you are accessing the Failed Future and the error propagates, as expected. &lt;/li&gt;
&lt;li&gt;if a single concurrent computation fails utterly you don't care (i.e. network server), so you  just avoid handling the Future object and you will never know anything about the failure, somewhat  like erlang's  asynchronous message passing. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I like this, it seems like an evolutionary step from old-style concurrency that is not complicated yet works, plus it blurs the line between synchronous and asynchronous message passing, which is a great thing in my opinion.&lt;/p&gt;

&lt;p&gt;There is more than this in Alice's concurrency, for example handling shared values, the difference between Thread and OS Processes, atomic state change and so on, but all built on top of this primitives, AFAICT. Take a look at it, it even comes with a GTK gui ;)&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=bMFZyJxx"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=kH3NJeuY"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=kH3NJeuY" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/opWJdyVZ7hw" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2007/7/4/aliceml-concurrency</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2007-06-12:129</id>
    <published>2007-06-12T09:53:00Z</published>
    <updated>2007-06-12T10:17:44Z</updated>
    <category term="doctest" />
    <category term="ruby" />
    <category term="testing" />
    <link href="http://feedproxy.google.com/~r/printme/~3/dwaOx6P-t0w/my-tiny-doctest-for-ruby" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2007/6/12/my-tiny-doctest-for-ruby#comments" thr:count="1" rel="replies" type="text/html" />
    <title>My Tiny DocTest for ruby</title>
<content type="html">
            &lt;p&gt;I believe that doctest for python is one of the best test libraries available, because it pushes the cost to develop functional tests to zero.&lt;/p&gt;


	&lt;p&gt;While I’m writing a dummy object persistence layer I thought it would have been nice to have something like that, basically seeking some kind of &lt;em&gt;literate testing process&lt;/em&gt;.&lt;/p&gt;


	&lt;p&gt;&lt;a href='http://darcs.riffraff.info/dbz/test/doc.rb'&gt;This is the first attempt at it&lt;/a&gt; (warning dirty, slow, duplicated code).&lt;/p&gt;


	&lt;p&gt;It somehow works, can be run from rcov/rake/ruby, loaded with multiple files, and allows writing nice tests like &lt;a href='http://darcs.riffraff.info/dbz/test/samples/basic.rb'&gt;this one&lt;/a&gt; . 
As you can see in the code, everything that does not look like irb code is ignored, which allows adding comments, leave python code mixed with ruby, write formulas and so on.&lt;/p&gt;


	&lt;p&gt;The lib is really half-backed, for example you canì’t use multiline declarations in irb or print something to screen, but I think it is a nice small thing.&lt;/p&gt;


	&lt;p&gt;You can find a different take on sample/doc testing &lt;a href='http://manveru.mine.nu/darcs/testdoc/'&gt;in manveru’s repository&lt;/a&gt;&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=vZ3EBxPf"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=reF3FMGu"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=reF3FMGu" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/dwaOx6P-t0w" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2007/6/12/my-tiny-doctest-for-ruby</feedburner:origLink></entry>
  <entry xml:base="http://www.riffraff.info/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:www.riffraff.info,2007-06-05:128</id>
    <published>2007-06-05T20:58:00Z</published>
    <updated>2007-06-05T21:26:02Z</updated>
    <category term="darcs" />
    <category term="ftp" />
    <category term="sitecopy" />
    <link href="http://feedproxy.google.com/~r/printme/~3/8nQaIJbYr48/using-darcs-with-ftp-and-without-ssh" rel="alternate" type="text/html" />
    <link href="http://www.riffraff.info/2007/6/5/using-darcs-with-ftp-and-without-ssh#comments" thr:count="0" rel="replies" type="text/html" />
    <title>Using darcs with FTP and without SSH</title>
<content type="html">
            &lt;p&gt;darcs is my favourite Version Control System. I'm not &lt;a href='http://chneukirchen.org/blog/archive/2006/04/my-dvcs-wishlist.html'&gt;chris&lt;/a&gt; and I have not tried a lot of them, but I just love darcs' cherry picking so everything that misses that is out of my list. Maybe monotone or subversion 1.5 would be interesting.&lt;/p&gt;

&lt;p&gt;Anyway, my only issue with darcs is that it does not allow pushing changes to a dumb repository, where &lt;em&gt;dumb&lt;/em&gt; means &lt;em&gt;ftp&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Since I don't have ssh access on all my hostings I found the solution in &lt;em&gt;sitecopy&lt;/em&gt; which is a nifty utility to keep a remote directory in sync with a local one by doing incremental uploads.&lt;/p&gt;

&lt;p&gt;To use this simply install sitecopy (which is probably avilable through your linux/bsd flavour package manager) and create a file &lt;code&gt;~/.sitecopyrc&lt;/code&gt; with a content like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;
site myproject
  server  ftp.myserver.com
  remote  /www/darcs.myserver.com/myproject
  local   /path/to/local/repository
  username  joe
  password  123
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and to create a directory &lt;code&gt;~/.sitecopy&lt;/code&gt;. The permission mask for the dir must be 0700 and for the rc file it must be 0600, otherwise sitecopy will complain about insecure files. &lt;/p&gt;

&lt;p&gt;At this point you just need to init the remote repository by doing &lt;code&gt;sitecopy --init myproject&lt;/code&gt;. It may take some time because the first time you'll be uploading all the old patches in the &lt;code&gt;_darcs/&lt;/code&gt; directory, but the next time you will do this, using &lt;code&gt;sitecopy --update myproject&lt;/code&gt; it will be quite fast.&lt;/p&gt;

&lt;p&gt;Obviously this approach works nicely only in a single-user environment, because if multiple users share the remote directory there will be inconsistencies, but it is useful to keep your copy of a projects' repository where you can have your patches and where you can point people that want them.&lt;/p&gt;
          &lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/printme?a=VtV6NnBl"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?d=1288" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/printme?a=hzwjIBk7"&gt;&lt;img src="http://feeds.feedburner.com/~f/printme?i=hzwjIBk7" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/printme/~4/8nQaIJbYr48" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://www.riffraff.info/2007/6/5/using-darcs-with-ftp-and-without-ssh</feedburner:origLink></entry>
</feed>
