<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:planet="http://planet.intertwingly.net/" xmlns:indexing="urn:atom-extension:indexing" indexing:index="no"><access:restriction xmlns:access="http://www.bloglines.com/about/specs/fac-1.0" relationship="deny"/>
  <title>Planet Scala</title>
  <updated>2010-03-09T19:40:47Z</updated>
  <generator uri="http://intertwingly.net/code/venus/">Venus</generator>
  <author>
    <name>David MacIver</name>
    <email>david.maciver@gmail.com</email>
  </author>
  <id>http://www.planetscala.com/atom.xml</id>
  <link href="http://www.planetscala.com/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.planetscala.com" rel="alternate"/>

  <entry>
    <id>http://code.technically.us/post/436159735</id>
    <link href="http://code.technically.us/post/436159735" rel="alternate" type="text/html"/>
    <title>Curried and Confused</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>The best post on the internet got some sweet linkage again this week. You know, <a href="http://creativekarma.com/ee.php/weblog/comments/my_verdict_on_the_scala_language/">the one</a> where Scala is too complex because you can express the sum of a list of numbers like so:</p>

<pre><code>def sum(nums: List[Int]) = (0 /: nums) { _ + _ }
</code></pre>

<p>In the intervening years since that expression prompted a ‘verdict’ that Scala was too difficult for us regular folks, a lot of us have written a heck of a lot of Scala. We had to make <a href="http://implicit.ly/">implicit.ly</a> just to keep up with the flow of Scala software that people are publishing these days. The pump is primed and the machinery has finally come to life. It’s an exciting time! For some.</p>

<p>But since it’s <a href="http://enfranchisedmind.com/blog/posts/post-functional-scala/">come up</a>, let’s review that old <code>/:</code> scarecrow. What makes him so perplexing to newcomers? Some have blamed the use of non-letters in the name. Okay then, how much clearer would Joe BeanFactory find <em>this</em> definition?</p>

<pre><code>def sum(nums: List[Int]) = (nums foldLeft 0) { _ + _ }
</code></pre>

<p>Not much really! Well, maybe the problem is the infix notation?</p>

<pre><code>def sum(nums: List[Int]) = nums.foldLeft(0) { _ + _ }
</code></pre>

<p>Yeah, I don’t know. At this point our rhetorical corporate programmer has gone out for coffee. Perhaps he will be back later to decide which programming languages we’re all supposed to use for his convenience. Maybe he would rather express things like <code>1 + 1</code> as <code>1.plus(1)</code> —or, maybe he just doesn’t give a Dilbert about orthogonality.</p>

<p>But seriously guys, I don’t think it’s the infix notation or the permitting of symbolic characters in syntactic symbols that make applications of <code>/:</code> difficult to grok at first. It’s <em>the blessed currying</em>. Setting off the first function application with parentheses prevents one’s uninitiated mind from cheaply translating it to a familiar series of parameters. Instead you have to recognize that the first function application returns a second function, which is applied to another set of parameters. It’s <em>trippy</em>.</p>

<p>Truth be told, this perplexed me at the time. But instead of rejecting the language for supporting functional constructs beyond my experience, I decided to keep learning—and I’m happy with how that has worked out. So it’s interesting that two years later, this particular functional freak-out has been ‘cited’ to brand Scala as overly complex (Perl-y) while a second thread of spite bemoans Scala’s insufficient promotion of currying.</p>

<p>It’s simple, you see. The currying in Scala makes innocent enterprise developers cry in their frappuccinos, while similar encounters in OCaml inspire a rapturous session of functional mind-blowing.</p>

<p>Well. At least you can learn Scala at your desk.</p></div>
    </summary>
    <updated>2010-03-09T05:01:00Z</updated>
    <category term="Functional Programming"/>
    <category term="Scala"/>
    <category term="Useful Idiots"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:43Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/434969207</id>
    <link href="http://code.technically.us/post/434969207" rel="alternate" type="text/html"/>
    <title>"Crap, there’s an underscore. Is it a ‘point’? Good question. And the answer is no."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“Crap, there’s an underscore. Is it a ‘point’? Good question. And the answer is no.”<br/><br/> - <em><a href="http://james-iry.blogspot.com/2010/03/robert-fischer-finally-admits-that.html">Robert Fischer Finally Admits that Scala is Functional</a></em></div>
    </summary>
    <updated>2010-03-08T17:50:51Z</updated>
    <category term="Scala"/>
    <category term="Point-free Debate"/>
    <category term="Functional Programming"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/434907171</id>
    <link href="http://code.technically.us/post/434907171" rel="alternate" type="text/html"/>
    <title>"The problem with modern software development is that it’s all Phase 2. The ubiquitious availability..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“The problem with modern software development is that it’s all Phase 2. The ubiquitious availability of nearly-right-but-not-quite libraries and frameworks-that-do-it-all-for-you-except-that-actually-they-don’t wipes out the exhilaration of Phase 1, but leaves us with even more of the drudgery of Phase 2.”<br/><br/> - <em><a href="http://reprog.wordpress.com/2010/03/03/whatever-happened-to-programming/">Whatever happened to programming?</a> (Would replace ‘modern’ with ‘mainstream,’ but otherwise YES.)</em></div>
    </summary>
    <updated>2010-03-08T17:03:51Z</updated>
    <category term="Programming"/>
    <category term="Work"/>
    <category term="Magic Beans"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:43Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-178174920347765771.post-6031173593466159927</id>
    <link href="http://james-iry.blogspot.com/2010/03/robert-fischer-finally-admits-that.html" rel="alternate" type="text/html"/>
    <title>Robert Fischer Finally Admits that Scala is Functional</title>
    <summary>Robert Fischer saysIf your language doesn’t lead people to re-discover point free programming at least in the small, then the language really isn’t taking function manipulation and functional language type conceptions seriously.Thus Fischer has finally recognized that Scala is functional.
