<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cake Solutions Team Blog</title>
	<atom:link href="http://www.cakesolutions.net/teamblogs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cakesolutions.net/teamblogs</link>
	<description>void magic() { }</description>
	<lastBuildDate>Fri, 03 Feb 2012 13:05:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Scalaz monads in Spring</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/02/03/scalaz-monads-in-spring/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=scalaz-monads-in-spring</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/02/03/scalaz-monads-in-spring/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 12:00:50 +0000</pubDate>
		<dc:creator>Jan Machacek</dc:creator>
				<category><![CDATA[Jan's Blog]]></category>
		<category><![CDATA[Monads]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Scalaz IO]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=2005</guid>
		<description><![CDATA[I won&#8217;t give you the category-theory based explanation of monads. Instead, I&#8217;m going to show you the application of monads, but not on Ints and Strings, but on ordinary domain instances; instances that we persist using Hibernate. Finally, we&#8217;ll run &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/02/03/scalaz-monads-in-spring/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I won&#8217;t give you the category-theory based explanation of <em>monads</em>. Instead, I&#8217;m going to show you the application of monads, but not on <code>Int</code>s and <code>String</code>s, but on ordinary domain instances; instances that we persist using Hibernate. Finally, we&#8217;ll run the entire example in the Spring Framework.</p>
<p>Why the complexity, you ask? My team often found the simple examples understandable, but they struggled to see the application of the monads to day-to-day business code. &#8220;Sure, we write monads that read a <code>String</code> from a file, chain it to monad that converts the <code>String</code> to <code>Int</code>, but we&#8217;re having to generate reports,&#8221; they said.</p>
<h2>The service</h2>
<p>Let&#8217;s write a <code>ReportService</code> that generates reports and then produces a combined report by combining the individual reports into one. Its API is:</p>
<pre class="brush:[scala]">
class ReportService {

  def produce()

  def combine()

}
</pre>
<p>Where the <code>produce</code> function generates the individual reports (pages, if you like); and the <code>combine</code> function takes the already generated reports and assembles the aggregate. We keep these reports in the database (and the content on the disk) and we map the RDBMS records to the <code>Record</code> instances. We are using Hibernate, leading the definition of the <code>Report</code> class:</p>
<pre class="brush:[scala]">
@Entity
case class Report() {
  @Id
  @GeneratedValue
  @BeanProperty
  var id: Long = _
  @Version
  @BeanProperty
  var version: Int = _
  @BeanProperty
  var fileName: String = _

}
</pre>
<p>As I said earlier, we are using Hibernate to manipulate the <code>Record</code> instances, so our <code>ReportService</code> will need to depend on the <code>SessionFactory</code>. Because we&#8217;re running in the Spring Framework, we can have the dependency injected in. We just have to give the appropriate metadata to the Spring Framework&#8217;s DI core:</p>
<pre class="brush:[scala]">
@Service
class ReportService @Autowired() (private val sessionFactory: SessionFactory) {

  def produce()

  def combine()

}
</pre>
<p>We&#8217;ll start with the <code>produce()</code> function. The task is to generate [a fixed number of] reports. So, we&#8217;ll need a <code>for</code> loop whose every iteration creates a <code>Report</code> instance and saves it to the DB.</p>
<pre class="brush:[scala]">
@Service
class ReportService @Autowired() (private val sessionFactory: SessionFactory) {

  @Transactional
  def produce() {
    for (i < - 0 to 100) {
      val report = Report()
      val content = "Report %d".format(i)
      report.fileName = "%d".format(i)

      // save the report's content

      sessionFactory.getCurrentSession.saveOrUpdate(report)
    }
  }

}
</pre>
<p>So far, so good. We have the fancy Scala <code>for</code> loop, but the code remains very similar to its Java equivalent. Now, let's deal with the IO. To save a report, we need to:</p>
<ul>
<li>create / open a file into which the content is going to go,</li>
<li>produce the report's content,</li>
<li>write the content to the file.</li>
</ul>
<ul>
<p>So, we have three operations. We go from <code>Report</code> to <em>operation giving</em> <code>File</code>, second that goes from <em>operation giving</em> <code>File</code> and <em>operation giving</em> <code>Data</code> to <em>operation giving</em> <code>Unit</code>. So, let's write these operations and define what we mean by <code>Data</code>:</p>
<pre class="brush:[scala]">
@Service
class ReportService @Autowired() (private val sessionFactory: SessionFactory) {
  type Data = Array[Char]
  import scalaz._
  import scalaz.effects._

  def reportToFile(report: Report) = io {
    new File("/Users/janmachacek/Tmp/r/%s".format(report.fileName))
  }
  def dataToFile(data: IO[Data])(file: File) = io {
    println("Written " + new String(data.unsafePerformIO) + " to " + file)
  }

  ...

}
</pre>
<p>The function <code>reportToFile</code> is the one that takes a <code>Report</code> and returns an <em>operation that gives</em> <code>File</code>. The <em>operation that gives</em> is whatever the <code>io</code> function returns. Then I have the <code>dataToFile</code> function that takes an <em>operation that takes </em>operation that gives <code>Data</code> and returns an <em>operation that gives <code>Unit</code></em>. Figure 1 shows a picture of what we're trying to do.</p>
<p>Figure 1. The operations and the links between them</p>
<p><img src="http://www.cakesolutions.net/teamblogs/wp-content/uploads/2012/02/monads.png" alt="" title="monads" width="475" height="375" /></p>
<p><em>We would like to wire the three operations together to give us a new operation that combines the three together!</em></p>
<p>This is crucial concept: we're not just pushing data around, we're creating a new operation that combines the smaller operations to do something useful for us. So, let's drop in the real syntax:</p>
<pre class="brush:[scala]">
@Service
class ReportService @Autowired() (private val sessionFactory: SessionFactory) {
  type Data = Array[Char]
  import scalaz._
  import scalaz.effects._

  def reportToFile(report: Report) = io {
    new File("/Users/janmachacek/Tmp/r/%s".format(report.fileName))
  }
  def dataToFile(data: IO[Data])(file: File) = io {
    println("Written " + new String(data.unsafePerformIO) + " to " + file)
  }

  @Transactional
  def produce() {
    for (i &lt;- 0 to 100) {
      val report = Report()
      val content = "Report %d".format(i)
      report.fileName = "%d".format(i)

      (reportToFile(report) &gt;&gt;=
         dataToFile(io {content.toCharArray})).unsafePerformIO

      sessionFactory.getCurrentSession.saveOrUpdate(report)
    }
  }

}
</pre>
<p>Let's explore the mystical <code>(reportToFile(report) &gt;&gt;= dataToFile(io {content.toCharArray})).unsafePerformIO</code> line. We have <code>reportToFile</code> takes a <code>Report</code> and makes a <em>thing</em> that makes a <code>File</code>. Then we have <code>dataToFile</code> which takes a <em>thing</em> that makes <code>Data</code> and <em>thing</em> that makes <code>File</code>. We treat these <em>things</em> as black boxes--they do something obscure, unknown and unknowable. But these <em>things</em> have a "screen" on them; and we can look at that "screen" and obtain the current value.</p>
<p>And that's the principle of monads. They are opaque things that can return some value and they can be chained together to form new things that combine whatever the component things do.</p>
<p>And that explains the <code>unsafePerformIO</code> call. The <code>(reportToFile(report) &gt;&gt;= dataToFile(io {content.toCharArray}))</code> simply returns a new monad, but we must "look at its screen"; make it compute a value, in other words. And that's what the <code>unsafePerformIO</code> function does.</p>
</ul>
</pre>
<p>Onwards, then! Let&#8217;s implement the <code>combine</code> function that selects all existing reports, and merges them into a one fat report that it then saves.</p>
<pre class="brush:[scala]">
@Service
class ReportService @Autowired() (private val sessionFactory: SessionFactory) {
  type Data = Array[Char]
  import scalaz._
  import scalaz.effects._
  import scala.collection.JavaConversions._

  def reportToFile(report: Report) = io {
    new File("/Users/janmachacek/Tmp/r/%s".format(report.fileName))
  }
  def dataToFile(data: IO[Data])(file: File) = io {
    println("Written " + new String(data.unsafePerformIO) + " to " + file)
  }
  def fileToData(file: File) = io {
    Source.fromFile(file).toArray
  }

  @Transactional
  def produce() {
    ...
  }

  @Transactional
  def combine() {
    val reports =
      sessionFactory.getCurrentSession.createCriteria(classOf[Report]).
        list().asInstanceOf[java.util.List[Report]].toList

    val out = Report()
    out.fileName = "out.txt"

    // take the reports and make one big fat report out

    sessionFactory.getCurrentSession.saveOrUpdate(out)
  }

}
</pre>
<p>The <code>combine</code> selects all <code>Report</code> records, and (using the function in scala.collection.JavaConversions._) converts the <code>java.util.List[Report]</code> into <code>scala.collections.immutable.List[Report]</code>. How do we now combine the reports? Let&#8217;s think about it:</p>
<ul>
<li>If the <code>reports</code> contains just one item, then the result is that one item,</li>
<li>If the <code>reports</code> contains two items, then we need some function that takes two <code>Report</code>s and makes the combined <code>Report</code>,</li>
<li>If the <code>reports</code> contains many (i.e. more than two!) items, then we take the first two and combine them into one (using the function from the previous step). Then we take the combined report and combine it with the third item; then we take the combined report and combine it with the fourth item; and so on, until the end.</li>
</ul>
<ul>
<p>So, we need a function that combines two reports into one and then an operation that implements the algorithm we described earlier. The name for the operation is <code>foldl1</code> and Figure 2 shows how it works:</p>
<p>Figure 2. foldl1 function</p>
<p><img src="http://www.cakesolutions.net/teamblogs/wp-content/uploads/2012/02/foldl.png" alt="" title="foldl" width="566" height="185" /></p>
<p>The arrows in the image are our function and <code>report<sub>1</sub>, report<sub>2</sub>, ..., report<sub>n</sub></code> is our list. Hence the code of the <code>combine</code> function becomes:</p>
<pre class="brush:[scala]">
@Service
class ReportService @Autowired() (private val sessionFactory: SessionFactory) {

  ...

  @Transactional
  def combine() {
    val reports =
      sessionFactory.getCurrentSession.createCriteria(classOf[Report]).
        list().asInstanceOf[java.util.List[Report]].toList

    val out = Report()
    out.fileName = "out.txt"

    reports.foldl1 { (r1: Report, r2: Report) =>
      // read the r1 and r2 from the files,
      // combine them and write to out
      out
    }

    sessionFactory.getCurrentSession.saveOrUpdate(out)
  }
}
</pre>
<p>We now have to read the report from a file into <code>Data</code> and the combine the two <code>Data</code>s representing the reports together. The good news is that we have already written the monads that deal with the report IO. All we have to do is to combine them to form new interesting monad that combines the reports.</p>
<pre class="brush:[scala]">
@Service
class ReportService @Autowired() (private val sessionFactory: SessionFactory) {

  ...

  @Transactional
  def combine() {
    val reports =
      sessionFactory.getCurrentSession.createCriteria(classOf[Report]).
        list().asInstanceOf[java.util.List[Report]].toList

    val out = Report()
    out.fileName = "out.txt"

    def combine(data: (Data, Data)) = io { data._1 ++ data._2 }

    reports.foldl1 { (r1: Report, r2: Report) =>
      (reportToFile(out) &gt;&gt;= dataToFile(
        (reportToFile(r1) &gt;&gt;= fileToData) &lt;|*|&gt;
        (reportToFile(r2) &gt;&gt;= fileToData) &gt;&gt;= combine)
      ).unsafePerformIO

      out
    }

    sessionFactory.getCurrentSession.saveOrUpdate(out)
  }
}
</pre>
<p>You already know about chaining the monads (using <code>&gt;&gt;=</code>), the new thing in the <code>reports.foldl1</code> function is the <code>&lt;|*|&gt;</code> operation. Think of this operation indeed as multiplication, but multiplication of the computed values of the monads. The monad on the left-hand side (<code>(reportToFile(r1) &gt;&gt;= fileToData)</code>) computes <code>Data</code>, the monad on the right-hand side (<code>(reportToFile(r2) &gt;&gt;= fileToData)</code>) computes <code>Data</code>. In this case, we have <code>Data</code> * <code>Data</code>, in other words a pair&#8211;tuple in computer speak&#8211;of <code>Data</code>. And that&#8217;s precisely what the <code>combine</code> function takes (its body simply appends the two arrays) and it returns the combined IO of <code>Data</code>&#8230; and we can use it as input of the <code>dataToFile</code> function, which is an IO monad that follows the <code>reportToFile(out)</code> monads.</p>
<p>The whole contraption represents our <em>report + report</em> function; which we give to the <code>foldl1</code> function. For completeness, we save the combined report using the injected <code>sessionFactory</code>.</p>
<h2>Summary</h2>
</p>
<p>This code combines dependency injection, load-time weaving (courtesy of the Spring Framework) with elegance and effectiveness of the Scala code. Finally, we take advantage of the IO monads in Scalaz to compose the individual trivial operations (report -> file, data -> file, etc.) to compose new operations that we use in the <code>produce</code> and <code>combine</code> functions.</p>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/02/03/scalaz-monads-in-spring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>This week in #Scala (03/02/2012)</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/02/03/this-week-in-scala-03022012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=this-week-in-scala-03022012</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/02/03/this-week-in-scala-03022012/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 08:35:37 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Mark's Blog]]></category>
		<category><![CDATA[Akka]]></category>
		<category><![CDATA[sbt]]></category>
		<category><![CDATA[sbt nexus]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[scala android]]></category>
		<category><![CDATA[Specs2]]></category>
		<category><![CDATA[Specs2 Spring]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1996</guid>
		<description><![CDATA[Welcome to another week in #Scala. We&#8217;ve been busy working on our open source projects here at Cake and have finally got spec2 spring published to Maven central and Sonatype. This week has been fairly quiet from a Scala point &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/02/03/this-week-in-scala-03022012/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Welcome to another week in #Scala. We&#8217;ve been busy working on our open source projects here at Cake and have finally got spec2 spring published to Maven central and Sonatype. This week has been fairly quiet from a Scala point of view (compared to normal standards anyway) but there are still a few interesting posts and releases to tell you about.</p>
<p>&nbsp;</p>
<p><strong>New Stuff</strong></p>
<p><strong><a href="http://implicit.ly/scalaxb-068" target="_blank">Scalaxb 0.6.8</a> </strong>is now available! scalaxb is an XML data-binding tool for Scala that supports W3C XML Schema (xsd) as the input file.</p>
<p><strong><a href="http://www.cakesolutions.org/specs2-spring-announce.html" target="_blank">Specs2 Spring version 0.4</a></strong>. In addition to many minor changes and bug fixes this release improves support for spring 2.5, adds hibernate 4 support and allows the @Bean annotation to be used from within Scala code. Find out more about spec2 spring and our other open source projects in <a href="http://www.cakesolutions.net/teamblogs/author/janm/" target="_blank">Jans blog</a>.</p>
<p>Have a look at <strong><a href="http://code.google.com/p/styla/" target="_blank">Styla</a></strong> &#8211; A fairly complete and fast Prolog interpreter written in Scala, using Paul Tarau&#8217;s Java-based Kernel Prolog as starting point.</p>
<p><strong><a href="http://implicit.ly/less-sbt-015" target="_blank">Less-sbt 0.1.5</a></strong> is now available. This release fixes a few issues and now uses the less-rhino-1.1.5.js compiler. Click through for more details.</p>
<p>&nbsp;</p>
<p><strong>Blogs and tutorials</strong></p>
<ul>
<li><a href="http://www.cakesolutions.net/teamblogs/2012/01/28/publishing-sbt-projects-to-nexus/" target="_blank">Publishing SBT projects to Nexus</a> by Jan Machacek (@honzam399 ).</li>
<li>Mike Miller has posted a review of the <a href="http://programmingitch.blogspot.com/2012/01/book-review-programming-concurrency-on.html" target="_blank">Programming Concurrency on the JVM</a> book by Venkat Subramaniam (@venkat_s).</li>
<li>A couple of AKKA 2 blogs, they aren&#8217;t scala but are still an interesting read: <a href="http://letitcrash.com/post/16813779762/akka-2-0-remoting-with-java" target="_blank">Akka 2.0 Remoting with Java </a>via the AKKA team blog, and <a href="http://www.gamlor.info/wordpress/2012/01/running-akka-2-0-on-android-wip/" target="_blank">Running Akka 2.0 On Android (WIP) </a>by Roman Stoffel (@GamlerHart)</li>
<li>Interesting (SIP) proposal on<a href="http://docs.scala-lang.org/sips/pending/inline-classes.html" target="_blank"> Scala inline classes</a></li>
</ul>
<div><span style="font-size: small;"><span style="line-height: 24px;"><br />
</span></span></div>
<p>As usual feel free to drop me a <a href="mailto:markh@cakesolutions.net" target="_blank">mail</a> or message @markglh on twitter with any Scala news!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/02/03/this-week-in-scala-03022012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why we come to work at Cake</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/02/02/why-we-come-to-work-at-cake/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=why-we-come-to-work-at-cake</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/02/02/why-we-come-to-work-at-cake/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 15:22:21 +0000</pubDate>
		<dc:creator>petere</dc:creator>
				<category><![CDATA[Ian's Blog]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1971</guid>
		<description><![CDATA[One of the most noticeable attributes of everyone at Cake is the burning desire to acquire, assimilate and utilise as much knowledge about what we do for a living as we can – it’s an addiction in good sense. This &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/02/02/why-we-come-to-work-at-cake/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the most noticeable attributes of everyone at Cake is the burning desire to acquire, assimilate and utilise as much knowledge about what we do for a living as we can – it’s an addiction in good sense.</p>
<p>This came up as we were closing-out a recent stand-up meeting on an agile project, when the team were excited about some of the functional programming ideas we’d come up with. <em>I love this place…my knowledge increases every day</em> said one of the team, and this got me thinking about why Cake is such a great place to work – we live and learn and do great stuff – and we get paid for it too!</p>
<p>Cake is about to embark on a period of growth, with the opening of our second office, in Oxford. It’s a clear statement of ambition and confidence, and at the same time it’s a big stretch. We need to ensure the <em>Cakeness</em> which makes us special is preserved, especially the knowledge pool. Working for a small company means we have an intimacy about the team, especially individual and collective knowledge, rapport and camaraderie – it’s not like working for a large company, which is like getting on a train with all the other passengers. Are you doing fifty miles and hour or is the train going fifty miles an hour and you’re just standing still?</p>
<p>We’re knowledge and innovation business, operating in the software development market, and consequently everyone wants to make a difference and keep on top of their game. So what drives us in this hunger for knowledge?</p>
<p>You start craving for knowledge and do not leave any source unturned to acquire it. It may be making you and people around you wiser, it could be adding spiritual maturity to you or it could be to improve your capability and fulfilment in your current or future role at work. Whatever your motivation, the mental process of knowing, including aspects such as awareness, perception, reasoning, and judgment are all stimulating and interesting points for self-reflection.</p>
<p>What is it that drives people into the jungles of the unknown? For me it is the mind&#8217;s inner urge to seek more learning, developing points of view and perspectives. The all-absorbing urge for knowledge is one of the thinking person&#8217;s deepest needs, and for me knowledge is interesting in itself and is personal strength, the greatest strength of all. There is much effort in gaining knowledge by everyone of us as we all think that what knowledge we have is insufficient. By understanding ever more knowledge, testing it and experiencing the wisdom in it one can only ever love the thirst. It is knowledge that is truly satisfying to our spirit, it brings us life and ever more greater life. Of course, that depends on your point of view, I’ve heard some people say ‘Ignorance is paradise’, but for me that’s simply not true.</p>
<p>But is the widespread availability of technology generating such wisdom or even improving our learning? Research shows that students using Google and online information portals today are producing work no better than they were 20 years ago using printed sources. Despite amazing technical breakthroughs, these technologies haven&#8217;t added to human knowledge, rather making plagiarism rife and discouraging original thinking and ‘lazy’ research. Information on a plate to satisfy short-term hunger, rather than feeding a yearning for genuine knowledge, and while technology enthusiasts celebrate the destruction of old industries, we&#8217;re left with the banality of Google and Wikipedia.</p>
<p>Of course, e-books are great inventions of convenience, but just like iTunes and digital music downloads, the tactile experience of holding a book in your hands is lost just as the loss of album sleeve notes is no longer part of the experience. However, I realise that after spending my Christmas Amazon vouchers – on a combination of ‘real’ books and kindle e-books – that I’m a collector of books rather than a reader, but feel good about myself in that I have an accumulated stock of future reading and thus a pile of new knowledge to unearth from reading.</p>
<p>Once I’ve done this, I find the tactile experience of finishing a physical book and closing it for the last time produces a mellowness, a warm glow, an inner feeling of contentment and happiness. Ok, we have the web with various blogs and online community sources to reach out and get new knowledge, but there is something about reading a book, the physicality of having it in your hands, that stands out from digital media.</p>
<p>The most wonderful thing that reading offers is a peep into another world. When you pick up a book and lose yourself into it, its like you have transcended your present situation. This temporary escape from our routine life is of great significance when it comes to your mental well-being. We all have day-to-days tasks to take care of, and many a times we go to bed all tense and frustrated and sometimes just downright bored with life. This is when reading comes to our rescue and we should welcome it with open arms if we truly want to be happy and alive. Reading offers us a chance to see the world from someone else&#8217;s eyes, thus broadening our horizons and opening our minds to new possibilities. Reading is to the mind what exercise is to the body.</p>
<p>You emerge out of this trance-like situation, fully refreshed, with a clearer vision and rejuvenated spirit. So the next time you feel as if your mental batteries could do with a recharge, pick up a good book and immerse yourself into for a good hour or so. And mind you, this solution comes with a guarantee card.  Reading is a great imagination booster and it helps develop a sense of creativity in you. It will also help you develop better concentration which we need so bad at all times.</p>
<p><strong>Are there many times in life where you probably find yourself gaining knowledge and coming to a place where everything is working well for you at the given moment because of your newfound awareness……but then it all fall apart again at the next moment?</strong></p>
<p>Sometimes it just makes you wonder what the heck is going on. The reason is because you still haven’t possessed the rest of the awareness you need for it to happen. As you keep learning and growing, you will keep getting more and more pieces of the puzzle so that you are able to acquire better and better mastery in different areas of life for creating your desired reality. Your life will get better and better when you keep picking yourself up in those areas that you have fallen and walk on, and do some great stuff!</p>
<p>But back to Cake, and our knowledge pool, and the point about knowledge, fulfilment and personal progression at work. Think about the formula for the traditional deal at work, which goes something like this:</p>
<p><em>I work&#8230; to earn money&#8230; which I use&#8230; to consume stuff&#8230; which makes me happy.</em></p>
<p>I suggest that this deal is not a sufficient description of what work can and should be. Instead I put forward the following knowledge-based and future-focused deal, which we think makes Cake different:</p>
<p><em>I work&#8230; to gain productive experiences&#8230; to improve my knowledge…that is the basis&#8230; of my happiness.</em></p>
<p>But this begs the question – what exactly is a meaningful productive experience, and how do you know when your work is meaningful? So here are the 10 questions we asked ourselves to establish whether our work at Cake is meaningful, based around knowledge, fulfilment and all the stuff we’ve gone on about above:</p>
<ul>
<li>Do you use the majority of the knowledge you have on a daily basis?&#8230;because meaningful work provides an opportunity for you to keep your knowledge fresh by using it constantly.</li>
</ul>
<ul>
<li>Do you feel intellectually stretched in your work?&#8230;because meaningful work both uses the knowledge you have and pushes the boundaries of what you can become.</li>
</ul>
<ul>
<li>Are you able to learn something new at least once a week?&#8230;because meaningful work creates constant opportunity for learning.</li>
</ul>
<ul>
<li>In your view are your colleagues at work knowledgeable and do you learn from them constantly?&#8230;because meaningful work is also about the colleagues who come with it, and your learning and development comes primarily through learning from others: ‘The Cake Tribe’.</li>
</ul>
<ul>
<li>Are the tasks you do at work interesting and complex?&#8230;because at the heart of meaningful work are the day-to-day tasks that you do.</li>
</ul>
<p>&nbsp;</p>
<ul>
<li>Do you get lots of feedback about how you are doing?&#8230;because meaningful work enables you to grow, and feedback from others is a crucial part of this.</li>
</ul>
<ul>
<li>Do you think that the work you do has a positive impact on the business?&#8230;because meaningful work enables you to make a clear link in your mind between the tasks you perform and the broader goals of the business.</li>
</ul>
<ul>
<li>Do you think that the work you do has a positive impact on society?&#8230;because meaningful work is made up of tasks that you believe do good and, as a consequence, make you feel good about yourself.</li>
</ul>
<ul>
<li>In your daily work, do you have the opportunity to reach out to develop networks with people very different from yourself?&#8230;because meaningful work creates opportunities for you to develop the ‘Big Ideas Crowd’ that is so crucial to developing your innovative and creative capacity.</li>
</ul>
<ul>
<li>Does your work give you time to really develop deep regenerative relationships with people inside and outside of your organisation?&#8230;because meaningful work creates time and space for you to develop emotionally.</li>
</ul>
<p>&nbsp;</p>
<p>So where are you on meaningful work?</p>
<p><strong>Score 8-10</strong> Through your active choices, or sheer luck, you are working in a meaningful way. Cherish the opportunities this provides and don’t compromise in the future.</p>
<p><strong>Score 5-7</strong><br />
Some aspects of your work are meaningful. Take a closer look at those you have said no to and search for the underlying patterns. Is it possible to focus on developing these areas?</p>
<p><strong>Score 1-4</strong><br />
Your job lacks meaning – you already know that! The question is – what are you going to do about it?</p>
<p>So there you have it, an inside perspective of what we think about in Cake when we’re not building great software. Take a look at our blogs, get in touch and join one of our communities, come inside for a conversation where we can share knowledge and do some meaningful work together.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/02/02/why-we-come-to-work-at-cake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Specs2 Spring 0.4</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/02/02/specs2-spring-0-4/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=specs2-spring-0-4</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/02/02/specs2-spring-0-4/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 09:12:53 +0000</pubDate>
		<dc:creator>Jan Machacek</dc:creator>
				<category><![CDATA[Jan's Blog]]></category>
		<category><![CDATA[Acceptance testing]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Specs2]]></category>
		<category><![CDATA[Specs2 Spring]]></category>
		<category><![CDATA[Spring Framework]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1967</guid>
		<description><![CDATA[We&#8217;re pleased to release version 0.4 of Specs2 Spring! 0.4 follows the very short-lived Maven Central practice-release 0.3. We now include support for Spring 2.5, 3.0 and 3.1; for the latest verion of Spring, we include bean profiles and environment &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/02/02/specs2-spring-0-4/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re pleased to release version 0.4 of Specs2 Spring!</p>
<p>0.4 follows the very short-lived Maven Central practice-release 0.3. We now include support for Spring 2.5, 3.0 and 3.1; for the latest verion of Spring, we include bean profiles and environment variables settable from the test annotations. We have also included support for raw SessionFactory and HibernateTemplate to work with the most popular ORM tool. The updates include:</p>
<ul>
<li>Supports Spring 2.5 through 3.1, including environment values and bean profiles in 3.1,</li>
<li>Test data setup (using BeanTables) now works with HibernateTemplate as well as SessionFactory in Hibernate 4</li>
<li>The @Bean annotation’s type value is now clazz to make it usable from Scala code</li>
</ul>
<p>Most excitingly, Specs2 Spring is now available in <a href="http://search.maven.org/#search%7Cga%7C1%7Corg.specs2" title="Maven Central" target="_blank">Maven Central</a> and <a href="https://oss.sonatype.org/index.html#nexus-search;quick~org.specs2" title="Sonatype OSS">Sonatype OSS</a>! All you need to do now is to include the dependency in your pom.xml:</p>
<pre class="brush:[xml]">
&lt;dependency&gt;
    &lt;groupId&gt;org.specs2&lt;/groupId&gt;
    &lt;artifactId&gt;spring_2.9.1&lt;/artifactId&gt;
    &lt;version&gt;0.4&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>To get started, download the <a href="http://www.cakesolutions.org/static/specs2-spring/0.4/api/index.html#package" title="ScalaDoc" target="_blank">ScalaDocs</a> and <a href="http://www.cakesolutions.org/static/specs2-spring/0.4/main.pdf" title="User guide" target="_blank">PDF user guide</a>; check out the <a href="http://www.cakesolutions.org/specs2-spring.html" target="_blank">http://www.cakesolutions.org/specs2-spring.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/02/02/specs2-spring-0-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Publishing SBT projects to Nexus</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/01/28/publishing-sbt-projects-to-nexus/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=publishing-sbt-projects-to-nexus</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/01/28/publishing-sbt-projects-to-nexus/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 08:02:16 +0000</pubDate>
		<dc:creator>Jan Machacek</dc:creator>
				<category><![CDATA[Jan's Blog]]></category>
		<category><![CDATA[Maven Central SBT]]></category>
		<category><![CDATA[SBT GPG]]></category>
		<category><![CDATA[SBT release]]></category>
		<category><![CDATA[Sonatype SBT]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1951</guid>
		<description><![CDATA[Specs2 Spring is available on Sonatype OSS and Maven Central! But how did we get there and what should you do to get the hosting, synchronisation to Maven Central and how do you automate the deployment process? Let&#8217;s tackle one &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/01/28/publishing-sbt-projects-to-nexus/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cakesolutions.org/specs2-spring.html">Specs2 Spring</a> is available on <a href="https://oss.sonatype.org/content/repositories/releases/org/specs2/spring_2.9.1/" target="_blank">Sonatype OSS</a> and <a href="http://search.maven.org/#search%7Cga%7C1%7Corg.specs2" target="_blank">Maven Central</a>! But how did we get there and what should you do to get the hosting, synchronisation to Maven Central and how do you automate the deployment process? Let&#8217;s tackle one thing at a time:</p>
<h2>Sonatype OSS support</h2>
<p>The first thing to is to open an issue in Sonatype&#8217;s JIRA, asking them to set up the Nexus repository for you. Once that&#8217;s done, you will be able to publish your snapshots and releases to Sonatype; the releases are then synchronised to Maven Central. The first few pages of <a href="https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide" target="_blank">Sonatype OSS Maven Repository Usage Guide</a> will show you how to get started.</p>
<h2>Building and publishing</h2>
<p>Now, this is the interesting bit. We are using SBT to build the project and we&#8217;d like to be able to run <code>sbt publish</code> to compile, package and publish the project to Sonatype automatically. Before we can do that, we need to configure GPG and SBT plugin that uses GPG to sign the artefacts. The plugin is <code>xsbt-gpg-plugin</code>, which will use GPG to sign the artefacts&#8211;properly signed artefacts are the requirement for Maven Central synchronisation. So, with the plugin, your <code>project/plugins.sbt</code> file should contain:</p>
<pre class="brush:[scala]">
...
resolvers += Resolver.url("scalasbt", /* no new line */
  new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases")) /* no new line */
  (Resolver.ivyStylePatterns)

addSbtPlugin("com.jsuereth" % "xsbt-gpg-plugin" % "0.5")
...
</pre>
<p>If you do not have GPG, you must also install &#038; configure it for your platform; if you do not have your keys, you must also generate key pair and then publish your public key. I cannot quite show you how to do this on Windows (sorry, get a Mac!). On OS X, you can use <a href="http://www.gpgtools.org/index.html" title="GPG Tools" target="_blank">GPG Tools</a>. Download and install it; the first thing GPG Tools will prompt you to do is to generate your key, protected by a passphrase. (I recommend that you keep the passphrase <em>very long</em>, as <a href="http://xkcd.com" title="XKCD" target="_blank">XKCD</a> points out in Figure 1!)</p>
<p>Figure 1. Key strengths</p>
<p><img src="http://imgs.xkcd.com/comics/password_strength.png"/></p>
<p>Before I can release the artefacts in Sonatype OSS releases and in Maven Central, I need to publish my public keys (so that others can verify that the artefacts are intact and that it was I who has produced them). To do that, you can use the GPG Keychain Access (see Figure 2) tool or use the <code>gpg</code> command-line program.</p>
<p>Figure 2. GPG Keychain Access</p>
<p><a href="http://www.cakesolutions.net/teamblogs/wp-content/uploads/2012/01/gpgkeychainaccess.png"><img src="http://www.cakesolutions.net/teamblogs/wp-content/uploads/2012/01/gpgkeychainaccess-300x152.png" alt="" title="gpgkeychainaccess" width="300" height="152" /></a></p>
<p>We are programmers, so let&#8217;s turn to the command line: we need to export a key, but to do that, we need to know its identifier:</p>
<pre class="brush:[bash]">
$ gpg --list-secret-keys
/Users/janmachacek/.gnupg/secring.gpg
-------------------------------------
sec   2048R/90A468A9 2012-01-30 [expires: 2016-01-30]
uid                  Jan Machacek &lt;jan.machacek@gmail.com&gt;
ssb   2048R/A9ED23D0 2012-01-30

$ gpg --send-keys 90A468A9
</pre>
<p>Your public key is now uploaded to the default key server (specified in <code>~/.gnupg/gpg.conf</code>) and it will be distributed to other key servers over the next few minutes. Once that happens, you&#8217;ll be ready to release your artefacts to Maven Central.</p>
<h3>Releasing</h3>
<p>Before we&#8217;ll configure the JAR signing, we must deal with the publish process. We set the <code>publishTo</code> (and several other settings) in <code>build.sbt</code> to use the Sonatype repository like so:</p>
<pre class="brush:[scala]">

publishTo &lt;&lt;= version { v: String =&gt;
  val nexus = "https://oss.sonatype.org/"
  if (v.trim.endsWith("SNAPSHOT"))
    Some("snapshots" at nexus + "content/repositories/snapshots")
  else
    Some("releases" at nexus + "service/local/staging/deploy/maven2")
}
</pre>
<p>Before we can publish our SBT-based project, we must ensure that its generated Maven POMs match the strict requirements of Sonatype and Maven Central. So, we must include the following code in your <code>build.sbt</code>:</p>
<pre class="brush:[scala]">
publishMavenStyle := true

publishArtifact in Test := false

pomIncludeRepository := { x =&gt; false }

pomExtra := (
  &lt;url&gt;http://www.cakesolutions.org/specs2-spring.html&lt;/url&gt;
  &lt;licenses&gt;
    &lt;license&gt;
      &lt;name&gt;BSD-style&lt;/name&gt;
      &lt;url&gt;http://www.opensource.org/licenses/bsd-license.php&lt;/url&gt;
      &lt;distribution&gt;repo&lt;/distribution&gt;
    &lt;/license&gt;
  &lt;/licenses&gt;
  &lt;scm&gt;
    &lt;url&gt;git@github.com:janm399/specs2-spring.git&lt;/url&gt;
    &lt;connection&gt;scm:git:git@github.com:janm399/specs2-spring.git&lt;/connection&gt;
  &lt;/scm&gt;
  &lt;developers&gt;
    &lt;developer&gt;
      &lt;id&gt;janmachacek&lt;/id&gt;
      &lt;name&gt;Jan Machacek&lt;/name&gt;
      &lt;url&gt;http://cakesolutions.org&lt;/url&gt;
    &lt;/developer&gt;
  &lt;/developers&gt;
)
</pre>
<p>Now, before we even attempt to run <code>sbt publish</code>, we need to specify the credentials for the Sonatype repository. But we don&#8217;t want to do that in the files we push to the VCS! Instead, we&#8217;ll create file <code>~/.sbt/sonatype.sbt</code>, which sets the <code>credentials</code> setting to the Sonatype ones:</p>
<pre class="brush:[scala]">
credentials += Credentials("Sonatype Nexus Repository Manager",
                           "oss.sonatype.org",
                           "your-sonatype-username",
                           "your-sonatype-password")
</pre>
<p>The work is done! We&#8217;ve modified </p>
<ul>
<li><code>~/.sbt/sonatype.sbt</code> with the Sonatype OSS credentials</li>
<li><code>project/plugins.sbt</code> with the <code>xsbt-gpg-plugin</code> plugin to sign the artefacts</li>
<li><code>build.sbt</code> to include the release settings</li>
</ul>
<p>Now we can run <code>sbt publish</code>, supply our key phrase go GPG and push the artefacts to Sonatype. If you are publishing snapshot release, then your work is done. If you are publishing a &#8220;real&#8221; release, keep reading.</p>
<h3>Promoting</h3>
<p>Once you&#8217;ve published your non-snapshot release, you will need to go to the Sonatype Nexus, login, select the staging repository and close it. (Again, follow the Sonatype Nexus guide for details.) Closing will verify that the Maven POMs are well formed, that the artefacts&#8217; signatures are valid. If all is well, your repository will end up in Maven Central within a few hours&#8217; time!</p>
<h2>Summary</h2>
<p>Publishing SBT-based projects to Sonatype and then Maven Central is easy&#8211;once you&#8217;ve dealt with the details of the Maven POMs. For complete views of the <code>build.sbt</code> and <code>project/plugins.sbt</code> files, take a look at Specs2 Spring&#8217;s sources at <a href="https://www.github.com/janm399/specs2-spring" target="_blank">https://www.github.com/janm399/specs2-spring</a>.</p>
<p>Josh Suereth (<a href="http://jsuereth.com/" target="_blank">http://jsuereth.com/</a>), the maintainer of the <code>xsbt-gpg-plugin</code> SBT plugin maintains a page where he outlines the latest details of the SBT deployment process. <a href="http://scala-sbt.org/using_sonatype.html" target="_blank">Clicky-here</a> to see Josh&#8217;s instructions.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/01/28/publishing-sbt-projects-to-nexus/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>This week in #Scala (27/01/2012)</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/01/27/this-week-in-scala-27012012/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=this-week-in-scala-27012012</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/01/27/this-week-in-scala-27012012/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 08:54:51 +0000</pubDate>
		<dc:creator>mark</dc:creator>
				<category><![CDATA[Mark's Blog]]></category>
		<category><![CDATA[Akka]]></category>
		<category><![CDATA[disruptors]]></category>
		<category><![CDATA[lift]]></category>
		<category><![CDATA[sbt]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[scalatra]]></category>
		<category><![CDATA[Scalaz]]></category>
		<category><![CDATA[shapeless]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1938</guid>
		<description><![CDATA[Welcome to another week in #Scala &#8211; it seems everyones been pretty busy this week! We&#8217;ve got new releases for Scalaz, Akka and shapeless to name a few, read on&#8230; &#160; New Stuff Scalaz 6.0.4 is now available! This latest &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/01/27/this-week-in-scala-27012012/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Welcome to another week in #Scala &#8211; it seems everyones been pretty busy this week! We&#8217;ve got new releases for Scalaz, Akka and shapeless to name a few, read on&#8230;</p>
<p>&nbsp;</p>
<p><strong>New Stuff</strong></p>
<p><strong><a href="https://groups.google.com/forum/#!topic/scalaz/pN-uzBKq-hY/discussion" target="_blank">Scalaz 6.0.4 is now available</a></strong>! This latest release fixes a few bugs, including a critical bug in scalaz.concurrent.Actor, and adds some new features.</p>
<p><strong><a href="http://implicit.ly/sbt-idea-100" target="_blank">sbt-idea 1.0.0</a></strong>. This SBT plugin automates creation of IntelliJ IDEA project files from sbt project definitions.</p>
<p><strong><a href="http://implicit.ly/shapeless-110" target="_blank">shapeless 1.1.0</a></strong>. Shapeless is an exploration of type class and dependent type based generic programming in Scala.</p>
<p><strong><a href="http://implicit.ly/scalatra-203" target="_blank">scalatra 2.0.3</a></strong> is out. Scalatra is a tiny, Sinatra-like web framework for Scala.</p>
<p><strong><a href="https://groups.google.com/group/akka-user/browse_thread/thread/7e1f73ca8ce9de18?pli=1" target="_blank">Akka-1.3-RC7</a></strong>. This maintenance release includes several minor improvements and bug fixes.</p>
<p><strong><a href="http://groups.google.com/group/akka-user/browse_thread/thread/2d0b56b1de826725?hl=en_US" target="_blank">Akka 2.0 pre-release Milestone 3</a>. </strong>The final release is getting closer all the time! This milestone fixes plenty of bugs, improves documentation and adds several new features. Click through for more information.</p>
<p><strong><a href="http://implicit.ly/loglady-100" target="_blank">loglady 1.0.0</a></strong>. loglady is a crazy simple logging API for Scala, wrapping slf4j.</p>
<p><strong><a href="http://implicit.ly/sbt-assembly-073" target="_blank">sbt-assembly has been updated to 0.7.3</a></strong>. sbt-assembly is a plug-in for SBT that creates a single jar of your project including all of its dependencies.</p>
<p>The <strong><a href="https://docs.google.com/document/d/18W9-fKs55wiFNjXL9q50PYOnR7-nnsImzJqHOPPbM4E/edit?hl=en_US&amp;pli=1" target="_blank">Akka 2.x roadmap</a></strong> has been updated.</p>
<p><strong><a href="http://implicit.ly/groll-120" target="_blank">groll</a></strong>, a plugin for sbt to view and navigate through the Git history has been updated to 1.2.0</p>
<p><strong><a href="http://implicit.ly/bytecask-011" target="_blank">bytecask 0.1.1</a></strong> is now available. bytecask is a low latency key/value database inspired by Bitcask</p>
<p><strong><a href="http://implicit.ly/lift-shiro-005" target="_blank">Lift Shiro 0.0.5</a></strong>. This is an integration between Apache Shiro and the Lift Web framework.</p>
<p><strong><a href="http://implicit.ly/sbt-native-packager-020" target="_blank">sbt-native-packager 0.2.0</a></strong> has been released! Click through for the full details</p>
<p>&nbsp;</p>
<p><strong>Blogs and tutorials</strong></p>
<ul>
<li>Coming to Scala &#8211; <a href="http://docs.scala-lang.org/sips/pending/futures-promises.html" target="_blank">Futures and Promises</a></li>
<li><a href="http://goodstuff.im/no-i-dont-owe-you-scala-toolsorg" target="_blank">No, I don&#8217;t owe you scala-tools.org</a> by David Pollak (@dpp)</li>
<li><a href="http://www.cakesolutions.net/teamblogs/2012/01/20/sbt-docbook-plugin/" target="_blank">SBT – DocBook Plugin</a> by Ndidi Alaneme (@AmarettoAndCode)</li>
<li><a href="http://villane.wordpress.com/2012/01/21/mixfix-operators-parser-combinators-bonus-part-2a" target="_blank">Mixfix Operators &amp; Parser Combinators, Bonus Part 2a</a> by Erkki Lindpere (@t4ffer)</li>
<li><a href="http://grahamhackingscala.blogspot.com/2012/01/javascript-and-scala-good-parts-and-bad.html" target="_blank">JavaScript and Scala: Good Parts and Bad</a> by Graham Lea</li>
<li><a href="http://scala-enterprise.blogspot.com/2012/01/scala-with-cdi-dependency-injection.html" target="_blank">Scala &#8220;Bug&#8221; with CDI Dependency Injection </a>by Hendy Irawan (@hendyirawan)</li>
<li>Great tutorial on<a href="https://github.com/scalamacros/scalamacros.github.com/blob/master/talks/2012-01-14-EnAlphaKepler.pdf" target="_blank"> Scala macros </a>(PDF!) by Eugene Burmako (@xeno_by)</li>
<li><a href="http://code.technically.us/post/16344288811/fables-of-the-reconstruction-part-1-losing-the-thread" target="_blank">Fables of the Reconstruction Part 1: Losing the Thread</a> by Nathan Hamblen (@n8han)</li>
<li><a href="http://uberblo.gs/2012/01/liftweb-bootstrap-a-nice-base-project!" target="_blank">Liftweb Bootstrap &#8211; a nice Base-Project</a> by Franz Bettag (@fbettag)</li>
<li><a href="http://dcsobral.blogspot.com/2012/01/string-interpolation-on-scala-210.html" target="_blank">String Interpolation on Scala 2.10</a> by Daniel Sobral (@dcsobral)</li>
<li>Q&amp;A: <a href="http://esj.com/Articles/2012/01/23/Introduction-to-Scala.aspx" target="_blank">An Introduction to the Scala Programming Language</a> with Martin Odersky (@odersky)</li>
<li><a href="http://debasishg.blogspot.com/2012/01/list-algebras-and-fixpoint-combinator.html" target="_blank">List Algebras and the fixpoint combinator Mu</a> by Debasish Ghosh (@debasishg)</li>
<li>AkkA Migration Guide,<a href="http://akka.io/docs/akka/snapshot/project/migration-guide-1.3.x-2.0.x.html" target="_blank"> from 1.3.x to 2.0.x</a></li>
<li><a href="http://blog.ometer.com/2012/01/24/the-java-ecosystem-and-scala-abi-versioning/" target="_blank">The Java ecosystem and Scala ABI versioning</a> by Havoc Pennington (@havocp)</li>
<li>Sonatype have posted <a href="https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide#SonatypeOSSMavenRepositoryUsageGuide-7e.DeployandStagewithSBT" target="_blank">instructions for publishing to oss.sonatype.org from SBT</a></li>
<li>Marc-Daniel Ortega (@patterngazer) has blogged about using the brilliant Disruptor framework in scala, <a href="http://patterngazer.blogspot.com/2012/01/start-trek-firing-disruptors-from-scala.html" target="_blank">A Start Trek firing Disruptors from Scala</a></li>
<li>The second part of the scala types interview with Viktor Klang is now available: <a href="http://www.scalatypes.com/webpage/episode-13-part-2-of-interview-with-viktor-klang-android-and-other-musings" target="_blank">Part 2 of Interview with Viktor Klang &#8211; Android and other musings</a></li>
</ul>
<p>&nbsp;</p>
<p>As usual feel free to drop me a <a href="mailto:markh@cakesolutions.net" target="_blank">mail</a> or message @markglh on twitter with any Scala news!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/01/27/this-week-in-scala-27012012/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Specs2 Spring from sources</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/01/23/specs2-spring-from-sources/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=specs2-spring-from-sources</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/01/23/specs2-spring-from-sources/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 19:13:59 +0000</pubDate>
		<dc:creator>Jan Machacek</dc:creator>
				<category><![CDATA[Jan's Blog]]></category>
		<category><![CDATA[SBT Docbook plugin]]></category>
		<category><![CDATA[Specs2 Spring]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1931</guid>
		<description><![CDATA[Specs2 Spring is going into Maven Central as soon as possible (I&#8217;ve submitted a request at https://issues.sonatype.org/browse/OSSRH-2760), which means that all you&#8217;ll have to do to use it in your projects is to add: &#60;dependency&#62; &#60;groupId&#62;org.specs2&#60;/groupId&#62; &#60;artifactId&#62;spring_${scala.version}&#60;/artifactId&#62; &#60;version&#62;0.3&#60;/version&#62; &#60;scope&#62;test&#60;/scope&#62; &#60;/dependency&#62; &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/01/23/specs2-spring-from-sources/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Specs2 Spring is going into Maven Central as soon as possible (I&#8217;ve submitted a request at <a href="https://issues.sonatype.org/browse/OSSRH-2760" target="_blank">https://issues.sonatype.org/browse/OSSRH-2760</a>), which means that all you&#8217;ll have to do to use it in your projects is to add:</p>
<pre class="brush:[xml]">
&lt;dependency&gt;
  &lt;groupId&gt;org.specs2&lt;/groupId&gt;
  &lt;artifactId&gt;spring_${scala.version}&lt;/artifactId&gt;
  &lt;version&gt;0.3&lt;/version&gt;
  &lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
</pre>
<p>Where <code>scala.version</code> property is <code>2.9.1</code>; or, if you prefer SBT, simply add to <code>libraryDependencies</code>:</p>
<pre class="brush:[scala]">
libraryDependencies ++= Seq(
  "org.specs2" %% "spring" % "0.3"
)
</pre>
<h2>What to do in the next few days/weeks</h2>
<p>But before that happens, you&#8217;ll need to build Specs2 Spring yourself. The good news is that it&#8217;s not at all difficult. You&#8217;ll need:</p>
<ol>
<li>Paul Phillips&#8217;s SBT Extras at <a href="https://github.com/paulp/sbt-extras">https://github.com/paulp/sbt-extras</a></li>
<li>Clones of <a href="https://github.com/janm399/sbt-docbook-plugin">https://github.com/janm399/sbt-docbook-plugin</a> and <a href="https://github.com/janm399/specs2-spring">https://github.com/janm399/specs2-spring</a></li>
</ol>
<p>Once you download the SBT Extras shell script, put it somewhere you remember and add it to your <code>PATH</code>. In my case, I copied the SBT Extras <code>sbt</code> script to <code>/usr/share/scala/sbt</code> and I&#8217;ve modified <code>/etc/profile</code> to say:</p>
<pre class="brush:[bash]">
export PATH=$PATH:/usr/share/scala/sbt
</pre>
<p>Next, clone the two repositories to some directory, say <code>~/sandbox</code>. Then you need to publish both projects to your local Ivy repository (this is where they are going to be picked up from later on). </p>
<pre class="brush:[bash]">
~/sandbox$ cd sbt-docbook-plugin
~/sandbox/sbt-docbook-plugin$ sbt publish-local
~/sandbox/sbt-docbook-plugin$ cd ../specs2-spring
~/sandbox/specs2-spring$ sbt publish-local
</pre>
<p>And you&#8217;re ready to go. The <code>"de.undercouch" % "sbt-docbook-plugin" % "0.2-SNAPSHOT"</code> <code>"org.specs2" % "spring" % "0.3"</code> are now available in your local Ivy repository; and you can use them in your Maven or SBT projects.</p>
<p>If you would like to contribute, and if you use <a href="http://www.jetbrains.com/idea">IntelliJ IDEA</a>, you can generate the IntelliJ IDEA project files by running <code>sbt gen-idea</code> in both projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/01/23/specs2-spring-from-sources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mixin composition using reflection</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/01/23/mixin-composition-using-reflection/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mixin-composition-using-reflection</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/01/23/mixin-composition-using-reflection/#comments</comments>
		<pubDate>Mon, 23 Jan 2012 13:00:35 +0000</pubDate>
		<dc:creator>Jan Machacek</dc:creator>
				<category><![CDATA[Jan's Blog]]></category>
		<category><![CDATA[Reflection mixins]]></category>
		<category><![CDATA[Reflection with]]></category>
		<category><![CDATA[Scala 2.9.1]]></category>
		<category><![CDATA[Scala reflection]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1922</guid>
		<description><![CDATA[I wanted to be able to construct Scala beans in my Spring application context, but I also wanted to be able to specify the mixins to be included in the constructed bean: &#60;?xml version="1.0" encoding="UTF-8"?&#62; &#60;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:scala="http://www.springframework.org/schema/scala" &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/01/23/mixin-composition-using-reflection/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I wanted to be able to construct Scala beans in my Spring application context, but I also wanted to be able to specify the mixins to be included in the constructed bean:</p>
<pre class="brush:[xml]">

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:scala="http://www.springframework.org/schema/scala"
  xsi:schemaLocation=...&gt;

  &lt;scala:bean class="org.cakesolutions.scala.services.UserService" &gt;
    &lt;scala:with trait="org.cakesolutions.scala.services.Mixin1" /&gt;
    &lt;scala:with trait="org.cakesolutions.scala.services.Mixin2" /&gt;

    &lt;scala:property name="dependency" value="Injected" /&gt;
  &lt;scala:bean&gt;

&lt;/beans&gt;
</pre>
<p>The difficulty is that <code>Class.forName</code> function does not allow me to specify the mixins. In the end, I modified a very hacky solution on Stack Overflow (which did not quite work in Scala 2.9 and only used one mixin). The solution involves generating classes that are similar to the classes that the Scala compiler generates when we run something like <code>new Cat with Eating with Speaking</code>. So, here it is in its full gory:</p>
<pre class="brush:[scala]">
class ScalaBeanFactory(private val beanType: Class[_ &lt;: AnyRef],
                       private val mixinTypes: Seq[Class[_ &lt;: AnyRef]]) {
  val loader = new DynamicClassLoader
  val clazz = loader.buildClass(beanType, mixinTypes)

   def getTypedObject[T] = getObject.asInstanceOf[T]

   def getObject = {
     clazz.newInstance()
   }

   def getObjectType = null

   def isSingleton = true

}

object DynamicClassLoader {
  private var id = 0
  def uniqueId = synchronized {  id += 1; "Klass" + id.toString }
}

class DynamicClassLoader extends java.lang.ClassLoader(getClass.getClassLoader) {

  def buildClass(t: Class[_ &lt;: AnyRef], vs: Seq[Class[_ &lt;: AnyRef]]) = {
    val id = DynamicClassLoader.uniqueId

    val classDef = new StringBuilder

    classDef.append("class ").append(id)
    classDef.append(" extends ").append(t.getCanonicalName)
    vs.foreach(c => classDef.append(" with %s".format(c.getCanonicalName)))

    val settings = new Settings(null)
    settings.usejavacp.value = true
    val interpreter = new IMain(settings)

    interpreter.compileString(classDef.toString())

    val r = interpreter.classLoader.getResourceAsStream(id)
    val o = new ByteArrayOutputStream
    val b = new Array[Byte](16384)
    Stream.continually(r.read(b)).takeWhile(_ &gt; 0).foreach(o.write(b, 0, _))
    val bytes = o.toByteArray

    defineClass(id, bytes, 0, bytes.length)
  }

}
</pre>
<p>The code cannot yet deal with constructors with parameters and does not copy annotations from the parent class&#8217;s constructor (should it do that?). However, it gives us a good starting point that is usable in the <code>scala</code> Spring namespace. Of course, don&#8217;t just take my word for it, verify it in a Specs2 specification:</p>
<pre class="brush:[scala]">
class ScalaBeanFactorySpec extends Specification {

  "getTypedObject mixes-in the specified traits" in {
    val f1 = new ScalaBeanFactory(classOf[Cat],
                                  Seq(classOf[Speaking], classOf[Eating]))

    val c1 = f1.getTypedObject[Cat with Eating with Speaking]

    c1.isInstanceOf[Cat with Eating with Speaking] must_==(true)

    /*
    c1.speak    // in trait Speaking
    c1.eat      // in trait Eating
    c1.meow     // in class Cat
    */
  }

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/01/23/mixin-composition-using-reflection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SBT &#8211; DocBook Plugin</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/01/20/sbt-docbook-plugin/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sbt-docbook-plugin</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/01/20/sbt-docbook-plugin/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 14:22:59 +0000</pubDate>
		<dc:creator>Ndidi</dc:creator>
				<category><![CDATA[Ndidi's Blog]]></category>
		<category><![CDATA[DocBook]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[sbt]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Specs2]]></category>
		<category><![CDATA[Specs2 Spring]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1858</guid>
		<description><![CDATA[Hey there! I&#8217;ve recently just started working with Cake Solutions, Scala and SBT. One of my first tasks was to improve the documentation in Specs2 Spring. SBT and DocBook As part of our Specs2 Spring project, we wanted to ensure users had &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/01/20/sbt-docbook-plugin/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hey there! I&#8217;ve recently just started working with <a href="http://www.cakesolutions.net/">Cake Solutions</a>, Scala and SBT. One of my first tasks was to improve the documentation in Specs2 Spring.</p>
<h2>SBT and DocBook</h2>
<p>As part of our <a href="https://github.com/janm399/specs2-spring">Specs2 Spring</a> project, we wanted to ensure users had access to Spec2 Spring&#8217;s documentation in a format they know and love, we figured we&#8217;d use <a href="http://www.docbook.org/">DocBook</a>, the multiformat-generating, markup language.</p>
<p>Fortunately a SBT plugin currently exists for DocBook, however it currently doesn&#8217;t have a few features we need.</p>
<p>We have forked the SBT DocBook plugin, because we needed to add support for XInclude, syntax highlighting, ePUB and many other improvements. Find it <a href="https://github.com/janm399/sbt-docbook-plugin">here</a>.</p>
<h2>The Setup</h2>
<p>Using it is pretty straight-forward. You should have a directory structure similar to this:</p>
<pre>MyProject
  build.sbt
  src/
    main/
      java/
      scala/
      docbook/
        main.xml
        chapter1.xml
        ...
  project/
    plugins.sbt</pre>
<p>Simply ensure all DocBook files are in the <code>src/main/docbook</code> directory. Note that if you have multiple DocBook files, the main file must be named <code>main.xml</code>. On the other hand, if there is just one file, feel free to name it anything you like.</p>
<p>Include the plugin in your <code>project/plugins.sbt</code> file as follows:</p>
<pre class="brush:[scala]">resolvers += ScalaToolsSnapshots

addSbtPlugin("de.undercouch" % "sbt-docbook-plugin" % "0.2-SNAPSHOT")</pre>
<p>That&#8217;s it!</p>
<h2>Run it!</h2>
<p>Generating documents in the format of your choice is pretty easy:</p>
<p><code><br />
$ sbt html<br />
</code></p>
<p><code><br />
$ sbt pdf<br />
</code></p>
<p><code><br />
$ sbt xhtml<br />
</code></p>
<p><code><br />
$ sbt manpage<br />
</code></p>
<p><code><br />
$ sbt eclipse-help<br />
</code></p>
<p>Checkout the readme for more options.</p>
<h2>How have we done it?</h2>
<p>Robust documentation is key to getting the community interested and involved in any project and modular documentation is key to the sanity of the project developers. An easy way to produce modular documentation is by using <a href="http://en.wikipedia.org/wiki/XInclude">XInclude</a>, sadly the plugin it uses, <a href="http://saxon.sourceforge.net/">Saxon</a> 6.5.3, for processing XSLT, cannot handle XInclude.</p>
<p>After extensive googling &amp; hacking, I eventually turned to <a href="http://xerces.apache.org/xerces2-j/">Xerces2</a> to resolve XInclude. The code looks a little something like this:</p>
<pre class="brush:[scala]">   private def transformDocBook(src: File, dst: File, styleSheet: String,
  cp: Classpath, log: Logger) {
    transform(src, dst, log) {
      //write output to temporary file. this avoids a bug in Saxon
      //that caused spaces in the output filename to be converted to
      //an escaped sequence (%20)
      val temp = File.createTempFile("sbt-docbook-plugin-", ".fo")
      val code = Fork.java(None, Seq[String](
      "-cp", cp.files.mkString(File.pathSeparator),
      "-Djavax.xml.parsers.DocumentBuilderFactory="+
        "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl",
      "-Djavax.xml.parsers.SAXParserFactory=" +
        "org.apache.xerces.jaxp.SAXParserFactoryImpl",
      "-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=" +
        "org.apache.xerces.parsers.XIncludeParserConfiguration",
      "com.icl.saxon.StyleSheet",
      "-o", temp.toString,
        src.toString, styleSheet
      ), log)

      //copy temporary file to real output file
      temp #&gt; dst !

      //delete temporary file (if this files it will be deleted on exit)
      if (!temp.delete()) {
        temp.deleteOnExit()
      }
      code
    }
  }</pre>
<p>So what&#8217;s going on here? Well <code><a href="http://harrah.github.com/xsbt/latest/api/index.html#sbt.Fork$$ForkJava">Fork.java</a></code> makes it possible for us to run a separate java process, <code>"-cp"</code> sets up it&#8217;s classpath, <code>cp.files.mkString(File.pathSeparator)</code> ensures that the correct path separator is used for your file system, the first 2 <code>-D</code> options set Xerces as Saxon&#8217;s xml parser, the last <code>-D</code> option turns on the XInclude feature and <code>-o</code> set&#8217;s Saxon&#8217;s output file or directory!</p>
<p>Maintaining Specs2 Spring and any other documentation has been made a little easier!</p>
<p>The next focus will be on improving the plugin&#8217;s output for documentation split into multiple files, in particular EPUB..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/01/20/sbt-docbook-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What can Scala do for you?</title>
		<link>http://www.cakesolutions.net/teamblogs/2012/01/20/what-can-scala-do-for-you/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=what-can-scala-do-for-you</link>
		<comments>http://www.cakesolutions.net/teamblogs/2012/01/20/what-can-scala-do-for-you/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 14:17:48 +0000</pubDate>
		<dc:creator>Jan Machacek</dc:creator>
				<category><![CDATA[Jan's Blog]]></category>
		<category><![CDATA[JEE]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[scala complexity]]></category>
		<category><![CDATA[Scala usefulness]]></category>
		<category><![CDATA[Spring Framework]]></category>

		<guid isPermaLink="false">http://www.cakesolutions.net/teamblogs/?p=1894</guid>
		<description><![CDATA[There are many new languages on the Java platform alongside the official Java language. Many have heard about Scala and many are considering using it in their code. So, how can Scala make your systems better? Is it really incredibly &#8230; <a href="http://www.cakesolutions.net/teamblogs/2012/01/20/what-can-scala-do-for-you/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There are many new languages on the Java platform alongside the official Java language. Many have heard about <a href="http://scala-lang.org" target="_blank">Scala</a> and many are considering using it in their code. So, how can Scala make your systems better? Is it really incredibly complex language that is simply far too difficult to use? Is it only suitable for very niche areas of development? Or is it a true general-purpose language, the Java of the future?</p>
<h2>What is Scala</h2>
<p>Scala is a type-safe, object-functional language. Scala allows you to build scalable (no, really?) systems by attempting to address the complexity of large systems. Its functional nature allows you to focus on the procedures in your system rather than the components in which these procedures live. Finally, Scala remains object-orieted, giving you the familiar inheritance, encapsulation and polymorphism.</p>
<p>In Scala, a functions is a first-class type; and as such can be assigned to a variable or passed as argument. You can kiss good-bye to the anonymous implementations of interfaces containing exactly one method: replace them with functions. But Scala goes further: its functions can accept functions as parameters and return functions; you can supply only some parameters of a function and the Scala compiler will create a new function that takes the remaining parameters! Finally, Scala functions can also have multiple parameter lists!</p>
<pre class="brush:[scala]">
def curry(i: Int)(j: Int) = i * j
val f = (x: Double, y: Double) =&gt; x * y
val fWithXEq5 = f(5, _: Double)
val oneTimeX = curry(1)_

fWithXEq5(3)   // == 15
curry(1)(2)    // == 2
oneTimeX(2)    // == 2
</pre>
<p>In Scala, you compose functionality through composition inheritance. You can think of this as multiple implementation inheritance with some terms and conditions; the closest equivalent in Java would be an interface with method bodies. With careful design, you can inject functionality to the objects that you construct; while keeping the elements (<code>trait</code>s in Scala speak) completely isolated and independent.</p>
<pre class="brush:[scala]">
trait Speakable {
  def sound: String

  def speak() {
    val voice = VoiceManager.getInstance().getVoice("kevin16")
    voice.allocate()
    voice.speak(sound)
    voice.deallocate()
  }
}

abstract class Animal {
  def sound: String
}
class Dog extends Animal {
  def sound = "Woof"
}
class Cat extends Animal {
  def sound = "Meow"
}
class SpeakingCat extends Cat with Speakable 

val cat = new Cat with Speakable
val dog = new Dog with Speakable
val muteDog = new Dog
val speakingCat = new SpeakingCat

cat.speak()           // OK, meows
dog.speak()           // OK, woofs
speakingCat.speak()   // OK, meows
muteDog.speak()       // Does not compile
</pre>
<p>Notice that I was able to mix-in the <code>Speakable</code> trait to either individual instances or create a new subclass of <code>Cat</code> with the speaking trait mixed-in.</p>
<p>You can also express meaning in the types in your code; meaning that in Java is impossible to convey in the source code and we must rely on the programmers&#8217; common sense.</p>
<pre class="brush:[scala]">
abstract class Animal {
  type SuitableFood &lt;: Food
}
class Cat extends Animal {
  type SuitableFood = CatFood
}
class Dog extends Animal {
  type SuitableFood = DogFood
}

abstract class Food
class CatFood extends Food
class LuxuryCatFood extends CatFood
class DogFood extends Food

def feed[A &lt;: Animal, F &lt;: A#SuitableFood](animal: A, food: F) =
  // somehow feed food to animal
</pre>
<p>I have expressed the common sense knowledge that a cat will eat cat food (just about), it will certainly eat luxury cat food, but will not touch dog food. The function <code>feed</code> enforces this at compile time!</p>
<pre class="brush:[scala]">
feed(new Cat, new CatFood)       // OK
feed(new Cat, new LuxuryCatFood) // OK
feed(new Cat, new DogFood)       // Don't be silly; does not compile!
</pre>
<h4>See! Too complicated</h4>
<p>You might be thinking, &#8220;this is exactly the complexity I don&#8217;t want in my code!&#8221; Yes, the code I&#8217;ve shown is more complex than your Java code, but it <em>does so much more!</em> It is impossible to express the concepts I&#8217;ve shown in Java as clearly and as succinctly as I can do in Scala. Yes, Scala code can be complex, but not because the language is inherently and needlessly complex, but because it can solve very complicated problems.</p>
<h4>All right, it&#8217;s not complex, but it&#8217;s not really useful</h4>
<p>Scala is brilliantly useful, because it <em>compiles to the standard Java byte code</em> and because it can use all your existing Java code. Combine Java and Scala and implement polyglot codebase that uses the best language to solve your problems! Look&#8211;you can even have use Scala with <a href="http://www.springframework.org" target="_blank">Spring Framework</a>!</p>
<pre class="brush:[scala]">
@Controller
class UserController @Autowired() (private val userService: UserService) {

  @RequestMapping(value = "/users", method = RequestMethod.GET)
  @ModelAttribute("users")
  def index = userService.findAll

}
</pre>
<h2>Find out more!</h2>
<p>Try out Scala, ask us for advice, guidance and mentoring, and you will have polyglot codebase that uses the best language to solve your problems! I&#8217;d be delighted to show you how to combine Scala in traditional Java EE applications either by implementing discrete portion of your application in Scala or even implementing most of your application in Scala, but using your existing Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cakesolutions.net/teamblogs/2012/01/20/what-can-scala-do-for-you/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

