<?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>Gerbrand on ICT &#187; scala</title>
	<atom:link href="http://www.gerbrand-ict.nl/tag/scala/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gerbrand-ict.nl</link>
	<description>Weblog on JEE and software-engineering</description>
	<lastBuildDate>Wed, 11 Aug 2010 20:51:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Scala and Java</title>
		<link>http://www.gerbrand-ict.nl/2010/03/scala-and-java/</link>
		<comments>http://www.gerbrand-ict.nl/2010/03/scala-and-java/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 12:53:22 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=408</guid>
		<description><![CDATA[When you say Ruby, you say Rails. When you say Groovy, you say unit-tests, scripting and integration. Well that might be over-acted, but that&#8217;s what most people make of it. Some people remark Scala is best-suited for backend-code, or very good at parallel code, but apart from that I&#8217;ve never heard that Scala is the [...]]]></description>
			<content:encoded><![CDATA[<p>When you say Ruby, you say Rails. When you say Groovy, you say unit-tests, scripting and integration. Well that might be over-acted, but that&#8217;s what most people make of it.<br />
Some people remark Scala is best-suited for backend-code, or very good at parallel code, but apart from that I&#8217;ve never heard that Scala is the language for the Lift framework. Or the language to use when you want to create multi-threaded code. What I hear mostly, Scala is the new Java.<br/><br />
Would that be true: could you use Scala as a dropin replacement for Java, as, let&#8217;s say, a <strong>Java 2.0</strong> or <strong>Java 8</strong>?</p>
<p>
In the coming postings I want to investigate that claim using my knowledge of experience in Java/J2EE and my complete lack of experience in Scala. Can you say to you&#8217;re developers, or yourself, from this day on, we&#8217;ll use Scala instead of Java to do our development?</p>
<p>
For now, I found this nice presentation I want to share: <a title="Miles Sabin Introduction To Scala For Java Developers" href="http://www.slideshare.net/skillsmatter/miles-sabin-introduction-to-scala-for-java-developers">Introduction To Scala For Java Developers</a> by Miles Sabin.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2010/03/scala-and-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Internal DSLs in Scala</title>
		<link>http://www.gerbrand-ict.nl/2009/03/internal-dsls-in-scala/</link>
		<comments>http://www.gerbrand-ict.nl/2009/03/internal-dsls-in-scala/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 20:42:30 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=135</guid>
		<description><![CDATA[The language Ruby is very extendible, making the language very suitable for designing internal DSL&#8217;s &#8211; custom languages for domain, or single purpose as you could call it. Togetter with a collegue I wrote on Internal DSLs in Ruby some time ago for my company&#8217;s website and newsletter. Scala is also quite extensible, and type [...]]]></description>
			<content:encoded><![CDATA[<p>The language Ruby is very extendible, making the language very suitable for designing internal DSL&#8217;s &#8211; custom languages for domain, or single purpose as you could call it. Togetter with a collegue I wrote on <a href="http://www.whitehorses.nl/?link=2099">Internal DSLs in Ruby </a>some time ago for my company&#8217;s website and newsletter. Scala is also quite extensible, and type safe. How good will Scala be on the creation on Internal DSL? Bill Venners write about this subject on Artima: <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=251945">Comparing DSLs in Ruby and Scala</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/03/internal-dsls-in-scala/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala and Twitter update</title>
		<link>http://www.gerbrand-ict.nl/2009/03/scala-and-twitter-update/</link>
		<comments>http://www.gerbrand-ict.nl/2009/03/scala-and-twitter-update/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 12:50:40 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=108</guid>
		<description><![CDATA[Recently wrote about a presentation on the interesest in Scala of tech-lead at Twitter. On another site a Twitter developer wrote half a year ago that several people at his company are learning Scala.  On the Twitter dev site I found a client-application for Twitter written in Scala.  The application looks simple, but I make [...]]]></description>
			<content:encoded><![CDATA[<p>Recently wrote about a presentation on the interesest in Scala of tech-lead at Twitter. On another site a Twitter developer<a href="http://www.gracelessfailures.com/2008/06/test-post.html"> wrote half a year ago</a> that several people at his company are learning Scala.  On the Twitter dev site I found a <a href="http://github.com/dcbriccetti/scala-experiments/tree/master">client-application</a> for Twitter written in Scala.  <a href="http://davebsoft.com/applications/simple-twitter-client">The application</a> looks simple, but I make to little use of Twitter to know how good it compares. According to another article I found via Google, <a href="http://www.scala-lang.org/node/1008">part of Twitter is (re)implemented in Scala</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/03/scala-and-twitter-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scala and twitter</title>
		<link>http://www.gerbrand-ict.nl/2009/03/scala-and-twitter/</link>
		<comments>http://www.gerbrand-ict.nl/2009/03/scala-and-twitter/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 16:01:42 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=89</guid>
		<description><![CDATA[By stumbled on a presentation by API lead of Twitter on Scala. For a moment I hoped Twitter was developed, but the language used at Twitter is Ruby. The speaker investigated a few current-date programming languages and found Scala met his needs best. See Why Scala.]]></description>
			<content:encoded><![CDATA[<p>By stumbled on a presentation by API lead of <a href="http://twitter.com/">Twitter </a>on <a href="http://www.scala-lang.org/">Scala</a>. For a moment I hoped Twitter was developed, but the language used at Twitter is Ruby. The <a href="http://www.web2expo.com/webexsf2009/public/schedule/speaker/3485">speaker </a>investigated a few current-date programming languages and found Scala met his needs best. See <a href="http://www.slideshare.net/al3x/why-scala-presentation">Why Scala</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/03/scala-and-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Combining Flex and Scala using Liftweb and BlazeDS</title>
		<link>http://www.gerbrand-ict.nl/2009/01/combining-flex-and-scala-using-liftweb-and-blazeds/</link>
		<comments>http://www.gerbrand-ict.nl/2009/01/combining-flex-and-scala-using-liftweb-and-blazeds/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 17:05:03 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[flex]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=64</guid>
		<description><![CDATA[I wanted to setup a sample project that uses Flex and Scala. I followed the excellent tutorial on FlexOnRails: Integrating Flex, BlazeDS, and Scala/Lift. The tutorial helps a lot explaining how to set up your sample project. Unfortunately the tutorial is a bit outdated with regard to latest versions. Fortunately I could solve all problems! [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to setup a sample project that uses Flex and Scala. I followed the excellent tutorial on FlexOnRails: <a href="http://flexonrails.net/?p=103">Integrating Flex, BlazeDS, and Scala/Lift</a>. The tutorial helps a lot explaining how to set up your sample project. Unfortunately the tutorial is a bit outdated with regard to latest versions. Fortunately I could solve all problems! I&#8217;ll list the problems I had. Also, I&#8217;ll post my project. I won&#8217;t redo the tutorial, as I certainly couldn&#8217;t to a better job then Derek Wischusen.</p>
<ul>
<li>First problem I had, was getting my backend compiled. The liftweb has changed slightly, as a result the class Boot.scala didn&#8217;t work anymore. I could solve it by downloading the latest <strong>Liftweb framework, version 0.9</strong>. I copied &amp; pasted the Boot.scala from the sites/examples dir. After a few tweaks (removing code I didn&#8217;t need), the project compiled successfully!</li>
<li>Then I wanted to setup the flex project. That was quite easy, using the latest version of <strong>Flexbuilder (version 3.0.2.214193)</strong>.<br />
I setup flexbuilder to deploy in the backend/webapp directly, as is explained in the tutorial.</li>
<li>I ran the project by running the following maven commands in the backend subdir:<br />
<strong>mvn package</strong><br />
<strong>mvn jetty:run</strong></li>
<li>While running the example, I got a AbstractMethodError. I wasn&#8217;t the first person to get that error, as I found on the <a href="http://markmail.org/message/sllcgvhebbp3nzbw#query:java.lang.AbstractMethodError%3A%20net.liftweb.http.SessionMaster%24.mailbox_%24eq(Lscala%2Factors%2FMessageQueue%3B)+page:1+mid:v5y2777ssl4mmqfq+state:results">Liftmailinglist</a>. I could fix the problem by using <strong>Scala version 2.7.1</strong> for my own project. All in all, when using bleeding-edge technologies, having the latest version isn&#8217;t good always!</li>
<li>After that I ran the project  again. Now I get a NullPointerException, seems the line <em>val msgBroker = MessageBroker.getMessageBroker(null)</em> returns Null.<br />
Turned out I forgot to update the web.xml, the Flex servlet and other configuration has to be added.</li>
</ul>
<p>I named the sample project Elegante. Download the source here: <a href="http://www.gerbrand-ict.nl/wp-content/uploads/2009/01/elegante.zip">elegante.zip</a>. For explanation see the original tutorial.</p>
<hr/>
<iframe src="http://rcm.amazon.com/e/cm?t=geonic-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0981531601&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/01/combining-flex-and-scala-using-liftweb-and-blazeds/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Scala release</title>
		<link>http://www.gerbrand-ict.nl/2009/01/scala-release/</link>
		<comments>http://www.gerbrand-ict.nl/2009/01/scala-release/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 23:36:47 +0000</pubDate>
		<dc:creator>gerbrand</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.gerbrand-ict.nl/?p=53</guid>
		<description><![CDATA[The final release of Scala 2.7.3 is out! You can download the release from the scala-download page. Some background: Scala is a elegant language that runs on the JavaVM. Unlike languages like Ruby and Groovy, Scala is statically typed. One of the reasons a lot of people like dynamic languages more than Java, is because [...]]]></description>
			<content:encoded><![CDATA[<p>The final release of Scala <strong>2.7.3</strong> is out! You can download the release from the <a href="http://www.scala-lang.org/downloads">scala-download</a> page.</p>
<p>Some background: Scala is a elegant language that runs on the JavaVM. Unlike languages like Ruby and Groovy, Scala is statically typed. One of the reasons a lot of people like dynamic languages more than Java, is because Java is very verbose. That verbosity is, amongst others, because of its type-system.<br />
However, unlike Java the typing-system is much more elegant and flexible. Because Scala can infer types, you&#8217;ll have to define types only when necessary. Look for example at the following code (taken from the <a href="http://www.scala-lang.org/node/220">Scala website</a>):</p>
<pre><span style="font-weight: bold;">object</span> Maps {
  <span style="font-weight: bold;">val</span> colors = Map(<span style="color: red;">"red"</span> -&gt; 0xFF0000,
                   <span style="color: red;">"turquoise"</span> -&gt; 0x00FFFF,
                   <span style="color: red;">"black"</span> -&gt; 0xFFFFFF,
                   <span style="color: red;">"orange"</span> -&gt; 0xFF8040,
                   <span style="color: red;">"brown"</span> -&gt; 0x804000)

  <span style="font-weight: bold;">def</span> main(args: Array[String]) {
    <span style="font-weight: bold;">for</span> (name &lt;- args) println(
      colors.get(name) <span style="font-weight: bold;">match</span> {
        <span style="font-weight: bold;">case</span> Some(code) <span style="font-weight: bold;">=&gt;</span>
          name + <span style="color: red;">" has code: "</span> + code
        <span style="font-weight: bold;">case</span> None <span style="font-weight: bold;">=&gt;</span>
          <span style="color: red;">"Unknown color: "</span> + name
      }
    )
  }
}</pre>
<p>There are no explicit type definitions, eventhough every defined value is statically typed. The scala compiler can infer that the <strong>val colors</strong> should have type scala.collection.immutable.Map[java.lang.String,Int]. Compare that to Java, where you&#8217;d  have to use Map&lt;String,Integer&gt; several times.<br />
Minor sidenote: there are languages that have an even more advanced typing system, see, <a href="http://www.codecommit.com/blog/scala/is-scala-not-functional-enough">this nice article</a>.</p>
<p>Furthermore, another what&#8217;s very much to like about new dynamic languages is it&#8217;s extendibily. You can extent a language like Ruby or Groovy, and create a new internal language.  Eventhough Scala is statically typed, in Scala this is possible as well.<br />
Let&#8217;s say you want a sort method for the general Array type. This can be accomplished with the following code:</p>
<pre><span style="color: green;">/* Defines a new method 'sort' for array objects */</span>
<span style="font-weight: bold;">object</span> implicits <span style="font-weight: bold;">extends</span> Application {
  <span style="font-weight: bold;">implicit</span> <span style="font-weight: bold;">def</span> arrayWrapper[A](x: Array[A]) =
    <span style="font-weight: bold;">new</span> {
      <span style="font-weight: bold;">def</span> sort(p: (A, A) <span style="font-weight: bold;">=&gt;</span> Boolean) = {
        util.Sorting.stableSort(x, p); x
      }
    }
  <span style="font-weight: bold;">val</span> x = Array(2, 3, 1, 4)
  println(<span style="color: red;">"x = "</span>+ x.sort((x: Int, y: Int) <span style="font-weight: bold;">=&gt;</span> x &lt; y))
}</pre>
<p>There&#8217;s a lot more exciting, as a last example, I put a code-snippet that demonstrates how XML is integrated in Scala:</p>
<pre>  <span class="kw" style="font-weight: bold;">val</span> header =
    <span class="tag" style="color: blue;">&lt;head&gt;</span>
      <span class="tag" style="color: blue;">&lt;title&gt;</span>
        { <span class="str" style="color: red;">"My Address Book"</span> }
      <span class="tag" style="color: blue;">&lt;/title&gt;</span>
    <span class="tag" style="color: blue;">&lt;/head&gt;</span>;

  <span class="kw" style="font-weight: bold;">val</span> people = <span class="kw" style="font-weight: bold;">new</span> AddressBook(
    Person(<span class="str" style="color: red;">"Tom"</span>, 20),
    Person(<span class="str" style="color: red;">"Bob"</span>, 22),
    Person(<span class="str" style="color: red;">"James"</span>, 19));

  <span class="kw" style="font-weight: bold;">val</span> page =
    <span class="tag" style="color: blue;">&lt;html&gt;</span>
      { header }
      <span class="tag" style="color: blue;">&lt;body&gt;</span>
       { people.toXHTML }
      <span class="tag" style="color: blue;">&lt;/body&gt;</span>
    <span class="tag" style="color: blue;">&lt;/html&gt;</span>;</pre>
<p>Finally, an example of a quicksort taken from this <a href="http://en.literateprograms.org/Quicksort_(Scala)">sample website</a>. Impressive, but I am to much unexperienced in Scala to grasp that code immediately:</p>
<pre>  <strong>def</strong> <span style="color: #2040a0;">sort</span><span style="color: #e8132c;">[</span><span style="color: #2040a0;">A</span> <span style="color: #e8132c;">&lt;%</span> <span style="color: #2040a0;">Ordered</span><span style="color: #e8132c;">[</span><span style="color: #2040a0;">A</span><span style="color: #e8132c;">]</span><span style="color: #e8132c;">]</span><span style="color: #4444ff;"><strong>(</strong></span><span style="color: #2040a0;">xs</span><strong>:</strong> <span style="color: #2040a0;">List</span><span style="color: #e8132c;">[</span><span style="color: #2040a0;">A</span><span style="color: #e8132c;">]</span><span style="color: #4444ff;"><strong>)</strong></span><strong>:</strong> <span style="color: #2040a0;">List</span><span style="color: #e8132c;">[</span><span style="color: #2040a0;">A</span><span style="color: #e8132c;">]</span> <strong>=</strong> <span style="color: #4444ff;"><strong>{</strong></span>
    <span style="color: #2040a0;">xs</span> <strong>match</strong> <span style="color: #4444ff;"><strong>{</strong></span>
        <strong>case</strong> <span style="color: #2040a0;">List</span><span style="color: #4444ff;"><strong>(</strong></span><span style="color: #4444ff;"><strong>)</strong></span> <strong>=&gt;</strong> <span style="color: #2040a0;">xs</span>
        <strong>case</strong> <strong>_</strong> <strong>=&gt;</strong>  <span style="color: #2040a0;">sort</span><span style="color: #4444ff;"><strong>(</strong></span><strong>for</strong><span style="color: #4444ff;"><strong>(</strong></span><span style="color: #2040a0;">item</span> <strong>&lt;-</strong> <span style="color: #2040a0;">xs</span>.<span style="color: #2040a0;">tail</span> <strong>if</strong> <span style="color: #2040a0;">item</span> &lt; <span style="color: #2040a0;">xs</span>.<span style="color: #2040a0;">head</span><span style="color: #4444ff;"><strong>)</strong></span> <strong>yield</strong> <span style="color: #2040a0;">item</span><span style="color: #4444ff;"><strong>)</strong></span> ::: <span style="color: #2040a0;">List</span><span style="color: #4444ff;"><strong>(</strong></span><span style="color: #2040a0;">xs</span>.<span style="color: #2040a0;">head</span><span style="color: #4444ff;"><strong>)</strong></span> ::: <span style="color: #2040a0;">sort</span><span style="color: #4444ff;"><strong>(</strong></span><strong>for</strong><span style="color: #4444ff;"><strong>(</strong></span><span style="color: #2040a0;">item</span> <strong>&lt;-</strong> <span style="color: #2040a0;">xs</span>.<span style="color: #2040a0;">tail</span> <strong>if</strong> <span style="color: #2040a0;">item</span> &gt;= <span style="color: #2040a0;">xs</span>.<span style="color: #2040a0;">head</span><span style="color: #4444ff;"><strong>)</strong></span> <strong>yield</strong> <span style="color: #2040a0;">item</span><span style="color: #4444ff;"><strong>)</strong></span>
    <span style="color: #4444ff;"><strong>}</strong></span>
  <span style="color: #4444ff;"><strong>}</strong></span></pre>
<hr/>
Below a book about Scala I recently read<br />
<iframe src="http://rcm.amazon.com/e/cm?t=geonic-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0981531601&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;m=amazon&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerbrand-ict.nl/2009/01/scala-release/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