val double : Int =&gt; Int = 2 * // point free function definition
List(1,2,3) map double /* removes one point</summary>
    <updated>2010-03-08T15:40:00Z</updated>
    <category scheme="http://www.blogger.com/atom/ns#" term="functional programming"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="humor"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="idiocy"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="scala"/>
    <author>
      <name>James Iry</name>
      <email>noreply@blogger.com</email>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-178174920347765771</id>
      <author>
        <name>James Iry</name>
        <email>noreply@blogger.com</email>
      </author>
      <link href="http://james-iry.blogspot.com/" rel="alternate" type="text/html"/>
      <link href="http://james-iry.blogspot.com/feeds/posts/default?alt=rss" rel="self" type="application/atom+xml"/>
      <subtitle>An exploration of software development.</subtitle>
      <title>One Div Zero</title>
      <updated>2010-03-09T18:20:26Z</updated>
    </source>
  </entry>

  <entry xml:lang="en">
    <id>http://www.scala-lang.org/5470 at http://www.scala-lang.org</id>
    <link href="http://www.scala-lang.org/node/5470" rel="alternate" type="text/html"/>
    <title>Scala Days - Jam Packed!</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Jam packed with a schedule of advanced research and technical talks by some of the most knowlegable experts in the industry. Jam packed with Scala community know-how, over 80 people already registered. And jam packed with opportunities to meet and talk to other Scala developers. <a href="http://days2010.scala-lang.org/">Scala Days 2010</a>, 15-16 April, EPFL, Switzerland.</p> <p><a href="http://days2010.scala-lang.org/program">The full schedule of sessions, presenters and abstracts is now available</a>. It is the time to take a look, decide what to see and get organised to come! At Scala Days you'll have a ball! Learn about the latest research, see how smart people are applying it in serious commercial applications, talk over your ideas, your company projects with other top notch people, people like Chris Conrad (from LinkedIn), Nathan Hamblen (SPDE contributor), Jorge Ortiz (Lift web framework committer) , Kunle Olukotun (Director Stanford PPP lab) Miles Sabin (Eclipse PlugIn), David Copeland (Industry Consultant), Heiko Seeberger (ScalaModules), Jonas Bonér (AKKA) and Josh Suereth (Maven-scala-plugin and more), and of course the entire EPFL Scala research group with Martin Odersky.</p></div>
    </summary>
    <updated>2010-03-08T14:10:35Z</updated>
    <author>
      <name>bagwell</name>
    </author>
    <source>
      <id>http://www.scala-lang.org/</id>
      <link href="http://www.scala-lang.org/" rel="alternate" type="text/html"/>
      <link href="http://www.scala-lang.org/rss.xml" rel="self" type="application/rss+xml"/>
      <title>The Scala Programming Language</title>
      <updated>2010-03-09T19:40:33Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/434115234</id>
    <link href="http://code.technically.us/post/434115234" rel="alternate" type="text/html"/>
    <title>Where people are staying for Scala Days</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><br/><br/><p><a href="http://bit.ly/scaladaysmap">Where people are staying for Scala Days</a></p></div>
    </summary>
    <updated>2010-03-08T06:03:32Z</updated>
    <category term="Lausanne"/>
    <category term="Scala Days"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:43Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/433502242</id>
    <link href="http://code.technically.us/post/433502242" rel="alternate" type="text/html"/>
    <title>"Because aside from the static typing, all the language features that Odersky trots out already exist..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“Because aside from the static typing, all the language features that Odersky trots out already exist in Perl.”<br/><br/> - <em><a href="http://enfranchisedmind.com/blog/posts/post-functional-scala/">Scala: Only Different from Perl in Fundamental Ways</a></em></div>
    </summary>
    <updated>2010-03-08T01:01:00Z</updated>
    <category term="Don't call me Perl"/>
    <category term="The Static Typing"/>
    <category term="Trollpieces"/>
    <category term="Functional Programming"/>
    <category term="Scala"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:43Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-3083788237966827171.post-7390104310519482036</id>
    <link href="http://jnordenberg.blogspot.com/feeds/7390104310519482036/comments/default" rel="replies" type="application/atom+xml"/>
    <link href="https://www.blogger.com/comment.g?blogID=3083788237966827171&amp;postID=7390104310519482036" rel="replies" type="text/html"/>
    <link href="http://www.blogger.com/feeds/3083788237966827171/posts/default/7390104310519482036" rel="edit" type="application/atom+xml"/>
    <link href="http://www.blogger.com/feeds/3083788237966827171/posts/default/7390104310519482036" rel="self" type="application/atom+xml"/>
    <link href="http://jnordenberg.blogspot.com/2010/03/scala-stream-fusion-and-specialization.html" rel="alternate" type="text/html"/>
    <title>Scala Stream Fusion and Specialization</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><b>Updated:</b> Fixed code links and added view and stream benchmarks.<br/><br/>Inspired by the successful results of <a href="http://www.cse.unsw.edu.au/~dons/streams.html">Haskell stream fusion</a> (see <a href="http://donsbot.wordpress.com/2010/03/01/evolving-faster-haskell-programs-now-with-llvm/">Evolving Faster Haskell Programs (now with LLVM!)</a> for some impressive optimizations) I was thinking if a similar concept is applicable to Scala collections. It turns out that with a combination of iterators and specialization it's possible to achieve similar optimizations in Scala.<br/><br/>The goal of stream fusion is essentially to optimize code like this:<br/><pre><br/>  def scalaLibrarySum(a : Array[Int]) = a.map(i =&gt; i * 3 + 7).filter(i =&gt; (i % 10) == 0).foldLeft(0)(_ + _)<br/></pre><br/>into code like this:<br/><pre><br/>  def mapFilterSumLoop(a : Array[Int]) = {<br/>    var i = 0<br/>    var r = 0<br/><br/>    while (i &lt; a.length) {<br/>      val v = a(i) * 3 + 7<br/><br/>      if ((v % 10) == 0)<br/>        r += v<br/><br/>      i += 1<br/>    }<br/><br/>    r<br/>  }<br/></pre><br/>If you run the <b>scalaLibrarySum</b> method in Scala it will create two intermediate arrays with the results of the <b>map</b> and <b>filter</b> operations. This is totally unnecessary for this calculation as the functions passed to <b>filter</b> and <b>map</b> are side effect free and thus the result of the function applications can be performed lazily just before the result is needed in the fold operation. This is basically how the <b>mapFilterSumLoop</b> method works.<br/><br/>Besides creating intermediate arrays, boxing of primitive values must be avoided if we want to have any chance of competitive performance (the Haskell libraries contain specialized instances to avoid boxing). Fortunately Scala supports specialization of type parameters in version 2.8, which enables us to avoid boxing while still writing generic code. Unfortunately this feature seems to be quite buggy at the moment, just by playing around with a simple example I encountered two bugs (tickets <a href="https://lampsvn.epfl.ch/trac/scala/ticket/3148">#3148</a> and <a href="https://lampsvn.epfl.ch/trac/scala/ticket/3149">#3149</a>). So, the code below contain some specialization done by hand. Hopefully these bugs will be fixed so that the code can be fully generalized.<br/><br/>The biggest difference compared to stream fusion in Haskell is that I use impure iterators in the Scala code. This is not as nice as the pure stream code used in Haskell, but it's a fact that Hotspot isn't nearly as good at optimizing pure functional code as GHC. Hotspot works best if fed imperative style loops.<br/><br/>Here's the definitions of the specialized functions and iterators I use in the benchmark below:<br/><pre><br/>  // Specialized Function1<br/>  trait Fn1[@specialized I, @specialized O] {<br/>    def apply(a : I) : O<br/>  }<br/><br/>  // Specialized Function2<br/>  trait Fn2[@specialized I1, @specialized I2, @specialized O] {<br/>    def apply(a1 : I1, a2 : I2) : O<br/>  }<br/><br/>  // Specialized iterator<br/>  trait SIterator[@specialized T] {<br/>    def hasMore : Boolean<br/>    def current : T<br/>    def next()<br/>  }<br/></pre><br/>In addition to this I've defined array, filter and map iterators. Unfortunately these are not generic due to the problems with the specialize feature:<br/><pre><br/>  class IntArrayIterator(a : Array[Int], var index : Int, endIndex : Int) extends SIterator[Int] {<br/>    def next() = index += 1<br/>    def current = a(index)<br/>    def hasMore = index &lt; endIndex<br/>  }<br/><br/>  // Optimally this would be: class FilterIterator[@specialized T](iter : SIterator[T], pred : Fn1[T, Boolean]) extends SIterator[T]<br/>  class FilterIterator(iter : SIterator[Int], pred : Fn1[Int, Boolean]) extends SIterator[Int] {<br/>    def hasMore = iter.hasMore<br/><br/>    def next() = {<br/>      iter.next()<br/>      findNext()<br/>    }<br/><br/>    def findNext() = {<br/>      while (iter.hasMore &amp;&amp; !pred(iter.current))<br/>        iter.next()<br/>    }<br/><br/>    def current = iter.current<br/><br/>    findNext()<br/>  }<br/><br/>  // Optimally this would be: class MapIterator[@specialized U][@specialized T](iter : SIterator[T], fn : Fn1[T, U]) extends SIterator[U]<br/>  class MapIterator(iter : SIterator[Int], fn : Fn1[Int, Int]) extends SIterator[Int] {<br/>    def next() = iter.next()<br/>    def current = fn(iter.current)<br/>    def hasMore = iter.hasMore<br/>  }<br/></pre><br/>The fold function is straightforward and generic:<br/><pre><br/>  def fold[@specialized T, @specialized U] (iter : SIterator[T], fn : Fn2[U, T, U], v : U) = {<br/>    var r = v<br/><br/>    while (iter.hasMore) {<br/>      r = fn(r, iter.current)<br/>      iter.next()<br/>    }<br/><br/>    r<br/>  }<br/></pre><br/>The map-filter-sum function can now be written using iterators:<br/><pre><br/>  def mapFilterSum(a : Array[Int]) = {<br/>    val filter = new Fn1[Int, Boolean] {def apply(a : Int) = (a % 10) == 0}<br/>    val map = new Fn1[Int, Int] {def apply(a : Int) = a * 3 + 7}<br/>    val s = new FilterIterator(new MapIterator(new IntArrayIterator(a, 0, a.length), map), filter)<br/>    fold(s, new Fn2[Int, Int, Int] {def apply(a1 : Int, a2 : Int) = a1 + a2}, 0)<br/>  }<br/></pre><br/>The full iterator code can be found <a href="http://svn.assembla.com/svn/metascala/src/test/stream/SpecializedIterators.scala">here</a>. Compile the code using the latest Scala 2.8 build with the -Yspecialize flag. The optimize flag doesn't seem to have much effect on the performance.<br/><br/>I've benchmarked four different implementations of the map-filter-sum calculation:<br/><ul><br/><li>The while loop shown above</li><br/><li>The while loop split up into map, filter and fold functions with intermediate array results passed between them</li><br/><li>The version using specialized iterators</li><br/><li>The Scala library implementation shown above</li><br/><li>Same as Scala library function but with a view instead</li><br/><li>Same as Scala library function but with a stream instead</li><br/></ul><br/>The benchmark is performed by taking the minimum execution time of 200 runs of each of the functions on an array of 1 million integers. Running the application with latest OpenJDK 7 (Hotspot version "build 17.0-b10") and the flags "-server -XX:CompileThreshold=100" I get the following results:<br/><pre><br/>Loop: (4990,-423600172)<br/>Loop with intermediate arrays: (6690,-423600172)<br/>Specialized iterators: (5367,-423600172)<br/>Scala array: (46444,-423600172)<br/>Scala view: (39625,-423600172)<br/>Scala stream: (63210,-423600172)<br/></pre><br/>The first result value is the minimum execution time in microseconds, the second value is the result of the calculation. As you can see the method using specialized iterators is almost as fast as the single while loop. Hotspot has inlined all the iterator code, not bad! Using intermediate arrays is about 25% slower than specialized iterators. Using the Scala library is about 7-9 times slower! Clearly this bad result is a consequence of boxing taking place. Using a view is fastest here as it also avoids intermediate array creation.<br/><br/>The conclusion from this simple experiment is that it's certainly possible to write collection libraries with a nice high level interface and at the same time have excellent performance. When Scala specialization support is improved hopefully this power be available to all Scala programmers.<br/><br/>The full benchmark code can be found <a href="http://svn.assembla.com/svn/metascala/src/test/stream/Main.scala">here</a>.<div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/3083788237966827171-7390104310519482036?l=jnordenberg.blogspot.com" width="1"/></div></div>
    </content>
    <updated>2010-03-07T13:02:04Z</updated>
    <published>2010-03-06T17:39:00Z</published>
    <author>
      <name>Jesper Nordenberg</name>
      <email>noreply@blogger.com</email>
      <uri>http://www.blogger.com/profile/07589508061874776093</uri>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-3083788237966827171</id>
      <author>
        <name>Jesper Nordenberg</name>
        <email>noreply@blogger.com</email>
        <uri>http://www.blogger.com/profile/07589508061874776093</uri>
      </author>
      <link href="http://jnordenberg.blogspot.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <link href="http://www.blogger.com/feeds/3083788237966827171/posts/default" rel="self" type="application/atom+xml"/>
      <link href="http://jnordenberg.blogspot.com/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <subtitle>randomThoughts filter (_.category in (Scala :: programming :: Nil)) foreach blogger.post</subtitle>
      <title>Jesper's Blog</title>
      <updated>2010-03-07T15:54:15Z</updated>
    </source>
  </entry>

  <entry xml:lang="en">
    <id>http://www.scala-lang.org/5513 at http://www.scala-lang.org</id>
    <link href="http://www.scala-lang.org/node/5513" rel="alternate" type="text/html"/>
    <title>Screencast: Get Started with Scala 2.8 Beta 1</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Getting started with any programming language is a daunting task, let  alone           getting your workstation in a state to create a non-trivial           application. I spent a few days reading and trying many Scala  tools and libraries. I use some of my findings in this screencast.</p>
<p>This screencast covers how to create a <code>Scala</code>  console-based project.           I use the simple-build-tool (<code>sbt</code>) to compile, run, test and then eclipsify a project. I briefly cover where to put source code,  tests and how to use Eclipse           to edit and debug the project. <a href="http://www.mgutz.com/2010/03/06/get_started_with_scala_sbt_and_eclipse.html" rel="nofollow">Click here to view to screencast.</a></p></div>
    </summary>
    <updated>2010-03-07T09:00:37Z</updated>
    <author>
      <name>mgutz</name>
    </author>
    <source>
      <id>http://www.scala-lang.org/</id>
      <link href="http://www.scala-lang.org/" rel="alternate" type="text/html"/>
      <link href="http://www.scala-lang.org/rss.xml" rel="self" type="application/rss+xml"/>
      <title>The Scala Programming Language</title>
      <updated>2010-03-09T19:40:36Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/430368090</id>
    <link href="http://code.technically.us/post/430368090" rel="alternate" type="text/html"/>
    <title>Dispatch 0.7.2 - implicit.ly</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://implicit.ly/dispatch-072">Dispatch 0.7.2 - implicit.ly</a>: <p/><ul>
<li>Use defaultCharset charset established by <code>&gt;\</code> for post and put</li>
<li>Handler chaining with the <code>&gt;+&gt;</code> operator, to use more than one handler against the same request with overlapping scopes</li>
<li>Multipart response handling with the <code>&gt;--&gt;</code> operator in dispatch-mime, to support <a href="http://blog.basho.com/2010/02/24/link-walking-by-example/">Riak link-walking and map-reduce</a>
</li>
</ul><p/></div>
    </summary>
    <updated>2010-03-06T15:37:00Z</updated>
    <category term="Dispatch"/>
    <category term="Scala"/>
    <category term="Riak"/>
    <category term="Mime"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:43Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/430363732</id>
    <link href="http://code.technically.us/post/430363732" rel="alternate" type="text/html"/>
    <title>"
Use defaultCharset charset established by &gt;\ for POST « and PUT «&lt;
Handler..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“<ul>
<li>Use defaultCharset charset established by &gt;\ for POST « and PUT «&lt;</li>
<li>Handler chaining with the &gt;+&gt; operator, to use more than one handler against the same request with overlapping scopes</li>
<li>Multipart response handling with the <code>&gt;--&gt;</code> operator in dispatch-mime, to support <a href="http://blog.basho.com/2010/02/24/link-walking-by-example/">Riak link-walking and map-reduce</a>
</li>
</ul>”<br/><br/> - <em><a href="http://implicit.ly/dispatch-072">Dispatch 0.7.2 - implicit.ly</a></em></div>
    </summary>
    <updated>2010-03-06T15:34:30Z</updated>
    <category term="Scala"/>
    <category term="Dispatch"/>
    <category term="Riak"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-06T15:40:44Z</updated>
    </source>
  </entry>

  <entry xml:lang="en">
    <id>http://blog.lostlake.org/index.php?/archives/99-guid.html</id>
    <link href="http://blog.lostlake.org/index.php?/archives/99-Burn-your-TransLink-card.html" rel="alternate" type="text/html"/>
    <title>Burn your TransLink card</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>I am outraged at the SF Muni and their adoption of the <a href="https://www.translink.org/TranslinkWeb/index.do">TransLink</a>
card.  Soon, there are certain bus lines that will only accept the
TransLink card during rush hour... you won't be able to ride the bus
except with one of these evil devices.<br/>
</p>
<p>So, what's my outrage?<br/>
</p> <p>I spent most of today trying to obtain a TrankLink card for my
kids.  I read on the TransLink site that the <a href="https://www.translink.org/TranslinkWeb/seniors.do">youth cards</a>
had to be obtained in person rather than at the normal retail
outlets. 
So, I took my kids downtown figuring I could buy a card at a Muni
station, but no dice.  Most of the folks in the Muni stations had
no clue.  Finally, somebody pointed me to Golden Gate Transit in
the Ferry Building, so off we went to the Ferry Building.<br/>
</p>
<p>We find the right booth to buy the pass.  Now, my kids are in
kindergarten.  There's no question that they are youths and are
elegible for youth discounts.  In fact, most Muni drivers say,
"These kids look too young to pay."  My response is, "Muni rules
say that 5 year olds pay and we follow rules in our family."<br/>
</p>
<p>So, I ask for 2 youth passes.  The woman behind the counter
says, "give me their birth certificates and we'll give you the youth
passes."  I say, "that's a joke, right?  Look at them, do
they look anywhere near 16 or 18 or whatever the cutoff age is?" 
She responds, "Our policy is that we only issue youth cards with a
birth certificate."<br/>
</p>
<p>We've had to show the kids' birth certificates for their social
security cards and for entrance to school.  We did not have to
produce birth certificates for library cards, health insurance, so I'm
wondering what is going on here.  I ask for a supervisor.<br/>
</p>
<p>I talk to the supervisor and he tells me, "It is our policy that you
need a birth certificate to obtain a youth TransLink card."  Me:
"Why?  Do these kids look like they're too old for the
card?"  Him: "We bond the birth certificate to the card to avoid
fraud."  Me: "You what?"  Him: "We make sure that the
discount card is associated with the person."  Me: "So, you're
telling me that in order to get a discount, you guys are going to track
the movements of my kids throughout the TransLink system?  How is
this supposed to reduce fraud?"  Him: "That's our policy,
sir."  Me: "Your policy is Orwellian and there's no way I'm
letting you associate my kids' public transportation usage with their
birth certificate.  Instead of trying to buy cards for the kids,
I'm going to burn mine."<br/>
</p>
<p>So, we walk away.  The supervisor comes running after me. 
"Sir, your kids look young enough that they don't need to pay a fair
anyway."  Me: "First, they have to pay on the SF Muni and we
follow the rules so we pay.  Second, giving me a 'free-be' today
don't mitigate your Big Brother policy of tracking my kids
where-abouts."  Him: "I'm just trying to be helpful."  Me:
"If you want to be helpful, go back to your boss and explain to him
that this is the United States and we move freely in this country."<br/>
</p>
<p>My kids asked me why I was cranky.  I said, "Because the bad
people want to know where you go."  Kids: "We're not going
anywhere bad, so why don't we want people to know where we've
gone?"  Me: "It is our right as Americans to come and go as we
please.  It's our right to be private.  But more importantly,
historically, once the government starts tracking their citizens,
especially their children, they will find a way to use the information
against you.  It's not that we have anything to hide, it's that
any time people want to always know, they are up to no good... they are
bad people."<br/>
</p>
<p>So, we walk through the Ferry Building and I see a guy with an <a href="http://www.eff.org/">EFF</a> hat. 
Now, this is San Francisco, so it's not unexpected to see some guy
sporting an EFF hat.  I go up to him and say, "Are you a member of
the EFF?  I was one of the first donors to the EFF so don't get
freaked."  He says, "Yes."  I say, "The TransLink folks want
my kids' birth certificates in order to get a youth TransLink card and
they bond the birth certificate to the card so they track the kid's
movement throughout their system."  His jaw dropped to the
ground.  We shared a brief moment of liberal outrage and my kids
and I went on our way.<br/>
</p>
<p>When I got home, I checked the TransLink site.  There is no
mention of requiring a birth certificate to obtain a youth pass. 
I called the TransLink customer service line and they did verify that a
birth certificate is required.<br/>
</p>
<p>First, TransLink is hiding the fact that a birth certificate is
required.  It's not on their public web site although it is
mentioned in a press release.  Why are they hiding this
information?  Do they think that if they don't publish it on their
web site that somehow it'll make it okay?<br/>
</p>
<p>Second, TransLink is managed by the <a href="http://www.mtc.ca.gov/services/translink/">Metropolitan
Transportation Commission</a>, but this is not mentioned anywhere on
the TransLink web site and is only mentioned once in the TransLink
cardholder "license agreement".  Why is the MTC hiding?<br/>
</p>
<p>Third, if the MTC is a governmental body, where was the public
hearing and the public comment request relating to requiring a birth
certificate and bonding that information to youth passes?<br/>
</p>
<p>Forth, what great problem are they looking to solve by associating a
card with a person?  What kind of failures is the current youth
(and elderly) pass mechanism (a different colored pass) justify bonding
my child's birth certificate to their transit card and track my
children's comings and goings?<br/>
</p>
<p>So, I am outraged.  I will burn my TransLink card and until
this Orwellian, KGB-esq policy of requiring a birth certificate to get
a youth TransLink, I will not in any way participate in the TransLink
system.  I urge you to do the same.<br/>
<br/>
</p></div>
    </content>
    <updated>2010-03-06T06:06:56Z</updated>
    <category term="Personal"/>
    <author>
      <name>David Pollak</name>
      <email>nospam@example.com</email>
    </author>
    <source>
      <id>http://blog.lostlake.org/</id>
      <logo>http://blog.lostlake.org/templates/default/img/s9y_banner_small.png</logo>
      <link href="http://blog.lostlake.org/" rel="alternate" type="text/html"/>
      <link href="http://blog.lostlake.org/index.php?/feeds/index.rss2" rel="self" type="application/rss+xml"/>
      <subtitle>Information, experiences, rants...</subtitle>
      <title>David Pollak's Blog</title>
      <updated>2010-03-06T06:06:56Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/428894220</id>
    <link href="http://code.technically.us/post/428894220" rel="alternate" type="text/html"/>
    <title>"In Scala 2.8, using the builder pattern is no longer necessary (or the most optimal solution) in..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“In Scala 2.8, using the builder pattern is no longer necessary (or the most optimal solution) in many cases, as Scala 2.8 adds support for named and default parameters.”<br/><br/> - <em><a href="http://villane.wordpress.com/2010/03/05/taking-advantage-of-scala-2-8-replacing-the-builder/">Taking Advantage of Scala 2.8: Replacing the Builder</a></em></div>
    </summary>
    <updated>2010-03-05T21:49:00Z</updated>
    <category term="True Dat"/>
    <category term="Patterns"/>
    <category term="Scala"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry xml:lang="en">
    <id>http://villane.wordpress.com/?p=115</id>
    <link href="http://villane.wordpress.com/2010/03/05/taking-advantage-of-scala-2-8-replacing-the-builder/" rel="alternate" type="text/html"/>
    <title>Taking Advantage of Scala 2.8: Replacing the Builder</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">In Scala 2.8, using the builder pattern is no longer necessary (or the most optimal solution) in many cases, as Scala 2.8 adds support for named and default parameters.
I’ll give an example of this based on ScalaBox2D. In the Box2D object model, physics Bodies are defined mostly by a set of Fixtures, which in turn [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=villane.wordpress.com&amp;blog=820948&amp;post=115&amp;subd=villane&amp;ref=&amp;feed=1"/></div>
    </summary>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>In Scala 2.8, using the <a href="http://blog.rafaelferreira.net/2008/07/type-safe-builder-pattern-in-scala.html">builder pattern</a> is no longer necessary (or the most optimal solution) in many cases, as <a href="http://www.scala-lang.org/node/4587">Scala 2.8</a> adds support for named and default parameters.</p>
<p>I’ll give an example of this based on <a href="http://github.com/Villane/scalabox2d/">ScalaBox2D</a>. In the Box2D object model, physics Bodies are defined mostly by a set of Fixtures, which in turn are defined by a Shape, density, friction, restitution and some other parameters.</p>
<p>In the Scala 2.7 version of ScalaBox2D, there were mutable fixture definitions, which were used by the engine to create the actual fixtures. The user code only worked with definitions, through an internal DSL that looked something like this (note: all code examples are simplified for clarity):</p>
<pre class="brush: java;">body {
  box(halfWidth, halfHeight) density 1 friction 0.3f restitution 0
  computeMassFromShapes
}
</pre>
<p>For the DSL implementation, I used simple builders which left values to defaults if not specified:</p>
<pre class="brush: java;">def box(halfW: Float, halfH: Float) = new FixtureBuilder(FixtureDef(PolygonDef.box(halfW, halfH)))

class FixtureBuilder(defn: FixtureDef) {
  def userData(userData: AnyRef) = { defn.userData = userData; this }
  def material(material: Material) = { defn.apply(material); this }
  def friction(friction: Float) = { defn.friction = friction; this }
  def restitution(restitution: Float) = { defn.restitution = restitution; this }
  def density(density: Float) = { defn.density = density; this }
  def filter(filter: FilterData) = { defn.filter = filter; this }
  def sensor(isSensor: Boolean) = { defn.isSensor = isSensor; this }
  def define = defn
}
</pre>
<p>The FixtureDefs are mutable mostly to simplify the builder. In Scala 2.8, I can use named and default parameters, and drop some more lines of code by not having builders at all. As a bonus, I can easily make the definitions immutable.</p>
<pre class="brush: java;">def fixtures(fd: FixtureDef*) {...}
val fixture = FixtureDef // a shorthand to the companion object of FixtureDef
val box = BoxDef // a shorthand to a BoxDef object that creates PolygonDefs

case class FixtureDef(
  shapeDef: ShapeDef,
  /** The friction coefficient, usually in the range [0,1]. */
  friction: Float = 0.2f,
  /** The restitution (elasticity) usually in the range [0,1]. */
  restitution: Float = 0f,
  /** The density, usually in kg/m^2. */
  density: Float = 0f,
  /** A sensor collects contact information but never generates a collision response. */
  isSensor: Boolean = false,
  /** Contact filtering data. */
  filter: FilterData = FilterData.Default,
  /** Use this to store application specific fixture data. */
  userData: AnyRef = null
)</pre>
<p>As you can see, the FixtureDef is now a case class with immutable parameters that have default values. Previously it looked very similar, but had only one parameter (ShapeDef) and all fields were mutable. The usage of the “DSL” now becomes a little bit more verbose (maybe I shouldn’t even call it a DSL any more) but I think it also becomes easier to understand for someone who knows the language but not the library, due to less moving parts and using built-in features instead of more code:</p>
<pre class="brush: java;">body {
  fixtures(
    fixture(box(halfWidth, halfHeight), density = 1, friction = 0.3f, restitution = 0)
  )
  computeMassFromShapes
}
</pre>
<p>Deleting code while maintaining functionality always makes me glad and this is one of those cases. I guess there may be some more complex cases where builders may still work better, but for simple things like the above example, I really like the named and default arguments feature.</p>
<p>Note: moving ScalaBox2D to Scala 2.8 is still a work in progress for me and there may be some further changes to this “DSL” as well.</p>
<br/>  <a href="http://feeds.wordpress.com/1.0/gocomments/villane.wordpress.com/115/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/villane.wordpress.com/115/"/></a> <a href="http://feeds.wordpress.com/1.0/godelicious/villane.wordpress.com/115/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/villane.wordpress.com/115/"/></a> <a href="http://feeds.wordpress.com/1.0/gostumble/villane.wordpress.com/115/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/villane.wordpress.com/115/"/></a> <a href="http://feeds.wordpress.com/1.0/godigg/villane.wordpress.com/115/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/villane.wordpress.com/115/"/></a> <a href="http://feeds.wordpress.com/1.0/goreddit/villane.wordpress.com/115/" rel="nofollow"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/villane.wordpress.com/115/"/></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=villane.wordpress.com&amp;blog=820948&amp;post=115&amp;subd=villane&amp;ref=&amp;feed=1"/></div>
    </content>
    <updated>2010-03-05T21:22:07Z</updated>
    <category term="Game programming"/>
    <category term="Programming"/>
    <category term="Scala"/>
    <author>
      <name>Erkki Lindpere</name>
    </author>
    <source>
      <id>http://villane.wordpress.com</id>
      <logo>http://www.gravatar.com/blavatar/2a9e7e1788c5a66712aee7e5ad5ff02f?s=96&amp;d=http://s2.wp.com/i/buttonw-com.png</logo>
      <link href="http://villane.wordpress.com/feed/" rel="self" type="application/atom+xml"/>
      <link href="http://villane.wordpress.com" rel="alternate" type="text/html"/>
      <link href="http://villane.wordpress.com/osd.xml" rel="search" type="application/opensearchdescription+xml"/>
      <link href="http://villane.wordpress.com/?pushpress=hub" rel="hub" type="text/html"/>
      <subtitle>Thoughts on software development</subtitle>
      <title>Villane</title>
      <updated>2010-03-05T21:40:17Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/428509980</id>
    <link href="http://code.technically.us/post/428509980" rel="alternate" type="text/html"/>
    <title>"At this stage, the Skinput armband contains a pico projector that displays the..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“At this stage, the Skinput armband contains a pico projector that displays the ‘touchpad’ on the user’s hand or forearm, along with biosensors that recognize skin taps on corresponding locations of the body, based on bone and soft tissue variations.”<br/><br/> - <em><a href="http://www.cmu.edu/homepage/computing/2010/winter/skinput.shtml">Your body is just a big iPod touch</a></em></div>
    </summary>
    <updated>2010-03-05T16:52:18Z</updated>
    <category term="Mobile"/>
    <category term="CMU"/>
    <category term="Made out of Meat"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:43Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/427060763</id>
    <link href="http://code.technically.us/post/427060763" rel="alternate" type="text/html"/>
    <title>Introduction to Scala slides by Peter Maas at eBay/marktplaats</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><br/><br/><p><a href="http://log4p.com/2010/03/04/introduction-to-scala/">
Introduction to Scala slides by Peter Maas at eBay/marktplaats</a></p></div>
    </summary>
    <updated>2010-03-04T23:43:01Z</updated>
    <category term="Slides"/>
    <category term="eBay"/>
    <category term="Scala"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/426196395</id>
    <link href="http://code.technically.us/post/426196395" rel="alternate" type="text/html"/>
    <title>Lift Web Framework 2.0 Milestone 3</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://implicit.ly/lift-web-framework-20-milestone-3-released">Lift Web Framework 2.0 Milestone 3</a>: <p/><ul>
<li>Enhancements to LiftActors and LRU to support Goat Rodeo</li>
<li>Add CouchDB support (lift-couchdb)</li>
<li>… !</li>
</ul><p/></div>
    </summary>
    <updated>2010-03-04T13:16:08Z</updated>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-7480826096025842182.post-6734876225398370377</id>
    <link href="http://scalada.blogspot.com/feeds/6734876225398370377/comments/default" rel="replies" type="application/atom+xml"/>
    <link href="https://www.blogger.com/comment.g?blogID=7480826096025842182&amp;postID=6734876225398370377" rel="replies" type="text/html"/>
    <link href="http://www.blogger.com/feeds/7480826096025842182/posts/default/6734876225398370377" rel="edit" type="application/atom+xml"/>
    <link href="http://www.blogger.com/feeds/7480826096025842182/posts/default/6734876225398370377" rel="self" type="application/atom+xml"/>
    <link href="http://scalada.blogspot.com/2008/04/named-arguments.html" rel="alternate" type="text/html"/>
    <title>Named arguments</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><div>edit at 3rd of March, 2010: Scala will have named arguments in 2.8. Great! <a href="http://www.scala-lang.org/sid/1">http://www.scala-lang.org/sid/1#</a></div><div><br/></div>Scala unfortunately doesn't have named arguments. I would really like to have them, because they make code much clearer in some cases, and it's harder to make mistakes with them. That's why I'll show one way to simulate them.<br/><br/>First, let's create the function that can handle homemade named arguments:<br/><br/><pre>    def f(x: {val name: String; val age: Int}) = {</pre><br/><br/>f takes one argument, that contains the actual parameters we want. The type is shorthand for Any{ ... }.<br/><br/>Next we have imported the contents of x to be visible inside method f. This is possible due to Scala's handling of objects as first class modules.<br/><br/><pre>    import x._</pre><br/><br/>And now we can use the attributes as if they were f's real parameters:<br/><br/><pre>    println(name + " is " + age + " years old")</pre><br/><br/>How about from client's perspective? Well, client can just create a structural type that contains the needed attributes (actual arguments).<br/><br/><pre>    f(new {val name = "Anthony"; val age = 5})</pre><br/><br/>As you see, it's not really possible to make mistakes this way. But the calling has too much boilerplate, namely vals. So let's make it a bit better:<br/><br/>We create a case class for each actual parameter.<br/><br/><pre>    case class Name(name : String)<br/>   case class Age (age : Int)<br/></pre><br/><br/>Now we can make very clear function signature:<br/><br/><pre>    def g(x: Name, y: Age) = {</pre><br/><br/>Unfortunately we have to import all parameters one by one.<br/><br/><pre>    import x._, y._<br/>   println(name + " is " + age + " years old")</pre><br/><br/>The client can call the method in the following way:<br/><br/><pre>    g(Name("Tim"), Age(2))</pre><br/><br/>That's it. It's annoying that we have to create case classes, but it's tolerable in important cases.<br/><br/>Here's the full code:<br/><br/><pre><br/>object Test extends Application{<br/> def f(x: {val name: String; val age: Int}) = {<br/>   import x._<br/>   println(name + " is " + age + " years old")<br/> }<br/> f(new {val name = "Anthony"; val age = 5})<br/><br/> case class Name(name : String)<br/> case class Age (age : Int)<br/><br/> def g(x: Name, y: Age) = {<br/>   import x._, y._<br/>   println(name + " is " + age + " years old")<br/> }<br/> g(Name("Tim"), Age(2))<br/>}<br/></pre><br/>Run the code and you get as output:<br/>Anthony is 5 years old<br/>Tim is 2 years old<br/><br/>edit:<br/><br/>On the client side, often one passes some constant values. If you call just like f(value1, value2, ... valueN), it's hard to know later when you see the code what the meaning for each value was; so you have to go see the API (if there's no tool help). Instead you have to define vals before the call:<br/><br/><pre>val age = 8<br/>val name = "Jim"<br/>f(age, name)</pre><br/><br/>But now there's the issue that you have to write the variables twice, and it would be nice to see immeaditely on the call what the value was.<br/><br/>Then:<br/><br/><pre>f(new {val age = 8; val name = "Jim"})</pre> isn't that bad at all. Neither the case class equivalent. If you have many arguments to pass, calling with single argument per line looks nice:<br/><pre>f(new { val age = 8<br/>       val name = "Jim"<br/>       val hobby = "blogging" })</pre><br/><br/>Named arguments are especially useful when constructing objects, because it's then when you have to pass lots of vaguely related arguments.<div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/7480826096025842182-6734876225398370377?l=scalada.blogspot.com" width="1"/></div></div>
    </content>
    <updated>2010-03-03T06:47:35Z</updated>
    <published>2008-04-13T17:27:00Z</published>
    <author>
      <name>Henrik Huttunen</name>
      <email>henrik.huttunen@gmail.com</email>
      <uri>http://www.blogger.com/profile/01845345214435219727</uri>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-7480826096025842182</id>
      <author>
        <name>Henrik Huttunen</name>
        <email>henrik.huttunen@gmail.com</email>
        <uri>http://www.blogger.com/profile/01845345214435219727</uri>
      </author>
      <link href="http://scalada.blogspot.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <link href="http://www.blogger.com/feeds/7480826096025842182/posts/default" rel="self" type="application/atom+xml"/>
      <link href="http://scalada.blogspot.com/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <title>Scalada - all about Scala</title>
      <updated>2010-03-09T19:12:21Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/422772499</id>
    <link href="http://code.technically.us/post/422772499" rel="alternate" type="text/html"/>
    <title>"I am not particularly proud of Apple right now."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“I am not particularly proud of Apple right now.”<br/><br/> - <em><a href="http://waffle.wootest.net/2010/03/02/for-shame/">waffle →  For Shame</a></em></div>
    </summary>
    <updated>2010-03-02T22:39:56Z</updated>
    <category term="Apple"/>
    <category term="Dumb Property"/>
    <category term="Waffle"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/422560351</id>
    <link href="http://code.technically.us/post/422560351" rel="alternate" type="text/html"/>
    <title>Bevy of sbt plugins</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://bmc.github.com/sbt-plugins/">Bevy of sbt plugins</a>: <p>This repository contains various plugins for the SBT build tool:</p>

<ul>
<li>The EditSource plugin provides methods that offer a similar substitution facility to the one available with an Ant’s filterset.</li>
<li>The IzPack plugin provides a method that will run the IzPack compiler, generating an installer jar for your application.</li>
<li>The Markdown plugin supplies methods to translate Markdown documents into HTML.</li>
</ul></div>
    </summary>
    <updated>2010-03-02T20:36:56Z</updated>
    <category term="sbt"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/422310902</id>
    <link href="http://code.technically.us/post/422310902" rel="alternate" type="text/html"/>
    <title>Shocker: Apple is going to use those patents</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://www.engadget.com/2010/03/02/apple-sues-htc-for-infringing-20-iphone-patents/">Shocker: Apple is going to use those patents</a>: <p>Remember how everybody dutifully assumed that Apple was patenting everything from <em>Minority Report</em> as a defense measure against, you know, ‘other’ patent trolls? Well it turns out that is not the case. They’re going to preemptively file suit to impede their competition, because they can. This is <em>how things work</em>.</p></div>
    </summary>
    <updated>2010-03-02T17:32:00Z</updated>
    <category term="Apple"/>
    <category term="Dumb Property"/>
    <category term="One More Thing"/>
    <category term="Useful Idiots"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-11993899.post-772983623240289637</id>
    <link href="http://www.blogger.com/feeds/11993899/772983623240289637/comments/default" rel="replies" type="application/atom+xml"/>
    <link href="https://www.blogger.com/comment.g?blogID=11993899&amp;postID=772983623240289637" rel="replies" type="text/html"/>
    <link href="http://www.blogger.com/feeds/11993899/posts/default/772983623240289637" rel="edit" type="application/atom+xml"/>
    <link href="http://www.blogger.com/feeds/11993899/posts/default/772983623240289637" rel="self" type="application/atom+xml"/>
    <link href="http://blog.spiralarm.com/richard/2010/02/this-blog-has-moved.html" rel="alternate" type="text/html"/>
    <title>This blog has moved</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">This blog has moved to <a href="http://richard.dallaway.com/">http://richard.dallaway.com/</a> or http://richard.dallaway.com/rss.xml if want the feed URL.  Sorry. Thanks.<div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/11993899-772983623240289637?l=blog.spiralarm.com%2Frichard" width="1"/></div></div>
    </content>
    <updated>2010-03-02T10:17:52Z</updated>
    <published>2010-02-28T18:29:00Z</published>
    <author>
      <name>Richard</name>
      <email>noreply@blogger.com</email>
      <uri>http://www.blogger.com/profile/13961558038549366975</uri>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-11993899</id>
      <author>
        <name>Richard</name>
        <email>noreply@blogger.com</email>
        <uri>http://www.blogger.com/profile/13961558038549366975</uri>
      </author>
      <link href="http://www.blogger.com/feeds/11993899/posts/default" rel="self" type="application/atom+xml"/>
      <link href="http://blog.spiralarm.com/richard/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <link href="http://www.blogger.com/feeds/11993899/posts/default?start-index=26&amp;max-results=25" rel="next" type="application/atom+xml"/>
      <link href="http://blog.spiralarm.com/richard/atom.xml" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <title>Richard's technical notes</title>
      <updated>2010-03-02T10:17:51Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/420940589</id>
    <link href="http://code.technically.us/post/420940589" rel="alternate" type="text/html"/>
    <title>Introducing GitHub Compare View</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://github.com/blog/612-introducing-github-compare-view">Introducing GitHub Compare View</a>: <p>That feature you’ve been clicking around for on github exists, now!</p></div>
    </summary>
    <updated>2010-03-02T01:27:01Z</updated>
    <category term="git"/>
    <category term="github"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:43Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/420355946</id>
    <link href="http://code.technically.us/post/420355946" rel="alternate" type="text/html"/>
    <title>simple-build-tool Processors (experimental)</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://code.google.com/p/simple-build-tool/wiki/Processors">simple-build-tool Processors (experimental)</a>: <p>Slowly but surely becoming a command line for Scala.</p></div>
    </summary>
    <updated>2010-03-01T20:05:50Z</updated>
    <category term="sbt"/>
    <category term="Scala"/>
    <category term="Fortuitous Platforms"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/420189919</id>
    <link href="http://code.technically.us/post/420189919" rel="alternate" type="text/html"/>
    <title>The advance program for Scala Days 2010</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://days2010.scala-lang.org/node/72">The advance program for Scala Days 2010</a>: <p>Click on their PDF link for beautiful aerial photos and session details!</p></div>
    </summary>
    <updated>2010-03-01T18:01:00Z</updated>
    <category term="Scala Days"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/419961353</id>
    <link href="http://code.technically.us/post/419961353" rel="alternate" type="text/html"/>
    <title>It was an exciting time to be a scientist AND an anagramist!</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><img src="http://25.media.tumblr.com/tumblr_kylx1dAPQt1qb6dplo1_500.png"/><br/><br/><p><a href="http://www.qwantz.com/index.php?comic=1663">It was an exciting time to be a scientist AND an anagramist!</a></p></div>
    </summary>
    <updated>2010-03-01T15:01:52Z</updated>
    <category term="Dinosaur Comics"/>
    <category term="Codes"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry xml:lang="en">
    <id>http://www.scala-lang.org/5458 at http://www.scala-lang.org</id>
    <link href="http://www.scala-lang.org/node/5458" rel="alternate" type="text/html"/>
    <title>Cloud Computing with Scala</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p><a href="http://gridgain.com/company.html#people">Nikita Ivanov</a>, Founder and CEO of<a href="http://www.gridgain.com/index.html"> GridGain</a> will be presenting <a href="http://javasymposium.techtarget.com/html/cloud.html#NIvanovCloud">"Cloud Computing with Scala and GridGain"</a> in the "New Cloud!" track at the <a href="http://javasymposium.techtarget.com/">The ServerSide Java Symposium</a>, March 17-19, 2010, Caesars Palace, Las Vegas. This will be the first showing of the GridGain v3.0 code base in a practical hands-on session where he will show you how to use Scala with GridGain’s cloud development platform to create simple and productive cloud computing platforms. TSSJS will have lots of informative sessions for you and the added bonus of being able to listen to James Gosling, the father of Java, keynote speech too.</p></div>
    </summary>
    <updated>2010-03-01T14:41:04Z</updated>
    <author>
      <name>bagwell</name>
    </author>
    <source>
      <id>http://www.scala-lang.org/</id>
      <link href="http://www.scala-lang.org/" rel="alternate" type="text/html"/>
      <link href="http://www.scala-lang.org/rss.xml" rel="self" type="application/rss+xml"/>
      <title>The Scala Programming Language</title>
      <updated>2010-03-09T19:40:33Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/419887753</id>
    <link href="http://code.technically.us/post/419887753" rel="alternate" type="text/html"/>
    <title>"Dependency Injection is one of the techniques that I use regularly when I am programming in Java...."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“Dependency Injection is one of the techniques that I use regularly when I am programming in Java. … I have been programming more in Scala and Clojure and being exposed to many of the functional paradigms that they encourage and espouse … it may be we will see that this is yet another instance of a pattern melding into the chores of a powerful language’s idiomatic use.”<br/><br/> - <em><a href="http://debasishg.blogspot.com/2010/02/dependency-injection-as-function.html">Dependency injection potentially sidelined by function currying</a></em></div>
    </summary>
    <updated>2010-03-01T14:07:00Z</updated>
    <category term="Patterns"/>
    <category term="Functional Programming"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:43Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-22587889.post-5773558157295330139</id>
    <link href="http://debasishg.blogspot.com/feeds/5773558157295330139/comments/default" rel="replies" type="application/atom+xml"/>
    <link href="https://www.blogger.com/comment.g?blogID=22587889&amp;postID=5773558157295330139" rel="replies" type="text/html"/>
    <link href="http://www.blogger.com/feeds/22587889/posts/default/5773558157295330139" rel="edit" type="application/atom+xml"/>
    <link href="http://debasishg.blogspot.com/feeds/posts/default/5773558157295330139" rel="self" type="application/atom+xml"/>
    <link href="http://debasishg.blogspot.com/2010/02/dependency-injection-as-function.html" rel="alternate" type="text/html"/>
    <title>Dependency Injection as Function Currying</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">Dependency Injection is one of the techniques that I use regularly when I am programming in Java. It's a nice way of making an application decoupled from concrete implementations and localize object creation logic within specific bootstrapping modules. Be it in the form of Spring XML or Guice Modules, the idea is to keep it configurable so that specific components of your application can choose to work with specific implementations of an abstraction.<br/><br/>It so happens that these days possibly I have started looking at things a bit differently. I have been programming more in Scala and Clojure and being exposed to many of the functional paradigms that they encourage and espouse, it has stated manifesting in the way I think of programming. In this post I will look into dependency injection on a different note. At the end of it may be we will see that this is yet another instance of a pattern melding into the chores of a powerful language's idiomatic use.<br/><br/>In one of my projects I have a class whose constructor has some of its parameters injected and the others manually provided by the application. Guice has a nice extension that does this for you - <a href="http://code.google.com/p/google-guice/wiki/AssistedInject">AssistedInject</a>. It writes the boilerplate stuff by generating an implementation of the factory. You just need to annotate the implementation class' constructor and the fields that aren't known to the injector. Here's an example from the Guice page ..<br/><br/><code><span class="java_keyword">public</span><span class="java_plain"> </span><span class="java_keyword">class</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_plain"> </span><span class="java_keyword">implements</span><span class="java_plain"> </span><span class="java_type">Payment</span><span class="java_plain"> </span><span class="java_separator">{</span><span class="java_plain"/><br/><span class="java_plain">  @</span><span class="java_type">Inject</span><span class="java_plain"/><br/><span class="java_plain">  </span><span class="java_keyword">public</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_separator">(</span><span class="java_plain"/><br/><span class="java_plain">        </span><span class="java_type">CreditService</span><span class="java_plain"> creditService</span><span class="java_separator">,</span><span class="java_plain">  </span><span class="java_comment">// injected</span><br/><span class="java_plain">        </span><span class="java_type">AuthService</span><span class="java_plain"> authService</span><span class="java_separator">,</span><span class="java_plain">  </span><span class="java_comment">// injected</span><br/><span class="java_plain">        @</span><span class="java_type">Assisted</span><span class="java_plain"> </span><span class="java_type">Date</span><span class="java_plain"> startDate</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_comment">// caller to provide</span><br/><span class="java_plain">        @</span><span class="java_type">Assisted</span><span class="java_plain"> </span><span class="java_type">Money</span><span class="java_plain"> amount</span><span class="java_separator">);</span><span class="java_plain">  </span><span class="java_comment">// aller to provide</span><br/><span class="java_plain">  </span><span class="java_separator">}</span><span class="java_plain"/><br/><span class="java_plain">  </span><span class="java_separator">...</span><span class="java_plain"/><br/><span class="java_separator">}</span><span class="java_plain"/><br/><span class="java_plain"/><br/></code><br/>Then in the Guice module we bind a <code>Provider&lt;Factory&gt;</code> ..<br/><br/><code><span class="java_plain">bind</span><span class="java_separator">(</span><span class="java_type">PaymentFactory</span><span class="java_separator">.</span><span class="java_keyword">class</span><span class="java_separator">).</span><span class="java_plain">toProvider</span><span class="java_separator">(</span><span class="java_plain"/><br/><span class="java_plain">  </span><span class="java_type">FactoryProvider</span><span class="java_separator">.</span><span class="java_plain">newFactory</span><span class="java_separator">(</span><span class="java_plain"/><br/><span class="java_plain">    </span><span class="java_type">PaymentFactory</span><span class="java_separator">.</span><span class="java_keyword">class</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_separator">.</span><span class="java_keyword">class</span><span class="java_separator">));</span><span class="java_plain"/><br/><span class="java_plain"/><br/></code><br/>The <code>FactoryProvider</code> maps the <code>create()</code> method's parameters to the corresponding <code>@Assisted</code> parameters in the implementation class' constructor. For the other constructor arguments, it asks the regular <code>Injector</code> to provide values.<br/><br/>So the basic issue that <code>AssistedInject</code> solves is to finalize (<i>close</i>) some of the parameters at the module level to be provided by the injector, while keeping the abstraction <i>open</i> for the rest to be provided by the caller.<br/><br/>On a functional note this sounds a lot like <a href="http://en.wikipedia.org/wiki/Currying">currying</a> .. The best rationale for currying is to allow for partial application of functions, which does the same thing as above in offering a flexible means of keeping parts of your abstraction open for later pluggability.<br/><br/>Consider the above abstraction modeled as a case class in Scala ..<br/><br/><code><span class="java_keyword">trait</span><span class="java_plain"> </span><span class="java_type">CreditService</span><span class="java_plain"/><br/><span class="java_keyword">trait</span><span class="java_plain"> </span><span class="java_type">AuthService</span><span class="java_plain"/><br/><span class="java_plain"/><br/><span class="java_keyword">case</span><span class="java_plain"> </span><span class="java_keyword">class</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_separator">(</span><span class="java_plain">creditService</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">CreditService</span><span class="java_separator">,</span><span class="java_plain"/><br/><span class="java_plain">                       authService</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">AuthService</span><span class="java_separator">,</span><span class="java_plain"/><br/><span class="java_plain">                       startDate</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">Date</span><span class="java_separator">,</span><span class="java_plain"/><br/><span class="java_plain">                       amount</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">Int</span><span class="java_separator">)</span><span class="java_plain"/><br/><span class="java_plain"/><br/></code><br/>One of the features of a Scala case class is that it generates a companion object automatically along with an apply method that enables you to invoke the class constructor as a function object ..<br/><br/><code><span class="java_keyword">val</span><span class="java_plain"> rp </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_separator">(</span><span class="java_plain"> </span><span class="java_comment">//..</span><br/><span class="java_plain"/><br/></code><br/>is in fact a syntactic sugar for <code>RealPayment.apply( //</code>.. that gets called implicitly. But you know all that .. right ?<br/><br/>Now for a particular module , say I would like to finalize on <code>PayPal</code> as the <code>CreditService</code> implementation, so that the users don't have to pass this parameter repeatedly - just like the injector of your favorite dependency injection provider. I can do this as follows in a functional way and pass on a partially applied function to all users of the module .. <br/><br/><div><br/><code><span class="java_plain">scala</span><span class="java_operator">&gt;</span><span class="java_plain"> </span><span class="java_keyword">case</span><span class="java_plain"> </span><span class="java_keyword">class</span><span class="java_plain"> </span><span class="java_type">PayPal</span><span class="java_separator">(</span><span class="java_plain">provider</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">String</span><span class="java_separator">)</span><span class="java_plain"> </span><span class="java_keyword">extends</span><span class="java_plain"> </span><span class="java_type">CreditService</span><span class="java_plain"/><br/><span class="java_plain">defined </span><span class="java_keyword">class</span><span class="java_plain"> </span><span class="java_type">PayPal</span><span class="java_plain"/><br/><span class="java_plain"/><br/><span class="java_plain">scala</span><span class="java_operator">&gt;</span><span class="java_plain"> </span><span class="java_keyword">val</span><span class="java_plain"> paypalPayment </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_separator">(</span><span class="java_type">PayPal</span><span class="java_separator">(</span><span class="java_literal">"bar"</span><span class="java_separator">),</span><span class="java_plain"> _</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">AuthService</span><span class="java_separator">,</span><span class="java_plain"> _</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">Date</span><span class="java_separator">,</span><span class="java_plain"> _</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">Int</span><span class="java_separator">)</span><span class="java_plain"/><br/><span class="java_plain">paypalPayment</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_separator">(</span><span class="java_type">AuthService</span><span class="java_separator">,</span><span class="java_plain"> java</span><span class="java_separator">.</span><span class="java_plain">util</span><span class="java_separator">.</span><span class="java_type">Date</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">Int</span><span class="java_separator">)</span><span class="java_plain"> </span><span class="java_operator">=&gt;</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_plain"> </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_operator">&lt;</span><span class="java_plain">function</span><span class="java_operator">&gt;</span><span class="java_plain"/><br/><span class="java_plain"/><br/></code><br/></div><br/><br/>Note how the Scala interpreter now treats <code>paypalPayment</code> as a function from <code>(AuthService, java.util.Date, Int) =&gt; RealPayment</code>. The underscore acts as the placeholder that helps Scala create a new function object with only those parameters. In our case the new functional takes only three parameters for whom we used the placeholder syntax. From your application point of view what it means is that we have closed the abstraction partially by finalizing the provider for the <code>CreditService</code> implementation and left the rest of it open. Isn't this precisely what the Guice injector was doing above injecting some of the objects at module startup ?<br/><br/>Within the module I can now invoke <code>paypalPayment</code> with only the 3 parameters that are still open ..<br/><br/><div><br/><code><span class="java_plain">scala</span><span class="java_operator">&gt;</span><span class="java_plain"> </span><span class="java_keyword">case</span><span class="java_plain"> </span><span class="java_keyword">class</span><span class="java_plain"> </span><span class="java_type">DefaultAuth</span><span class="java_separator">(</span><span class="java_plain">provider</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">String</span><span class="java_separator">)</span><span class="java_plain"> </span><span class="java_keyword">extends</span><span class="java_plain"> </span><span class="java_type">AuthService</span><span class="java_plain"/><br/><span class="java_plain">defined </span><span class="java_keyword">class</span><span class="java_plain"> </span><span class="java_type">DefaultAuth</span><span class="java_plain"/><br/><span class="java_plain"/><br/><span class="java_plain">scala</span><span class="java_operator">&gt;</span><span class="java_plain"> paypalPayment</span><span class="java_separator">(</span><span class="java_type">DefaultAuth</span><span class="java_separator">(</span><span class="java_literal">"foo"</span><span class="java_separator">),</span><span class="java_plain"> java</span><span class="java_separator">.</span><span class="java_plain">util</span><span class="java_separator">.</span><span class="java_type">Calendar</span><span class="java_separator">.</span><span class="java_plain">getInstance</span><span class="java_separator">.</span><span class="java_plain">getTime</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_literal">10000</span><span class="java_separator">)</span><span class="java_plain"/><br/><span class="java_plain">res0</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_plain"> </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_separator">(</span><span class="java_type">PayPal</span><span class="java_separator">(</span><span class="java_plain">foo</span><span class="java_separator">),</span><span class="java_type">DefaultAuth</span><span class="java_separator">(</span><span class="java_plain">foo</span><span class="java_separator">),</span><span class="java_type">Sun</span><span class="java_plain"> </span><span class="java_type">Feb</span><span class="java_plain"> </span><span class="java_literal">28</span><span class="java_plain"> </span><span class="java_literal">15</span><span class="java_operator">:</span><span class="java_literal">22</span><span class="java_operator">:</span><span class="java_literal">01</span><span class="java_plain"> IST </span><span class="java_literal">2010</span><span class="java_separator">,</span><span class="java_literal">10000</span><span class="java_separator">)</span><span class="java_plain"/><br/><span class="java_plain"/><br/></code><br/></div><br/><br/>Now suppose for some modules I would like to close the abstraction for the <code>AuthService</code> as well in addition to freezing <code>PayPal</code> as the <code>CreditService</code>. One alternative will be to define another abstraction as <code>paypalPayment</code> through partial application of <code>RealPayment</code> where we close both the parameters. A better option will be to reuse the <code>paypalPayment</code> abstraction and use explicit function currying. Like ..<br/><br/><div><br/><code><span class="java_plain">scala</span><span class="java_operator">&gt;</span><span class="java_plain"> </span><span class="java_keyword">val</span><span class="java_plain"> paypalPaymentCurried </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_type">Function</span><span class="java_separator">.</span><span class="java_plain">curried</span><span class="java_separator">(</span><span class="java_plain">paypalPayment</span><span class="java_separator">)</span><span class="java_plain"/><br/><span class="java_plain">paypalPaymentCurried</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_separator">(</span><span class="java_type">AuthService</span><span class="java_separator">)</span><span class="java_plain"> </span><span class="java_operator">=&gt;</span><span class="java_plain"> </span><span class="java_separator">(</span><span class="java_plain">java</span><span class="java_separator">.</span><span class="java_plain">util</span><span class="java_separator">.</span><span class="java_type">Date</span><span class="java_separator">)</span><span class="java_plain"> </span><span class="java_operator">=&gt;</span><span class="java_plain"> </span><span class="java_separator">(</span><span class="java_type">Int</span><span class="java_separator">)</span><span class="java_plain"> </span><span class="java_operator">=&gt;</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_plain"> </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_operator">&lt;</span><span class="java_plain">function</span><span class="java_operator">&gt;</span><span class="java_plain"/><br/><span class="java_plain"/><br/></code><br/></div><br/><br/>and closing it partially using the <code>DefaultAuth</code> implementation ..<br/> <br/><div><br/><code><span class="java_plain">scala</span><span class="java_operator">&gt;</span><span class="java_plain"> </span><span class="java_keyword">val</span><span class="java_plain"> paypalPaymentWithDefaultAuth </span><span class="java_operator">=</span><span class="java_plain"> paypalPaymentCurried</span><span class="java_separator">(</span><span class="java_type">DefaultAuth</span><span class="java_separator">(</span><span class="java_literal">"foo"</span><span class="java_separator">))</span><span class="java_plain"/><br/><span class="java_plain">paypalPaymentWithDefaultAuth</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_separator">(</span><span class="java_plain">java</span><span class="java_separator">.</span><span class="java_plain">util</span><span class="java_separator">.</span><span class="java_type">Date</span><span class="java_separator">)</span><span class="java_plain"> </span><span class="java_operator">=&gt;</span><span class="java_plain"> </span><span class="java_separator">(</span><span class="java_type">Int</span><span class="java_separator">)</span><span class="java_plain"> </span><span class="java_operator">=&gt;</span><span class="java_plain"> </span><span class="java_type">RealPayment</span><span class="java_plain"> </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_operator">&lt;</span><span class="java_plain">function</span><span class="java_operator">&gt;</span><span class="java_plain"/><br/><span class="java_plain"/><br/></code><br/></div><br/><br/>The rest of the module can now treat this as an abstraction that uses <code>PayPal</code> for <code>CreditService</code> and <code>DefaultAuth</code> for <code>AuthService</code>. Like Guice we can have hierarchies of modules that injects these settings and publishes a more specialized abstraction to downstream clients.<div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/22587889-5773558157295330139?l=debasishg.blogspot.com" width="1"/></div></div>
    </content>
    <updated>2010-03-01T05:59:16Z</updated>
    <published>2010-02-28T15:20:00Z</published>
    <category scheme="http://www.blogger.com/atom/ns#" term="functional"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="DI"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="scala"/>
    <author>
      <name>Debasish</name>
      <email>ghosh.debasish@gmail.com</email>
      <uri>http://www.blogger.com/profile/01613713587074301135</uri>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-22587889</id>
      <author>
        <name>Debasish</name>
        <email>ghosh.debasish@gmail.com</email>
        <uri>http://www.blogger.com/profile/01613713587074301135</uri>
      </author>
      <link href="http://debasishg.blogspot.com/feeds/posts/full" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <link href="http://debasishg.blogspot.com/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <link href="http://debasishg.blogspot.com/feeds/posts/full?start-index=4&amp;max-results=3" rel="next" type="application/atom+xml"/>
      <link href="http://feeds.feedburner.com/RuminationsOfAProgrammer" rel="self" type="application/atom+xml"/>
      <subtitle>A programmer's blog - will deal with everything that relates to a programmer. Occasionally, it will contain some humour, some politics and some sport news.</subtitle>
      <title>Ruminations of a Programmer</title>
      <updated>2010-03-04T06:54:46Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-2267747408703654731.post-6571196421976972675</id>
    <link href="http://pchiusano.blogspot.com/feeds/6571196421976972675/comments/default" rel="replies" type="application/atom+xml"/>
    <link href="https://www.blogger.com/comment.g?blogID=2267747408703654731&amp;postID=6571196421976972675" rel="replies" type="text/html"/>
    <link href="http://www.blogger.com/feeds/2267747408703654731/posts/default/6571196421976972675" rel="edit" type="application/atom+xml"/>
    <link href="http://www.blogger.com/feeds/2267747408703654731/posts/default/6571196421976972675" rel="self" type="application/atom+xml"/>
    <link href="http://pchiusano.blogspot.com/2010/01/actors-are-not-good-concurrency-model.html" rel="alternate" type="text/html"/>
    <title>Actors are not a good concurrency model</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><i>Actors are not a good concurrency model, and neither are Erlang processes.</i><br/><br/>Wait, <i>what?</i> Isn't Erlang the king of high-uptime distributed systems? If Erlang can do all this using the actor model (Erlang processes are identical to actors in the essential ways, discussed below), isn't there something good about it? Isn't there??<br/><br/>Well, yes. What's good about it is it's better than the dinosaur era alternative of shared-state preemptive multithreading. But so what? Just because the actor model is better than dinosaur era technology doesn't mean we should keep using it. Remember the rise of OO? Before OO, the alternative was programming in languages like C, with pretty much zero support for polymorphism. Any approach to polymorphism was better than nothing at all, so OO's concepts of classes and subtyping was a huge improvement (my opinion is that polymorphism was the real unfilled niche that OO filled). Now that we've learned a bit more, OO has started to seem less appealing to some - parametric polymorphism exists independent of OOP, and bounded polymorphism can be implemented with either typeclasses or a combination of first-class and higher-order modules. It's possible there are some other ideas from OO worth salvaging, but more likely I think OO is just an evolutionary dead-end. <br/><br/>And so it might be with actors. Though I don't know exactly what the replacement looks like yet (I'd like to look at some alternatives and explore ideas in a future post), I do know what's wrong with actors, and that's what I'd like to explore here. But going further, I'd like to use actors as an example to show what's also problematic with side effects and impure functions <i>in general</i>. In doing so I'll try to avoid the usual FP evangelizing and make this a more precise, technical argument. <br/><br/>So what's wrong with actors? The problem which dooms the actor model is that actors are fundamentally <i>not composable</i>. I'm going to leave that term undefined for now, except to say vaguely that entities are composable if we can easily and generally combine their behaviors in some way <i>without having to modify the entities being combined</i>. I think of composability as being the key ingredient necessary for acheiving reuse, and for achieving a combinatorial expansion of what is succinctly expressible in a programming model. (Also see this <a href="http://blog.tmorris.net/why-functional-programming-matters-in-short-prose/">explanation by Tony Morris</a>.) It goes without saying that code reusability is a very desireable property for programs to have, and many of the other virtues of good software engineering end up tying back to reusability - for instance, testability is nothing more than the ability to reuse a component in the context of a test. <br/><br/>So what makes actors not composable? Well, an actor (and an Erlang process) is constructed from a function <code>A =&gt; Unit</code>. That this function returns <code>Unit</code> rather than a meaningful type means that it must <i>hardcode some action to take once the result (<b>whose type is not even shown</b>) is available</i>. It is this unfortunate property that destroys any chance we have at combining actors in any sort of general way like we would in a typical combinator library. <br/><br/>As a simple example, consider the following two actors: 1) an actor that accepts lists of integers and turns the list into a min-heap. 2) An actor that accepts (heap,k) pairs and extracts the top k elements in order from the given heap. Can we write a function that accepts these two actors and returns an actor which accepts (list,k) pairs and pulls out the k minimum elements in sorted order? And generalizing a bit, can we write the more general combining function, the one that doesn't care whether the types are 'heap', 'int' and 'list' or <code>A</code>, <code>B</code> or <code>C</code>?<br/><br/>You just can't do this with actors since you can't make any assumptions about what the actor will do with the result - it might forward it to some other actor, write it to a file, extract from it the missile launch codes and launch the missile, etc. In fact, if you actually try to achieve the composability I'm talking about using actors, what you end up doing is having all actors return their result as a response to their sender, essentially recreating pure functions within the actor model, badly, losing type information in the process. What this should tell you is that actors, if worth anything, might be useful more as a tool for building some other higher-level abstraction. But if that's the case, perhaps we shouldn't even expose actors as a programming model and instead just program directly in the higher-level model.<br/><br/>In practice, I suspect actors are basically only used at the top level of a program, where the damage to composability is minimized, and pure functions (which are composable and work fine at any level of the program) are used everywhere else to achieve reuse. The problem with this approach is when you find out a few months later that what you thought was going to be the top level of your program actually is going to become a very small embedded component in some larger system, and this top level now contains a large amount of unreusable complex logic that must be gutted to work as an embedded component. <br/><br/>The problem I am talking about here is not in any way specific to actors. It applies to any functions with side effects. I claim the only way to achieve true composability is to program with pure functions, and this applies to concurrent programs or to any other programs you'd like to write. (Sometimes, you decide it's worth taking the composability hit and you write functions with side effects - of course I don't object to this in absolutely all cases - but I don't think the fundamental model underlying concurrent and distributed programming should have to take this hit.) <br/><br/>What makes pure functions composable is they are <i>only</i> the logic of the computation. A pure function makes no decisions about what actions to take with the result of the computation, and also makes no decisions about what actions to take before the computation is executed. By keeping these concerns separate, we can reuse the function elsewhere in places where we need to do something different with the result, or where we need to do something different before the computation is executed (for instance, in testing, to generate an instance of the input type rather than obtaining the input from some impure function). <br/><br/>In fact, you can think of any impure function as having three "steps": 1) An "input" side effect, <code>Unit =&gt; B</code>, a pure function <code>(A,B) =&gt; C</code>, and an "output" side effect <code>C =&gt; Unit</code>. It makes perfect software engineering sense to decouple these components - and that is exactly what is done in purely functional programming.<br/><br/>Let's look at a very simple example. Suppose I write a <code>sort</code> function, which sorts the input list in place. For this function, we have no input side effects. The pure core of this function is (conceptually) a sorting function that returns a new list. What is the output side effect? It is to <i>rebind the name that the input list is bound to in the caller to the sorted version of the list</i>. So if the caller were something like <pre>def foo(list: ArrayList[Int]): Foo = { <br/>  ...<br/>  sort(list)<br/>  ...<br/>}</pre>then <code>sort</code> will rebind the name <code>list</code> to the sorted version of that list. Since <code>list</code> is itself a parameter of <code>foo</code>, this rebinding will occur in the caller of <code>foo</code>, and possibly its caller, all the way out to the place where that list was originally declared. The question is, should the sort function really be making the decision about whether to do this? If we let the sort function make this decision, we're allowing it to make an assumption about the caller, namely, that the caller no longer intends to maintain references to the unsorted version of the list (an assumption which, incidentally, is not even tracked by the type system).<br/><br/>Of course, this example of an in-place sort isn't too terrible. The caller just needs to be aware of this side effect and has to adjust its calling convention accordingly. But the lack of uniformity in chaining and combining logic caused by side effects starts to add up very quickly. In practice, what actually occurs in large systems with impure functions sprinkled about is that many functions end up with so many assumptions about their callers (and these assumptions propagate to their callers, as above) that the call graph becomes very static, with functions often having only a single or small number of callers. This makes the system a lot more rigid, more difficult to test without elaborate mocking and dependency injection frameworks (which brings with it its own set of problems), and results in a lot of (often hidden) duplication of logic. <br/><br/>Other simple examples show more obvious destruction of composability. If I write a function that reads a bunch of things from a file <i>and then</i> performs some complex logic, we can't easily reuse that logic elsewhere (unless we want to populate a file first, which may not be what we want). If a function performs some complex logic <i>and then</i> launches the missile, we can't easily reuse that complex logic elsewhere in places where we don't want to launch the missile. <br/><br/>Taking a step back from all this bashing of actors and side effects, I do certainly agree that actors and side effects in general have a certain "intuitive" appeal, a rough analog to how the real world works. But that does not justify their usage as a programming model. The technical challenges of engineering large pieces of software mean that a good programming model may have to tradeoff intuitiveness for attributes like composability. But I suspect even this tradeoff is overplayed - intuitiveness is also often code language for "what system I am familiar with". Once you learn and internalize a different model your ability to reason within that model (and thus, I believe, its intuitiveness) is more a function of the features and formal structure of that model than of some inherent "intuitiveness" metric.<div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/2267747408703654731-6571196421976972675?l=pchiusano.blogspot.com" width="1"/></div></div>
    </content>
    <updated>2010-03-01T04:04:37Z</updated>
    <published>2010-01-15T20:02:00Z</published>
    <category scheme="http://www.blogger.com/atom/ns#" term="haskell"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="programming"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="scala"/>
    <author>
      <name>Paul Chiusano</name>
      <email>noreply@blogger.com</email>
      <uri>http://www.blogger.com/profile/04844651950877109501</uri>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-2267747408703654731</id>
      <author>
        <name>Paul Chiusano</name>
        <email>noreply@blogger.com</email>
        <uri>http://www.blogger.com/profile/04844651950877109501</uri>
      </author>
      <link href="http://pchiusano.blogspot.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <link href="http://www.blogger.com/feeds/2267747408703654731/posts/default" rel="self" type="application/atom+xml"/>
      <link href="http://pchiusano.blogspot.com/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <subtitle>(Stuff worth thinking about)</subtitle>
      <title>Prettt-tty, pretty, pretty good!</title>
      <updated>2010-03-09T16:18:52Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/418488973</id>
    <link href="http://code.technically.us/post/418488973" rel="alternate" type="text/html"/>
    <title>"So what’s wrong with actors? The problem which dooms the actor model is that actors are..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“So what’s wrong with actors? The problem which dooms the actor model is that actors are fundamentally <em>not composable</em>.”<br/><br/> - <em><a href="http://pchiusano.blogspot.com/2010/01/actors-are-not-good-concurrency-model.html">Bad actors</a></em></div>
    </summary>
    <updated>2010-02-28T23:01:56Z</updated>
    <category term="Actors"/>
    <category term="Concurrency"/>
    <category term="Functional Programming"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:44Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/418338953</id>
    <link href="http://code.technically.us/post/418338953" rel="alternate" type="text/html"/>
    <title>"Silicon Valley emerged as the world capital of high-tech development … due largely to the..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“Silicon Valley emerged as the world capital of high-tech development … due largely to the horizontal networks of informal and formal cooperation that developed among fledgling companies … and, <strong>perhaps just as important, beers after work</strong>.”<br/><br/> - <em><a href="http://books.google.com/books?id=rd2ibodep7UC&amp;pg=PA324&amp;lpg=PA324&amp;dq=%22perhaps+just+as+important,+beers+after+work%22&amp;source=bl&amp;ots=G2Jeo1spQ_&amp;sig=1gaoYdSuwkARKxeqaGWJqxxCcaI&amp;hl=en&amp;ei=HdGKS5IG0ciUB9vlmdEB&amp;sa=X&amp;oi=book_result&amp;ct=result&amp;resnum=1&amp;ved=0CAYQ6AEwAA#v=onepage&amp;q=%22perhaps%20just%20as%20important%2C%20beers%20after%20work%22&amp;f=false"><em>Bowling Alone</em></a> (Don’t worry, we’ve <a href="http://www.meetup.com/Functional-Alcoholics/">got New York covered</a>.)</em></div>
    </summary>
    <updated>2010-02-28T21:45:00Z</updated>
    <category term="New York"/>
    <category term="Meetups"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T19:40:43Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/418179012</id>
    <link href="http://code.technically.us/post/418179012" rel="alternate" type="text/html"/>
    <title>Mobile cambrian explosion births two-headed beast</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><br/><br/><p><a href="http://www.blogeee.net/2010/02/une-prise-en-main-video-du-msi-dual-screen/">Mobile cambrian explosion births two-headed beast</a></p></div>
    </summary>
    <updated>2010-02-28T20:21:00Z</updated>
    <category term="Mobile"/>
    <category term="Windows"/>
    <category term="MSI"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-09T04:40:40Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-1673113361032868171.post-735483212096690274</id>
    <link href="http://suereth.blogspot.com/feeds/735483212096690274/comments/default" rel="replies" type="application/atom+xml"/>
    <link href="https://www.blogger.com/comment.g?blogID=1673113361032868171&amp;postID=735483212096690274" rel="replies" type="text/html"/>
    <link href="http://www.blogger.com/feeds/1673113361032868171/posts/default/735483212096690274" rel="edit" type="application/atom+xml"/>
    <link href="http://www.blogger.com/feeds/1673113361032868171/posts/default/735483212096690274" rel="self" type="application/atom+xml"/>
    <link href="http://suereth.blogspot.com/2010/02/actor-styles-oo-functional-or-blended.html" rel="alternate" type="text/html"/>
    <title>Actor Styles... OO, Functional or Blended...</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">I had the privilege of a free cup of coffee with David Pollak when I was in the bay area recently.  He was describing his new goat-rodeo library when he showed me the interface for his "Worker" class (which is similar to an Actor class).   He made a comment about "being annoyed with writing all those case statements" in actors, and so figured out a method using reflection and method overloading to define an actor that merely responds to all messages it receives.   I'm sure there was more to it than this, but I believe he's partially solved an OO issue I complained about in an <a href="http://suereth.blogspot.com/2009/04/partial-functions-inheritance.html">earlier blog about partial functions and inheritance</a>.  Let's take a bit to remember that solution to the issue.<br/><br/>The crux of the problem is the blend of OO and functional.   Functions are composable.  You can have one function take another and compose them all day long.   Objects are also composable.  One object can take another object and utilize it all day long.   Methods (functions attached to objects) are not as composable.  Scala traits give you means to compose with them, but all your composition is done at instantiation time (i.e. mixing in traits, inheritance, etc.).  Now we come to the main issue.  An Actor is an abstract class that you subclass.  This leads one to compose behavior through traits (similar to other OO-style programs in Scala), but the method of doing so is a bit strange.   We start with our "FinalMixinActor" class<br/><br/><pre class="brush: scala">trait BaseActor extends Actor {<br/><br/>   def makeMessageHandler() : PartialFunction[Any,Unit] = {<br/>      case x =&gt; //Unhandled message, assume design flaw!<br/>            error("Unknown message: " + x)    <br/>   }<br/>}<br/>trait FinalActor extends BaseActor[T] {<br/>   lazy val messageHandler = makeMessageHandler()<br/>   override def act() {<br/>       Actor.loop {<br/>          react messageHandler<br/>       }<br/>   }<br/>}<br/></pre><br/>These two classes provide us with a way to compose actors.  We make sure all behavior extends the BaseActor, and we make sure when creating an actor that "FinalActor" gets mixed in *last* in the inheritance linearization.   This means that when FinalActor calls "makeMessageHandler", all the standard OO inheritance has a chance to kick and pull the behaviors you've composed.  Let's see an example of composing an actor with two functionalities....<br/><br/><pre class="brush: scala">case class Ping()<br/>case class Pong()<br/><br/>trait PingPongBehavior extends BaseActor {<br/>   def makeMessageHandler() : PartialFunction[Any,Unit] = {<br/>      val myBehavior : PartialFunction[Any,Unit] = {<br/>         case Ping() =&gt; sender ! Pong()<br/>      }<br/>      return myBehavior orElse super.makeMessageHandler()<br/>   }<br/>}<br/></pre><br/>This is our "PingPong" behavior actor for sending/receiving Ping/Pong messages.   As you can see in the makeMessageHandler... we're manually converting functional composition into inheritance composition.  It does give us flexibility if we'd like our behavior to run last. Let's create our second piece of behavior...<br/><br/><br/><pre class="brush: scala">case class Shutdown()<br/><br/>trait RemoteControlBehavior extends BaseActor {<br/>   def makeMessageHandler() : PartialFunction[Any,Unit] = {<br/>      val myBehavior : PartialFunction[Any,Unit] = {<br/>         case Shutdown() =&gt; Actor.exit<br/>      }<br/>      return myBehavior orElse super.makeMessageHandler()<br/>   }<br/>}<br/></pre><br/>This is a simple actor that just lets us send a shutdown command to an actor instead of relying on the actor knowing when to shut itself down (or linking it).  Not necessarily useful, but it will help illustrate our next point.   Let's create an actor that  mixes in both these functionalities.<br/><br/><br/><pre class="brush: scala">val myActor = new PingPongBehavior with RemoteControlBehavior with FinalActor<br/>myActor.start<br/></pre><br/>Notice how we *have* to mix in FinalActor last so the composition of makeMessageHandler is done correctly.  This also prevents other actors from adding behavior in their act methods....<br/><br/>Anyway, it's a decent method of allowing mixin behavior of actors.  It doesn't have much type safety, but the Scala standard actors library actually makes you jump through some hoops to get type-safety anyway (plus all their samples are against Any... so it seems they tend to encourage this...)<br/><br/><br/>Now for a look at how Goat-Rodeo helps solve this.   First, Goat-Rodeo uses a type-safe message passing API, including knowing whether a message is allowed a response, and the type of that response.  Let's take a look at a boiled down version of the <a href="https://www.assembla.com/wiki/show/goat_rodeo/Modeling_a_Skitter_User">twitter-clone sample on goat-rodeo's wiki</a>.  I've used elipses to ignore implementation details of Goat Rodeo:<br/><br/><br/><pre class="brush: scala">class UserWorker(...) extends WorkerImpl[..., UserMsg](...) {<br/>  /**<br/>   * handle the Follow message<br/>   */<br/>  def doFollow(msg: Follow) {<br/>     ...<br/>  }<br/>}<br/></pre><br/>As you can see, it's just a method.  Goat-Rodeo looks for methods with "do" or "handle" in the name and constructs a PartialFunction for the actor-behavior.   The <pre>Follow</pre>class must be a subclass of <pre>UserMsg</pre>as Goat-Rodeo is also strongly typed.  Because <pre>doFollow</pre>returns Unit, goat-rodeo knows that there is no return expected with this message.  If you'd like to handle different messages, simple use method overloading.  The best part, if we'd like to use OO inheritance to compose behavior, we can do so directly now...<br/><br/><pre class="brush: scala">class UserWorkerPlus(...) extends UserWorker(...) {<br/>  /**<br/>   * handle the Follow message<br/>   */<br/>  def doFollow(msg: Follow) {<br/>     println("ZOMG!!!!!!!!!!!!!!!!!!")<br/>     super.doFollow(msg)<br/>  }<br/>}<br/></pre><br/>That should be a lot more comfortable to OO developers.  With some type trickery you could even create the "management" behavior traits and mix them into "workers" as needed.  It still leaves some things to be desired.  e.g. when I compose partial functions in a purely functional sense, I can have the type-checker automatically infer what the new signature of a partial function should be after an orElse.  With both of these methods, that is not possible.  For the pure functional users, I'd recommend creating actors using something akin to this function (or you should just use scalaz, as their actors library is very well done):<br/><br/><pre class="brush: scala">import scala.actors.Actor<br/>import scala.actors.Channel<br/><br/>class ChanneledActor[T](f : PartialFunction[T,Unit]) extends Actor {<br/>  val typedChannel = new Channel[T](this)<br/>      def act() {<br/>         Actor.loop {<br/>            typedChannel react f<br/>         }<br/>      }<br/>}<br/><br/>def makeActor[T, U](f : PartialFunction[T,U]) : Channel[T] = {<br/>   val a = new ChanneledActor(f andThen ( x =&gt; () ))  //Ignore results...<br/>   a.start<br/>   a.typedChannel<br/>}<br/></pre><br/>This will let you compose partial functions in a functional style and let the type-checker figure out the signature.  Finally when you create an Actor with the makeActor method, it will return the type-safe channel to send messages with.  Here's an example interpreter session:<br/><br/><pre class="brush: scala">scala&gt; makeActor[Int,Unit] { case x : Int =&gt; println("HAI") }                   <br/>res3: scala.actors.Channel[Int] = scala.actors.Channel@154f77b<br/><br/>scala&gt; res3 ! "HAI"<br/>&lt;console&gt;:10: error: type mismatch;<br/> found   : java.lang.String("HAI")<br/> required: Int<br/>       res3 ! "HAI"<br/>              ^<br/><br/>scala&gt; res3 ! 5    <br/><br/>scala&gt; HAI<br/></pre><br/><br/>Anyway, if you truly desire a functional approach to actors, you should look into Scalaz, as they've done it right.   If you desire a hybrid or an OO approach, I hope I've helped outline the details for you.   I'm very interested to see how all these libraries evolve over time, and kudos to David Pollak for goat-rodeo.<div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/1673113361032868171-735483212096690274?l=suereth.blogspot.com" width="1"/></div></div>
    </content>
    <updated>2010-02-28T15:47:18Z</updated>
    <published>2010-02-28T15:12:00Z</published>
    <category scheme="http://www.blogger.com/atom/ns#" term="actors"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="functional vs. oo"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="goat rodeo"/>
    <author>
      <name>J. Suereth</name>
      <email>noreply@blogger.com</email>
      <uri>http://www.blogger.com/profile/10176429810160937559</uri>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-1673113361032868171</id>
      <author>
        <name>J. Suereth</name>
        <email>noreply@blogger.com</email>
        <uri>http://www.blogger.com/profile/10176429810160937559</uri>
      </author>
      <link href="http://suereth.blogspot.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <link href="http://www.blogger.com/feeds/1673113361032868171/posts/default" rel="self" type="application/atom+xml"/>
      <link href="http://suereth.blogspot.com/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <link href="http://www.blogger.com/feeds/1673113361032868171/posts/default?start-index=26&amp;max-results=25" rel="next" type="application/atom+xml"/>
      <subtitle>My thoughts and/or rants on Software Development.</subtitle>
      <title>Rants, Raves and Ridicule</title>
      <updated>2010-03-02T09:43:34Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/414101798</id>
    <link href="http://code.technically.us/post/414101798" rel="alternate" type="text/html"/>
    <title>"i will publish this book by hook or by crook. i’m now several hundred hours into the project..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“i will publish this book by hook or by crook. i’m now several hundred hours into the project and my technical review team is also into the project by dozens of hours. i’m not just going to waste that time. To be clear, the book project is on github <a href="http://github.com/leithaus/XTrace/tree/monadic/src/main/book/content/">here</a>. i’m committed to 3 pages per day (except between 19 Mar 2010 - 28 Mar 2010 where i will be on a Guitar Craft course and completely incommunicado) until the first draft is complete. You all can watch the progress.”<br/><br/> - <em><a href="http://old.nabble.com/-scala--Fwd:-Pro-Scala-ts27721953.html">Allegedly <em>too deep</em> Scala  book being written on github </a></em></div>
    </summary>
    <updated>2010-02-26T23:24:34Z</updated>
    <category term="Apress"/>
    <category term="Publihing"/>
    <category term="Scala"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-08T17:40:46Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/413704707</id>
    <link href="http://code.technically.us/post/413704707" rel="alternate" type="text/html"/>
    <title>Functional Alcoholics Undeterred by Legendary Snowstorm</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><img src="http://28.media.tumblr.com/tumblr_kygqgl5UB01qb6dplo1_500.jpg"/><br/><br/><p><a href="http://www.meetup.com/Functional-Alcoholics/calendar/12504108/">Functional Alcoholics Undeterred by Legendary Snowstorm</a></p></div>
    </summary>
    <updated>2010-02-26T19:07:00Z</updated>
    <category term="New York"/>
    <category term="Functional Programming"/>
    <category term="Meetup"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-08T17:01:04Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/413330415</id>
    <link href="http://code.technically.us/post/413330415" rel="alternate" type="text/html"/>
    <title>"Giving them a patent on this idea is lunacy. But the whole idea of software patents is lunacy. We..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“Giving them a patent on this idea is lunacy. But the whole idea of software patents is lunacy. We need to eliminate software patents and we need to do it now.”<br/><br/> - <em><a href="http://www.avc.com/a_vc/2010/02/more-patent-nonsense.html">Facebook Patents News, Feeds</a></em></div>
    </summary>
    <updated>2010-02-26T14:39:51Z</updated>
    <category term="Software Patents"/>
    <category term="Dumb Property"/>
    <category term="Facebook"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-08T06:00:45Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/413258461</id>
    <link href="http://code.technically.us/post/413258461" rel="alternate" type="text/html"/>
    <title>Outside.in looking for Scala coders in New York</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://outside.in/about#5.1">Outside.in looking for Scala coders in New York</a>: <p>Or more fully “Ruby, Scala, Geo, NLP, Ad Serving &amp; Optimization”. Are you their next “<a href="http://en.wikipedia.org/wiki/Superstar_(film)"><em>Superstar</em></a> Software Engineer”???</p></div>
    </summary>
    <updated>2010-02-26T13:42:00Z</updated>
    <category term="Scala"/>
    <category term="New York"/>
    <category term="Kitchen Sinks"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-08T01:00:48Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/409663151</id>
    <link href="http://code.technically.us/post/409663151" rel="alternate" type="text/html"/>
    <title>sbt-eclipsify 0.5.0 - sbt plugin to generate project metadata for you-know-what</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://implicit.ly/sbt-eclipsify-050">sbt-eclipsify 0.5.0 - sbt plugin to generate project metadata for you-know-what</a></div>
    </summary>
    <updated>2010-02-24T21:23:52Z</updated>
    <category term="sbt"/>
    <category term="Eclipse"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-07T15:40:50Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/409455055</id>
    <link href="http://code.technically.us/post/409455055" rel="alternate" type="text/html"/>
    <title>Passing arguments to unit tests in sbt</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://jackcoughonsoftware.blogspot.com/2010/02/sbt-and-test-arguments.html">Passing arguments to unit tests in sbt</a></div>
    </summary>
    <updated>2010-02-24T18:59:15Z</updated>
    <category term="Tests"/>
    <category term="sbt"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-05T21:40:48Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-34927953.post-2392208901439516075</id>
    <link href="http://jackcoughonsoftware.blogspot.com/feeds/2392208901439516075/comments/default" rel="replies" type="application/atom+xml"/>
    <link href="http://jackcoughonsoftware.blogspot.com/2010/02/sbt-and-test-arguments.html#comment-form" rel="replies" type="text/html"/>
    <link href="http://www.blogger.com/feeds/34927953/posts/default/2392208901439516075" rel="edit" type="application/atom+xml"/>
    <link href="http://www.blogger.com/feeds/34927953/posts/default/2392208901439516075" rel="self" type="application/atom+xml"/>
    <link href="http://jackcoughonsoftware.blogspot.com/2010/02/sbt-and-test-arguments.html" rel="alternate" type="text/html"/>
    <title>SBT and Test Arguments</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><br/><br/>If you want to pass arguments to tests in SBT, you've come to the right place. First know this - it only works in certain situations, it's a bit crufty, and its subject to change. But I'll try to keep this page up to date if it does change.<br/><br/>Another important note, if you want to pass arguments at the sbt command line, you can only do it for test-quick, and test-only (I think). It doesn't work for the default "test" command. This is a bit unfortunate, but there is a workaround (not a very good one, but at least it exists).<br/><br/>A final note: it works with ScalaTest and ScalaCheck. I haven't tested any of this with Specs, and not sure if Eric has implemented argument handling.<br/><br/><h4>Passing Args to ScalaTest from the Command Line</h4><br/>Let's say you have this little ScalaTest class that uses both params and tags:<br/><pre><br/>import org.scalatest.fixture.FixtureFunSuite<br/>import org.scalatest.Tag<br/><br/>class WickedCoolTest extends FixtureFunSuite{<br/> type FixtureParam = Map[String,Any]<br/> override def withFixture(test: OneArgTest) {<br/>   test(test.configMap)<br/> }<br/> test("1", Tag("dood1")){ conf =&gt; println("dood1: " + conf) }<br/> test("2", Tag("dood2")){ conf =&gt; println("dood2: " + conf) }<br/> test("3", Tag("dood3")){ conf =&gt; println("dood3: " + conf) }<br/>}</pre><br/>To run all tests in in this class use:<br/><pre><br/>test-only WickedCoolTest<br/></pre><br/>To run only tests tagged with "dood1" use:<br/><pre><br/>test-only WickedCoolTest -- -n dood1<br/></pre><br/>To run tests tagged with dood1 or dood2, use:<br/><pre><br/>test-only WickedCoolTest -- -n "dood1 dood2"<br/></pre><br/>To run all tests except for tests tagged with dood2, run:<br/><pre><br/>test-only WickedCoolTest -- -l dood2<br/></pre><br/>To run all tests except for tests tagged with dood2 dood3, run:<br/><pre><br/>test-only WickedCoolTest -- -l "dood2 dood3"<br/></pre><br/>To pass configuration parameters to a test, use:<br/><pre><br/>test-only WickedCoolTest -- -Danswer=42<br/></pre><br/>To pass many config params, add more -D's:<br/><pre><br/>test-only WickedCoolTest -- -Danswer=42 -DrealAnswer=54<br/></pre><br/>Tags and parameters can be used in combination, like so:<br/><pre><br/>test-only WickedCoolTest -- -n "dood dood2" -Dhey=you -Dm=f<br/></pre><br/>This runs only tests tagged with dood or dood2 and produces the following output:<br/><br/>dood: Map(hey -&gt; you, m -&gt; f)<br/>dood2: Map(hey -&gt; you, m -&gt; f)<br/><br/><h4>Passing Args to ScalaCheck from the Command Line</h4><br/>I'll spare you the entire example and just get to the point here.<br/><br/>To set the minimum number of successful tests, use '-s'<br/><pre><br/>&gt; test-only *IntParallelArrayCheck -- -s 5000<br/>...<br/>[info] == scala.collection.parallel.mutable.IntParallelArrayCheck ==<br/>[info] OK, passed 5000 tests.<br/></pre><br/><br/>The rest of the examples are very similar. Consult ScalaCheck itself for further documentation. <br/><ul><br/><li>-s (minSuccessfulTests): Number of tests that must succeed in order to pass a property<br/></li><li>-d (maxDiscardedTests): Number of tests that can be discarded before ScalaCheck stops testing a property<br/></li><li>-n (minSize): Minimum data generation size<br/></li><li>-x (maxSize): Maximum data generation size<br/></li><li>-w (workers): Number of threads to execute in parallel for testing<br/></li><li>-z (wrkSize): Amount of work each thread should do at a time<br/></li></ul><br/><h4>Default Arguments</h4><br/>Maybe you want to pass default arguments to your test framework of choice. That is, you want to pass the same arguments every time you run your tests (and still be able to pass more dynamically, if you wish). You can do this too, by adding elements to 'testOptions'. Doing so will take effect when you run sbt test, sbt test-only, sbt test-quick, etc. <br/><br/>Let's say you want the minimum number of ScalaCheck passing tests to be 5000 every time you run ScalaCheck. Here is how you do that: <br/><pre><br/>override def testOptions = <br/>  super.testOptions ++ <br/>  Seq(TestArgument(TestFrameworks.ScalaCheck, "-s", "5000")) <br/></pre><br/><br/>Or maybe you only ever want to run your fast ScalaTest tests.<br/><pre><br/>override def testOptions = <br/>  super.testOptions ++ <br/>  Seq(TestArgument(TestFrameworks.ScalaTest, "-n", "fast")) <br/></pre><br/><h4>Custom Test Tasks</h4><br/>Maybe you have some test that you run all the time. At the sbt command line, instead of saying &gt; test-quick blah.blah.Blah, you just want to say: &gt; blah.<br/><br/>You can do that too, and you can pass args to it dynamically, and you get the default arguments as well. You'll have to take the following code and put it into your sbt file. It's ugly, I know, but the results are nice. <br/><pre><br/>lazy val blah = singleTestTask("blah.blah.Blah")<br/> <br/>private def singleTestTask(className: String) = task { args =&gt;<br/>  defaultTestTask(TestFilter(_ == className) :: <br/>   testOptions.toList ::: ScalaTestArgs(args))<br/>}<br/><br/>private def newScalaTestArg(l: String*) = <br/>  TestArgument(TestFrameworks.ScalaTest, l:_*)<br/><br/>private def ScalaTestArgs(args: Seq[String]): List[TestArgument] = {<br/>  def KVArgs(args: Seq[String]): TestArgument = <br/>    newScalaTestArg(args.map("-D" + _):_*)<br/>  def tagsFromArgs(tags: Seq[String]): List[TestArgument] = {<br/>    if (tags.isEmpty) Nil else <br/>      List(newScalaTestArg("-n", tags.mkString(" ")))<br/>  }<br/>  val (kvs, tags) = args.partition(_.contains("="))<br/>  KVArgs(kvs.toSeq) :: tagsFromArgs(tags.toSeq)<br/>}</pre><br/><h4>Subclasses</h4><br/>Finally, maybe you want to set up tasks like 'test-fast' and 'test-slow' which only run your fast and slow tests. Let's imagine that you've created a trait called blah.blah.SlowTest and all of your slow tests extend that trait. Tests that don't extend SlowTest are considered to be in the fast group. With the code below, at the sbt command line you'll be able to say &gt; test-fast, and &gt; test-slow. <br/><br/>Again, it's a bit ugly to put this stuff in your sbt project file, but it works for now, until I come up with a better plan :)<br/><pre><br/>lazy val testSlow = <br/>  runSubclassesOf("org.nlogo.util.SlowTest")<br/>lazy val testFast = <br/>  runEverythingButSubclassesOf("org.nlogo.util.SlowTest")<br/><br/>private def runSubclassesOf(className: String) = {<br/>  val subclass: Boolean =&gt; Boolean = x =&gt; x<br/>  subclassTest(className, subclass)<br/>}<br/>  <br/>private def runEverythingButSubclassesOf(className: String) = {<br/>  val notSubclass: Boolean =&gt; Boolean = x =&gt; ! x<br/>  subclassTest(className, notSubclass)<br/>}<br/><br/>private def subclassTest(className: String, <br/>                         subclassCheck: Boolean =&gt; Boolean) = task { <br/>  args =&gt;<br/>  lazy val jars = <br/>    testClasspath.get.toList.map(_.asURL).toArray[java.net.URL]<br/>  lazy val loader = <br/>    new java.net.URLClassLoader(jars,buildScalaInstance.loader)<br/>  def clazz(name: String) = Class.forName(name, false, loader)<br/>  lazy val superClass = clazz(className)<br/>  def filter = <br/>    TestFilter(c =&gt; <br/>      subclassCheck(superClass.isAssignableFrom(clazz(c))))<br/>  defaultTestTask<br/>    (filter :: testOptions.toList ::: ScalaTestArgs(args))<br/>}</pre><br/><br/><h4>Yeah...</h4><br/>Let me know if you have any issues with any of this, I'll be happy to help. I put it together pretty quickly. If there are any glaring errors or omissions, please tell.<div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/34927953-2392208901439516075?l=jackcoughonsoftware.blogspot.com" width="1"/></div></div>
    </content>
    <updated>2010-02-24T17:59:24Z</updated>
    <published>2010-02-24T17:01:00Z</published>
    <author>
      <name>Jack Cough</name>
      <email>noreply@blogger.com</email>
      <uri>http://www.blogger.com/profile/04509343962912103631</uri>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-34927953</id>
      <author>
        <name>Jack Cough</name>
        <email>noreply@blogger.com</email>
        <uri>http://www.blogger.com/profile/04509343962912103631</uri>
      </author>
      <link href="http://jackcoughonsoftware.blogspot.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <link href="http://www.blogger.com/feeds/34927953/posts/default" rel="self" type="application/atom+xml"/>
      <link href="http://jackcoughonsoftware.blogspot.com/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <link href="http://www.blogger.com/feeds/34927953/posts/default?start-index=26&amp;max-results=25" rel="next" type="application/atom+xml"/>
      <subtitle>Thoughts about Languages.</subtitle>
      <title>Jack Cough on Software</title>
      <updated>2010-03-08T11:53:57Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/409345774</id>
    <link href="http://code.technically.us/post/409345774" rel="alternate" type="text/html"/>
    <title>Riak: Link Walking By Example</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://blog.basho.com/2010/02/24/link-walking-by-example/">Riak: Link Walking By Example</a></div>
    </summary>
    <updated>2010-02-24T17:31:24Z</updated>
    <category term="Riak"/>
    <category term="Datastores"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-05T16:40:50Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/408357040</id>
    <link href="http://code.technically.us/post/408357040" rel="alternate" type="text/html"/>
    <title>"It turns out that the International Intellectual Property Alliance, an umbrella group for..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“It turns out that the International Intellectual Property Alliance, an umbrella group for organisations including the MPAA and RIAA, has requested with the US Trade Representative to consider countries like Indonesia, Brazil and India for its ‘Special 301 watchlist’ because they use open source software.”<br/><br/> - <em><a href="http://www.guardian.co.uk/technology/blog/2010/feb/23/opensource-intellectual-property">Free software challenges “intellectual property” construct</a></em></div>
    </summary>
    <updated>2010-02-24T04:06:00Z</updated>
    <category term="Free Software"/>
    <category term="Dumb Property"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-04T23:40:40Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/407562527</id>
    <link href="http://code.technically.us/post/407562527" rel="alternate" type="text/html"/>
    <title>Web Development in the Scala World Outside of Lift -  New York Scala Enthusiasts</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://www.meetup.com/New-York-Scala-Enthusiasts/calendar/12651402/">Web Development in the Scala World Outside of Lift -  New York Scala Enthusiasts</a>: <blockquote>
  <p>Peter will talk about … The work he’s been doing to integrate Scala into The Play Framework … And his very own Pinky, a REST/MVC glue web framework built on top of Guice and Guice Servlet 2.0</p>
</blockquote></div>
    </summary>
    <updated>2010-02-23T21:13:00Z</updated>
    <category term="Meetup"/>
    <category term="Play"/>
    <category term="Scala"/>
    <category term="Web"/>
    <category term="New York"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-04T13:00:40Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/407135584</id>
    <link href="http://code.technically.us/post/407135584" rel="alternate" type="text/html"/>
    <title>"It does not try to hide relational database concepts from the developer, on the contrary it exposes..."</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">“It does not try to hide relational database concepts from the developer, on the contrary it exposes them as first class citizens so they can be easily leveraged from within the Scala language.”<br/><br/> - <em><a href="http://max-l.github.com/Squeryl/index.html"><strong>Squeryl</strong>: a functional bridge between Scala objects and relational data</a></em></div>
    </summary>
    <updated>2010-02-23T15:45:00Z</updated>
    <category term="SQL"/>
    <category term="Scala"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-03T22:40:47Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/407034259</id>
    <link href="http://code.technically.us/post/407034259" rel="alternate" type="text/html"/>
    <title>iNanny cracks whip</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Right after Apple made us ridicule their sorry quest for a <a href="http://code.technically.us/post/405937059/god-hires-assistant">mobile “bring-up” loser</a>, Phil Schiller has gone and <a href="http://www.nytimes.com/2010/02/23/technology/23apps.html">blabbed a bunch of 1984 crap to the <em>Times</em></a>, which he foreshadowed back in <a href="http://technically.us/code/archive/2009/11/#item-6542">November</a>. It’s awesome.</p>

<p>See, just over the last few weeks the world has gotten really Naughty. Schiller himself has blushed at</p>

<blockquote>
  <p>an increasing number of apps containing very objectionable content.</p>
</blockquote>

<p>Oh my! Let’s just hope Schiller was not forced to evaluate each and every one, in private. Apparently this is a Unique Crisis:</p>

<blockquote>
  <p>It came to the point where we were getting customer complaints from women who found the content getting too degrading and objectionable, as well as parents who were upset with what their kids were able to see.</p>
</blockquote>

<p>Now hold on a sec, Mr. Schiller. Women have been known to disagree with each other on many things, including what is <em>too</em> degrading (?) or objection-able. It’s a little iffy to completely ban products based on what you say the women say. And those parents, maybe you should tell them about the famous “parental controls” you now build into everything?</p>

<blockquote>
  <p>We obviously care about developers, but in the end have to put the needs of the kids and parents first.</p>
</blockquote>

<p>Much like it has always been necessary to ban racy items from bookshelves, computers, and the internet because some anonymous prude in the employ of a private business was offended/aroused.</p>

<p>But what about <em>Sports Illustrated</em>’s beloved mainstream pr0n—which (some) women have been <a href="http://lala.com/zCuTI">objecting to</a> for ages—is there some kind of special, or <em>double</em>, standard in place to protect our big old-media brands?</p>

<blockquote>
  <p>The difference is this is a well-known company with previously published material available broadly in a well-accepted format.</p>
</blockquote>

<p>Well that’s a relief. <em>S.I.</em> is just appropriately degrading to women.</p>

<p>On the other hand if you want a software platform that isn’t run like a bought-off nursery, <a href="http://technically.us/code/x/avoiding-the-inanny/">there are alternatives</a>.</p></div>
    </summary>
    <updated>2010-02-23T14:21:00Z</updated>
    <category term="Apple"/>
    <category term="Twerps"/>
    <category term="iNanny"/>
    <category term="iPhone"/>
    <category term="pr0n"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-02T20:20:56Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-6818189468244276547.post-5909409295908854589</id>
    <link href="http://quoiquilensoit.blogspot.com/feeds/5909409295908854589/comments/default" rel="replies" type="application/atom+xml"/>
    <link href="https://www.blogger.com/comment.g?blogID=6818189468244276547&amp;postID=5909409295908854589" rel="replies" type="text/html"/>
    <link href="http://www.blogger.com/feeds/6818189468244276547/posts/default/5909409295908854589" rel="edit" type="application/atom+xml"/>
    <link href="http://www.blogger.com/feeds/6818189468244276547/posts/default/5909409295908854589" rel="self" type="application/atom+xml"/>
    <link href="http://quoiquilensoit.blogspot.com/2010/02/dynamically-creat-spring-beans.html" rel="alternate" type="text/html"/>
    <title>Dynamically create spring bean</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">I used this in a dbunit test to create a dummy service layer bean dynamically. <br/><br/>The rest of the beans were configured in xml files. I created this bean dynamically in the test so that I didn't have to pollute the xml config.<br/><br/><pre class="brush: java">// Dynamically create a DummyServiceToMakeCodeTransactional bean and register with spring<br/>     DefaultListableBeanFactory autowireCapableBeanFactory = (DefaultListableBeanFactory) getApplicationContext().getAutowireCapableBeanFactory();<br/>     AbstractBeanDefinition beanDefinition =<br/>          BeanDefinitionBuilder.rootBeanDefinition(<br/>               DummyServiceToMakeCodeTransactional.class.getName()).getBeanDefinition();<br/>     autowireCapableBeanFactory.registerBeanDefinition("DummyService", beanDefinition);<br/>     DummyServiceToMakeCodeTransactional bean = (DummyServiceToMakeCodeTransactional) <br/>     getApplicationContext().getBean("DummyService");<br/><br/></pre><div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/6818189468244276547-5909409295908854589?l=quoiquilensoit.blogspot.com" width="1"/></div></div>
    </content>
    <updated>2010-02-23T12:08:15Z</updated>
    <published>2010-02-23T12:06:00Z</published>
    <author>
      <name>Tim Azzopardi</name>
      <email>noreply@blogger.com</email>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-6818189468244276547</id>
      <author>
        <name>Tim Azzopardi</name>
        <email>noreply@blogger.com</email>
      </author>
      <link href="http://quoiquilensoit.blogspot.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <link href="http://www.blogger.com/feeds/6818189468244276547/posts/default" rel="self" type="application/atom+xml"/>
      <link href="http://quoiquilensoit.blogspot.com/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <title>Quoi qu'il en soit</title>
      <updated>2010-03-03T10:11:02Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/405937059</id>
    <link href="http://code.technically.us/post/405937059" rel="alternate" type="text/html"/>
    <title>God hires assistant</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://mashable.com/2010/02/22/iphone-os-devices/">God hires assistant</a>: <blockquote>
  <p>The job posting from the Cupertino, CA, company specifically calls for an engineering manager to handle “platform bring-up.” In the job description, Apple states that it’s looking for a manager “to lead a team focused on bring-up of iPhone OS on new platforms.” It seems like Apple wants some outside talent with very strong technical experience, especially when it comes to bringing software onto multiple hardware devices.</p>
</blockquote>

<p>Whatever a “bring-up” is, this job posting is weird because Apple is supposed to have the next decade specked out already, if not in product testing. We (consumers) learn about the future of computing at Apple events, when they decide to tell us. Our 2015 portable computers will be descendants of Apple’s “iPad” invention, like those copy-cat props in Avatar and Minority Report.</p>

<p>But this job posting would imply that Apple is in a competitive marketplace where other companies have ideas, too. That open mobile platforms may be on the verge of a cambrian explosion of unexpected, unplanned, useful devices that will be difficult to fight off with a platform that is locked down in both hardware (old news!) and software (evil news!). That the world hasn’t been standing still in the two years that the iPhone has … grown. (<a href="http://waffle.wootest.net/2010/02/03/displays-meant/">Not that there’s anything wrong with that</a>.)</p></div>
    </summary>
    <updated>2010-02-23T01:17:00Z</updated>
    <category term="Mobile"/>
    <category term="Apple"/>
    <category term="iPhone"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-02T17:20:45Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-22587889.post-8752276955215978661</id>
    <link href="http://debasishg.blogspot.com/feeds/8752276955215978661/comments/default" rel="replies" type="application/atom+xml"/>
    <link href="https://www.blogger.com/comment.g?blogID=22587889&amp;postID=8752276955215978661" rel="replies" type="text/html"/>
    <link href="http://www.blogger.com/feeds/22587889/posts/default/8752276955215978661" rel="edit" type="application/atom+xml"/>
    <link href="http://debasishg.blogspot.com/feeds/posts/default/8752276955215978661" rel="self" type="application/atom+xml"/>
    <link href="http://debasishg.blogspot.com/2010/02/dsl-grow-your-syntax-on-top-of-clean.html" rel="alternate" type="text/html"/>
    <title>DSL : Grow your syntax on top of a clean semantic model</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">A DSL primarily has two components - <i>a semantic model</i> that abstracts the underlying domain and a <i>linguistic abstraction</i> on top that speaks the dialect of the user. The semantic model is the model of the domain where you can apply all the principles of DDD that Eric Evans espouses. And the linguistic abstraction is a thin veneer on top of the underlying model. The more well abstracted your model is, easier will be the construction of the layer on top of it. Here's a general architecture of a DSL engineering stack :-<br/><br/><a href="http://2.bp.blogspot.com/_r-NJO1NMiu4/S4IJvohPhGI/AAAAAAAAAKc/Xx_hy4ZBCXI/s1600-h/ext_dsl_10.gif"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5440922013752329314" src="http://2.bp.blogspot.com/_r-NJO1NMiu4/S4IJvohPhGI/AAAAAAAAAKc/Xx_hy4ZBCXI/s400/ext_dsl_10.gif" style="display: block; margin: 0px auto 10px; text-align: center; cursor: pointer; cursor: hand; width: 400px; height: 300px;"/></a><br/><br/>It's interesting to observe that the two components of the stack evolve somewhat orthogonally.<br/><br/><b>The Semantic Model evolves Bottom Up</b><br/><br/>The semantic model usually evolves in a bottom up fashion - larger abstractions are formed from smaller abstractions using principles of composition. It can be through composition of traits or objects or it can be through composition of functions as well. How beautiful your compositions can be depends a lot on the language you use. But it's important that the semantic model also speaks the language of the domain. <br/><br/>Here's an example code snippet from my upcoming book <a href="http://www.manning.com/ghosh">DSLs In Action</a> that models the business rules for a trading DSL. When you do a trade on a stock exchange you get charged a list of tax and fee components depending on the market where you execute the trade. The following snippet models a business rule using Scala that finds out the list of applicable tax/fee heads for a trade ..<br/><br/><code><span class="java_keyword">class</span><span class="java_plain"> </span><span class="java_type">TaxFeeRulesImpl</span><span class="java_plain"> </span><span class="java_keyword">extends</span><span class="java_plain"> </span><span class="java_type">TaxFeeRules</span><span class="java_plain"> </span><span class="java_separator">{</span><span class="java_plain"/><br/><span class="java_plain">  override </span><span class="java_keyword">def</span><span class="java_plain"> forTrade</span><span class="java_separator">(</span><span class="java_plain">trade</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">Trade</span><span class="java_separator">)</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">List</span><span class="java_separator">[</span><span class="java_type">TaxFee</span><span class="java_separator">]</span><span class="java_plain"> </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_separator">{</span><span class="java_plain"/><br/><span class="java_plain">    </span><span class="java_separator">(</span><span class="java_plain">forHKG orElse </span><br/><span class="java_plain">       forSGP orElse </span><br/><span class="java_plain">         forAll</span><span class="java_separator">)(</span><span class="java_plain">trade</span><span class="java_separator">.</span><span class="java_plain">market</span><span class="java_separator">)</span><span class="java_plain"/><br/><span class="java_plain">  </span><span class="java_separator">}</span><span class="java_plain"/><br/><span class="java_plain">   </span><br/><span class="java_plain">  </span><span class="java_keyword">val</span><span class="java_plain"> forHKG</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">PartialFunction</span><span class="java_separator">[</span><span class="java_type">Market</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">List</span><span class="java_separator">[</span><span class="java_type">TaxFee</span><span class="java_separator">]]</span><span class="java_plain"> </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_separator">{</span><span class="java_plain"> </span><br/><span class="java_plain">    </span><span class="java_keyword">case</span><span class="java_plain"> HKG </span><span class="java_operator">=&gt;</span><span class="java_plain"> </span><br/><span class="java_plain">      </span><span class="java_comment">// in real life these can come from a database</span><br/><span class="java_plain">      </span><span class="java_type">List</span><span class="java_separator">(</span><span class="java_type">TradeTax</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">Commission</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">Surcharge</span><span class="java_separator">)</span><span class="java_plain"/><br/><span class="java_plain">  </span><span class="java_separator">}</span><span class="java_plain"/><br/><span class="java_plain">    </span><br/><span class="java_plain">  </span><span class="java_keyword">val</span><span class="java_plain"> forSGP</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">PartialFunction</span><span class="java_separator">[</span><span class="java_type">Market</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">List</span><span class="java_separator">[</span><span class="java_type">TaxFee</span><span class="java_separator">]]</span><span class="java_plain"> </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_separator">{</span><span class="java_plain"/><br/><span class="java_plain">    </span><span class="java_keyword">case</span><span class="java_plain"> SGP </span><span class="java_operator">=&gt;</span><span class="java_plain"> </span><br/><span class="java_plain">      </span><span class="java_type">List</span><span class="java_separator">(</span><span class="java_type">TradeTax</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">Commission</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">Surcharge</span><span class="java_separator">,</span><span class="java_plain"> VAT</span><span class="java_separator">)</span><span class="java_plain"/><br/><span class="java_plain">  </span><span class="java_separator">}</span><span class="java_plain"/><br/><span class="java_plain">    </span><br/><span class="java_plain">  </span><span class="java_keyword">val</span><span class="java_plain"> forAll</span><span class="java_operator">:</span><span class="java_plain"> </span><span class="java_type">PartialFunction</span><span class="java_separator">[</span><span class="java_type">Market</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">List</span><span class="java_separator">[</span><span class="java_type">TaxFee</span><span class="java_separator">]]</span><span class="java_plain"> </span><span class="java_operator">=</span><span class="java_plain"> </span><span class="java_separator">{</span><span class="java_plain"/><br/><span class="java_plain">    </span><span class="java_keyword">case</span><span class="java_plain"> _ </span><span class="java_operator">=&gt;</span><span class="java_plain"> </span><span class="java_type">List</span><span class="java_separator">(</span><span class="java_type">TradeTax</span><span class="java_separator">,</span><span class="java_plain"> </span><span class="java_type">Commission</span><span class="java_separator">)</span><span class="java_plain"/><br/><span class="java_plain">  </span><span class="java_separator">}</span><span class="java_plain"/><br/><span class="java_plain"/><br/><span class="java_plain">  </span><span class="java_comment">//..</span><br/><span class="java_separator">}</span><span class="java_plain"/><br/><span class="java_plain"/><br/></code><br/>The method <code>forTrade</code> clearly expresses the business rule, which reads almost as expressive as the English version ..<br/><br/><i>"Get the Hong Kong specific list for trades executed on the Hong Kong market OR Get the Singapore specific list for trades executed on the Singapore market OR Get the most generic list valid for all other markets"</i><br/><br/>Note how Scala <code>PartialFunction</code> s can be chained together to give the above model an expressive yet succinct syntax.<br/><br/><b>The Language Interface evolves Top Down</b><br/><br/>Here you start with the domain user. What dialect does he use on the trading desk ? And then you try to build an interpreter around that which uses the services that the semantic model publishes. I call this thin layer of abstraction a <b>DSL Facade</b> that sits between your DSL script and the underlying domain model and acts as the glue.<br/><br/>It also depends a lot on the host language as to how you would like to implement the facade. With a language like Lisp, macros can come in very handy in designing an interpreter layer for the facade. And with macros you do bottom up programming, bending the host language to speak your dialect.<br/><br/>When you are developing an external DSL, the EBNF rules that you specify act as the DSL Facade for growing your syntax. Within the rules you can use foreign code embedding to interact with your semantic model. <br/><br/>In summary, when you design a DSL, the semantic model is as important as the dialect that it speaks. Having a well designed semantic model is an exercise in designing well-engineered abstractions. And as I mention in my book, the four qualities of good abstractions are <i>minimalism</i>, <i>distillation</i>, <i>extensibility</i> and <i>composability</i>.<div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/22587889-8752276955215978661?l=debasishg.blogspot.com" width="1"/></div></div>
    </content>
    <updated>2010-02-22T05:29:16Z</updated>
    <published>2010-02-22T04:35:00Z</published>
    <category scheme="http://www.blogger.com/atom/ns#" term="dsl"/>
    <category scheme="http://www.blogger.com/atom/ns#" term="dslsina"/>
    <author>
      <name>Debasish</name>
      <email>ghosh.debasish@gmail.com</email>
      <uri>http://www.blogger.com/profile/01613713587074301135</uri>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-22587889</id>
      <author>
        <name>Debasish</name>
        <email>ghosh.debasish@gmail.com</email>
        <uri>http://www.blogger.com/profile/01613713587074301135</uri>
      </author>
      <link href="http://debasishg.blogspot.com/feeds/posts/full" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <link href="http://debasishg.blogspot.com/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <link href="http://debasishg.blogspot.com/feeds/posts/full?start-index=4&amp;max-results=3" rel="next" type="application/atom+xml"/>
      <link href="http://feeds.feedburner.com/RuminationsOfAProgrammer" rel="self" type="application/atom+xml"/>
      <subtitle>A programmer's blog - will deal with everything that relates to a programmer. Occasionally, it will contain some humour, some politics and some sport news.</subtitle>
      <title>Ruminations of a Programmer</title>
      <updated>2010-03-04T06:54:46Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/403837502</id>
    <link href="http://code.technically.us/post/403837502" rel="alternate" type="text/html"/>
    <title>Spde sbt 0.3.0 http://post.ly/OzTU</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Spde sbt 0.3.0 <a href="http://post.ly/OzTU">http://post.ly/OzTU</a></p></div>
    </summary>
    <updated>2010-02-22T01:34:53Z</updated>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-02T17:20:45Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/403837337</id>
    <link href="http://code.technically.us/post/403837337" rel="alternate" type="text/html"/>
    <title>spde-examples 0.2.0 http://post.ly/Ozl9</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>spde-examples 0.2.0 <a href="http://post.ly/Ozl9">http://post.ly/Ozl9</a></p></div>
    </summary>
    <updated>2010-02-22T01:34:53Z</updated>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-01T20:00:56Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/403347691</id>
    <link href="http://code.technically.us/post/403347691" rel="alternate" type="text/html"/>
    <title>sqlshell:  a Scala-based SQL command line tool</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://www.clapper.org/software/scala/sqlshell/">sqlshell:  a Scala-based SQL command line tool</a>: <blockquote>
  <p>similar in concept to tools like Oracle’s SQL*Plus, the PostgreSQL psql command, and MySQL’s mysql tool</p>
</blockquote></div>
    </summary>
    <updated>2010-02-21T21:22:49Z</updated>
    <category term="Scala"/>
    <category term="SQL"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-01T18:00:54Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/402996583</id>
    <link href="http://code.technically.us/post/402996583" rel="alternate" type="text/html"/>
    <title>irb on Android</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://github.com/headius/ruboto-irb">irb on Android</a>: <p>Because… An Application may itself install or launch other executable code by any means, including without limitation through the use of a plug-in architecture, calling other frameworks, other APIs or otherwise. Any interpreted code may be downloaded and used in an Application.</p></div>
    </summary>
    <updated>2010-02-21T18:05:00Z</updated>
    <category term="Android"/>
    <category term="Ruby"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-01T15:01:00Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/402892981</id>
    <link href="http://code.technically.us/post/402892981" rel="alternate" type="text/html"/>
    <title>That Trendy Computer — waffle</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><br/><br/><p>That Trendy Computer — <a href="http://waffle.wootest.net/2010/02/21/and-im-a-pc/"><em>waffle</em></a></p></div>
    </summary>
    <updated>2010-02-21T17:00:00Z</updated>
    <category term="Business Programs"/>
    <category term="Lace-baiting"/>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-03-01T14:01:01Z</updated>
    </source>
  </entry>

  <entry>
    <id>tag:blogger.com,1999:blog-24611184.post-3404931511753350592</id>
    <link href="http://www.blogger.com/feeds/24611184/posts/default/3404931511753350592?v=2" rel="edit" type="application/atom+xml"/>
    <link href="http://www.blogger.com/feeds/24611184/posts/default/3404931511753350592?v=2" rel="self" type="application/atom+xml"/>
    <link href="http://feedproxy.google.com/~r/WonderingAround/~3/QK4oCUxebNo/parallelizing-junit-test-runs.html" rel="alternate" type="text/html"/>
    <title>Parallelizing JUnit test runs</title>
    <content type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml">Original post at the <a href="http://eng.kaching.com/2010/02/parallelizing-junit-test-runs.html">kaChing engineering blog</a>.<br/>
<br/>
Test runs should be as fast as possible in order to allow a lean development cycle. One of the applications is a <a href="http://timothyfitz.wordpress.com/2009/02/10/continuous-deployment-at-imvu-doing-the-impossible-fifty-times-a-day/">Continuous Deployment</a> (see <a href="http://www.slideshare.net/startuplessonslearned/2010-02-19-the-lean-startup-webstock-2010">Lean Startup</a>).<br/>
<br/>
Using strong multi-core machines to run tests is not enough since most unit tests are using a single thread per test. Apart of reducing IO to minimum, having tests running in parallel is required to squeeze the juice of of the machine. Additional value from Parallelizing JUnit test runs is ensuring that tests have no dependency between each other.<br/>
<br/>
The way we implemented parallel test runs is creating an <a href="http://ant.apache.org/">ANT</a> target with a <a href="http://ant.apache.org/manual/CoreTasks/parallel.html">parallel task</a> containing N <a href="http://ant.apache.org/manual/OptionalTasks/junit.html">JUnit tasks</a> where <i>N == number of cores</i>. For example:<pre class="brush: xml;tab-size: 2; smart-tabs: true; toolbar: false; gutter: false; first-line:1;">&lt;parallel&gt;
      &lt;junit printsummary="yes" haltonfailure="yes" fork="true" maxmemory="${maxmemory}" showoutput="yes"&gt;
        &lt;jvmarg value="-XX:MaxPermSize=${permMem}"/&gt;
        &lt;jvmarg value="-Xms${minMem}"/&gt;
        &lt;jvmarg value="-Xmx${maxmemory}"/&gt;
        &lt;classpath refid="classpath.test" /&gt;
        &lt;formatter type="xml" usefile="true" /&gt;
        &lt;test name="com.kaching.GroupedTests$GroupA" todir="${testTargetJunit}" unless="testcase"/&gt;
      &lt;/junit&gt;
      &lt;junit printsummary="yes" haltonfailure="yes" fork="true" maxmemory="${maxmemory}" showoutput="yes"&gt;
        &lt;jvmarg value="-XX:MaxPermSize=${permMem}"/&gt;
        &lt;jvmarg value="-Xms${minMem}"/&gt;
        &lt;jvmarg value="-Xmx${maxmemory}"/&gt;
        &lt;classpath refid="classpath.test" /&gt;
        &lt;formatter type="xml" usefile="true" /&gt;
        &lt;test name="com.kaching.GroupedTests$GroupB" todir="${testTargetJunit}" unless="testcase"/&gt;
      &lt;/junit&gt;
  ...
     &lt;/parallel&gt;
</pre>The GroupedTests$GroupX are classes extending <a href="http://junit.org/apidocs/junit/framework/TestCase.html">TestCase</a> with a <i>public static Test suite()</i>. The suite() method creates a <a href="http://junit.org/apidocs/junit/framework/TestSuite.html">JUnit test suite</a> on the fly by loading all the tests in scope and filtering them out. If for example there are four cores, therefore you would like to have a group of four suites each running fourth of the tests. The suits are using a java.util.Random seeded with the commit revision number. Using the Random object we decide on placing test cases in suits. <pre class="brush: java;tab-size: 2; smart-tabs: true; toolbar: false; gutter: false; first-line:1;">random.nextInt(numOfTestSuites) == testSuiteId</pre>Therefore a testcase goes to a single suite and they are evenly distributed between suites. Randomness in assigning test cases to suites (and therefore to processes) gives us some reassurance that there are no dependencies between tests.<br/>
<br/>
As a result we have the tests running about twice as fast as they did before, in the range of 2 min, 20 sec for about 4.6k tests for one of our components, including code fetch from source repository, clean, build, and test suite setup time. It gives us a nice 100% test machine utilization and faster commit to production deployment cycle (about four minutes).<div class="blogger-post-footer"><img alt="" height="1" src="https://blogger.googleusercontent.com/tracker/24611184-3404931511753350592?l=www.eishay.com" width="1"/></div><img height="1" src="http://feeds.feedburner.com/~r/WonderingAround/~4/QK4oCUxebNo" width="1"/></div>
    </content>
    <updated>2010-02-21T03:46:40Z</updated>
    <published>2010-02-21T03:46:00Z</published>
    <category scheme="http://www.blogger.com/atom/ns#" term="testing"/><feedburner:origLink xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://www.eishay.com/2010/02/parallelizing-junit-test-runs.html</feedburner:origLink>
    <author>
      <name>Eishay Smith</name>
      <email>noreply@blogger.com</email>
      <uri>http://www.blogger.com/profile/09443096006184006852</uri>
    </author>
    <source>
      <id>tag:blogger.com,1999:blog-24611184</id>
      <author>
        <name>Eishay Smith</name>
        <email>noreply@blogger.com</email>
        <uri>http://www.blogger.com/profile/09443096006184006852</uri>
      </author>
      <link href="http://www.eishay.com/feeds/posts/default" rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml"/>
      <link href="http://www.eishay.com/" rel="alternate" type="text/html"/>
      <link href="http://pubsubhubbub.appspot.com/" rel="hub" type="text/html"/>
      <link href="http://www.blogger.com/feeds/24611184/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" rel="next" type="application/atom+xml"/>
      <link href="http://feeds.feedburner.com/WonderingAround" rel="self" type="application/atom+xml"/>
      <title>Wondering around</title>
      <updated>2010-03-03T07:09:40Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/400699606</id>
    <link href="http://code.technically.us/post/400699606" rel="alternate" type="text/html"/>
    <title>Code as Craft — Etsy programmers' blog</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><a href="http://codeascraft.etsy.com/2010/02/10/code-as-craft/">Code as Craft — Etsy programmers' blog</a>: <p>It’s funny because Etsy was linked in <a href="http://technically.us/code/x/codecraft/">this post</a>.</p></div>
    </summary>
    <updated>2010-02-20T16:21:07Z</updated>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-02-28T23:00:47Z</updated>
    </source>
  </entry>

  <entry>
    <id>http://code.technically.us/post/399135298</id>
    <link href="http://code.technically.us/post/399135298" rel="alternate" type="text/html"/>
    <title>Spde 0.2.4 http://post.ly/Oah9</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p>Spde 0.2.4 <a href="http://post.ly/Oah9">http://post.ly/Oah9</a></p></div>
    </summary>
    <updated>2010-02-19T21:07:05Z</updated>
    <source>
      <id>http://code.technically.us/</id>
      <author>
        <name>Coderspiel</name>
      </author>
      <link href="http://tumblr.superfeedr.com/" rel="hub" type="text/html"/>
      <link href="http://code.technically.us/" rel="alternate" type="text/html"/>
      <link href="http://technically.us/resources/com.typeturner.Typeturner/code-rss" rel="self" type="application/rss+xml"/>
      <title>Coderspiel</title>
      <updated>2010-02-28T21:40:59Z</updated>
    </source>
  </entry>

  <entry xml:lang="en">
    <id>http://www.scala-lang.org/5346 at http://www.scala-lang.org</id>
    <link href="http://www.scala-lang.org/node/5346" rel="alternate" type="text/html"/>
    <title>Scala in Egypt</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p><a href="http://jdc2010.egjug.org/node/1">JDC-2010</a> takes place 27 February in Nasr City, Aswan, Egypt  and has been promoted by the EGJUG, one of the most active user groups in the Middle East. This year Scala, an "emerging language" <a href="http://jdc2010.egjug.org/node/30">is being presented by Hossam Karim</a>, a Senior Technical Architect at ITWorx. As well as Scala, the JDC will be covering Rich Internet Application and Client (JSF, JavaFX, Adobe Flex, JBoss Rich Faces) and Enterprise Application Integration (OSGi, Spring Integration, Enterprise Service Bus, SOA, Business Process Management,Enterprise Messaging, Webservices).</p></div>
    </summary>
    <updated>2010-02-19T13:08:11Z</updated>
    <author>
      <name>bagwell</name>
    </author>
    <source>
      <id>http://www.scala-lang.org/</id>
      <link href="http://www.scala-lang.org/" rel="alternate" type="text/html"/>
      <link href="http://www.scala-lang.org/rss.xml" rel="self" type="application/rss+xml"/>
      <title>The Scala Programming Language</title>
      <updated>2010-03-09T19:40:33Z</updated>
    </source>
  </entry>

  <entry xml:lang="en">
    <id>http://www.scala-lang.org/5343 at http://www.scala-lang.org</id>
    <link href="http://www.scala-lang.org/node/5343" rel="alternate" type="text/html"/>
    <title>Use Infinispan with Scala</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p><a href="http://www.jboss.org/infinispan">Infinispan 4.0.0.CR4</a> has just been announced with many new features and Amin Abbaspour, a member of the JBOSS community, has <a href="http://community.jboss.org/wiki/InfinispanInteractiveTutorialwithScala">provided a tutorial</a> on how to use this powerful data grid platform from Scala. Step by step, he explains how Scala can be used to create high performance, highly available Enterprise scale Infiniscan data grids.</p></div>
    </summary>
    <updated>2010-02-19T09:49:58Z</updated>
    <author>
      <name>bagwell</name>
    </author>
    <source>
      <id>http://www.scala-lang.org/</id>
      <link href="http://www.scala-lang.org/" rel="alternate" type="text/html"/>
      <link href="http://www.scala-lang.org/rss.xml" rel="self" type="application/rss+xml"/>
      <title>The Scala Programming Language</title>
      <updated>2010-03-09T19:40:33Z</updated>
    </source>
  </entry>

  <entry xml:lang="en">
    <id>http://www.scala-lang.org/5342 at http://www.scala-lang.org</id>
    <link href="http://www.scala-lang.org/node/5342" rel="alternate" type="text/html"/>
    <title>Scala at NFJS Symposiums</title>
    <summary type="xhtml"><div xmlns="http://www.w3.org/1999/xhtml"><p><a href="http://www.nofluffjuststuff.com/home/main">NFJS - No Fluff Just Stuff Software Symposiums</a> are recognised to be world class events where you can learn about the latest technology, improve your skills and meet the experts. This year there are a series of local events centred around Enterprise Java, Agility, Spring, Groovy/Grails, Ajax, JSF and multiple language sessions on Scala.</p> <p>Reflecting the growing commercial deployment of Scala each NFJS event now contain several sessions on various aspects of Scala given by leading industry consultants, people like Michael Nygard, Venkat Subramaniam and Ted Neward. If you are interested in staying up to date in the Java world and want to get up to speed with Scala then look out for an NFJS symposium near you; please read below.</p></div>
    </summary>
    <updated>2010-02-19T08:35:08Z</updated>
    <author>
      <name>bagwell</name>
    </author>
    <source>
      <id>http://www.scala-lang.org/</id>
      <link href="http://www.scala-lang.org/" rel="alternate" type="text/html"/>
      <link href="http://www.scala-lang.org/rss.xml" rel="self" type="application/rss+xml"/>
      <title>The Scala Programming Language</title>
      <updated>2010-03-09T19:40:36Z</updated>
    </source>
  </entry>
</feed>
