<?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>Legolas in Minas Tirith &#187; java2scala</title>
	<atom:link href="http://www.javalinux.it/wordpress/categories/java2scala/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javalinux.it/wordpress</link>
	<description>Alessio &#38; Stefano ideas</description>
	<lastBuildDate>Tue, 20 Apr 2010 09:59: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>java2scala #2: Hello world</title>
		<link>http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/</link>
		<comments>http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 22:05:01 +0000</pubDate>
		<dc:creator>Stefano MAESTRI</dc:creator>
				<category><![CDATA[java2scala]]></category>

		<guid isPermaLink="false">http://www.javalinux.it/wordpress/?p=353</guid>
		<description><![CDATA[function fbs_click() { u=location.href; t=document.title; window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&#038;t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436"); return false; } html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;} html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;} Share The first java2scala samples we are going to discuss is generated by creating project from maven archetype. Let [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		var dzone_url = "http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/";
		var dzone_title = "java2scala #2: Hello world";
		var dzone_style = "1";
		var dzone_blurb = "																				The first java2scala samples we are going to discuss is generated by creating project from maven archetype.Let me remember you that you need an environment with:Eclipse with eclipse-scala pluginmaven wih maven-scala plugingit to clone...";
		//-->
		</script>
		<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "java2scala #2: Hello world";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.javalinux.it%2Fwordpress%2F2009%2F12%2F16%2Fjava2scala-2-hello-world%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.javalinux.it%2Fwordpress%2F2009%2F12%2F16%2Fjava2scala-2-hello-world%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>The first <a href="http://www.javalinux.it/wordpress/java2scala/">java2scala</a> samples we are going to discuss is generated by creating project from maven archetype.<br />
Let me remember you that you need an environment with:</p>
<ul>
<li>Eclipse with <a href="http://www.scala-lang.org/node/94" target="_blank">eclipse-scala plugin</a></li>
<li>maven wih <a href="http://scala-tools.org/mvnsites/maven-scala-plugin/" target="_blank">maven-scala plugin</a></li>
<li><a href="http://github.com/maeste/java2scalaSamples">git to clone the project from github</a>. This is optional, you can of course download the code directly with download link on github page itself&#8230;or digit yourself</li>
</ul>
<p>I&#8217;ve used m2eclipse plugin and created the two submodules using maven-archetype-quickstart (for java module) and scala-archetype-simple (for scala).</p>
<p>Let&#8217;s start with code samples (of course all code is available on our <a href="http://github.com/maeste/java2scalaSamples" target="_blank">github project</a>):</p>
<p><strong>Java class</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">it.javalinux.samples.java</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* Hello world!
*
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> App
<span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Hello World!&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Java unit test</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">it.javalinux.samples.java</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">junit.framework.Test</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">junit.framework.TestCase</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">junit.framework.TestSuite</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * Unit test for simple App.
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> AppTest
    <span style="color: #000000; font-weight: bold;">extends</span> TestCase
<span style="color: #009900;">&#123;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Create the test case
     *
     * @param testName name of the test case
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> AppTest<span style="color: #009900;">&#40;</span> <span style="color: #003399;">String</span> testName <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span> testName <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * @return the suite of tests being tested
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Test suite<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> TestSuite<span style="color: #009900;">&#40;</span> AppTest.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Rigourous Test :-)
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testApp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        assertTrue<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Scala class</strong></p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">package</span> it.<span style="color: #000000;">javalinux</span>.<span style="color: #000000;">samples</span>.<span style="color: #000000;">scala</span>
&nbsp;
<span style="color: #00ff00; font-style: italic;">/**
 * Hello world!
 *
 */</span>
<span style="color: #0000ff; font-weight: bold;">object</span> App <span style="color: #0000ff; font-weight: bold;">extends</span> Application <span style="color: #F78811;">&#123;</span>
  println<span style="color: #F78811;">&#40;</span> <span style="color: #6666FF;">&quot;Hello World!&quot;</span> <span style="color: #F78811;">&#41;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p><strong>Scala Unit Test</strong></p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">package</span> it.<span style="color: #000000;">javalinux</span>.<span style="color: #000000;">samples</span>.<span style="color: #000000;">scala</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">import</span> org.<span style="color: #000000;">junit</span>.<span style="color: #000080;">_</span>
<span style="color: #0000ff; font-weight: bold;">import</span> Assert.<span style="color: #000080;">_</span>
&nbsp;
<span style="color: #000080;">@</span>Test
<span style="color: #0000ff; font-weight: bold;">class</span> AppTest <span style="color: #F78811;">&#123;</span>
&nbsp;
    <span style="color: #000080;">@</span>Test
    <span style="color: #0000ff; font-weight: bold;">def</span> testOK<span style="color: #F78811;">&#40;</span><span style="color: #F78811;">&#41;</span> <span style="color: #000080;">=</span> assertTrue<span style="color: #F78811;">&#40;</span><span style="color: #0000ff; font-weight: bold;">true</span><span style="color: #F78811;">&#41;</span>
&nbsp;
<span style="color: #008000; font-style: italic;">//    @Test</span>
<span style="color: #008000; font-style: italic;">//    def testKO() = assertTrue(false)</span>
&nbsp;
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p><strong>Scala BDD specs</strong></p>

<div class="wp_syntax"><div class="code"><pre class="scala" style="font-family:monospace;"><span style="color: #0000ff; font-weight: bold;">package</span> it.<span style="color: #000000;">javalinux</span>.<span style="color: #000000;">samples</span>.<span style="color: #000000;">scala</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">import</span> org.<span style="color: #000000;">specs</span>.<span style="color: #000080;">_</span>
<span style="color: #0000ff; font-weight: bold;">import</span> org.<span style="color: #000000;">specs</span>.<span style="color: #000000;">runner</span>.<span style="color: #F78811;">&#123;</span>ConsoleRunner, JUnit4<span style="color: #F78811;">&#125;</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">class</span> MySpecTest <span style="color: #0000ff; font-weight: bold;">extends</span> JUnit4<span style="color: #F78811;">&#40;</span>MySpec<span style="color: #F78811;">&#41;</span>
<span style="color: #008000; font-style: italic;">//class MySpecSuite extends ScalaTestSuite(MySpec)</span>
<span style="color: #0000ff; font-weight: bold;">object</span> MySpecRunner <span style="color: #0000ff; font-weight: bold;">extends</span> ConsoleRunner<span style="color: #F78811;">&#40;</span>MySpec<span style="color: #F78811;">&#41;</span>
&nbsp;
<span style="color: #0000ff; font-weight: bold;">object</span> MySpec <span style="color: #0000ff; font-weight: bold;">extends</span> Specification <span style="color: #F78811;">&#123;</span>
  <span style="color: #6666FF;">&quot;This wonderful system&quot;</span> should <span style="color: #F78811;">&#123;</span>
    <span style="color: #6666FF;">&quot;save the world&quot;</span> in <span style="color: #F78811;">&#123;</span>
      <span style="color: #0000ff; font-weight: bold;">val</span> list <span style="color: #000080;">=</span> Nil
      list must beEmpty
    <span style="color: #F78811;">&#125;</span>
  <span style="color: #F78811;">&#125;</span>
<span style="color: #F78811;">&#125;</span></pre></div></div>

<p><strong>My Comments</strong><br />
It have been your first taste of scala. How do you feel with it?</p>
<p>Of course, since it is your first piece of scala code in this samples you have to note a lot of things. Don&#8217;t try to get all aspects right now, I promise I&#8217;ll explain you each of them in great detail in next future:</p>
<ul>
<li>Scala support two keyword class and object. The first one is the same than in scala, while the object is the keyword to define singleton object. Singleton object is the way scala define &#8220;static&#8221; methods in a pure object oriented style&#8230;don&#8217;t ask me to explain in this very first sample singleton object and/or companion object&#8230;we will explain their usefulness very sonn, just be a little patience and think it as classes with all static methods. Let me remark they are much more than this, but we will focus on them later in our series.</li>
<li>Scala method definition syntax. The equals after a method name suggest that a method is function returning a value, while methods without equals symbol, or declaring Unit as return type, are procedure defined only for their side effects.</li>
<li>Scala val keyword. Scala support two kind of variable definition. val keyword define an immutable variable (like final in java) while var define a mutable variable. Please keep in mind using of val is encouraged and very often used to develop with a functional style.</li>
<li>Scala conciseness: The App class is more concise in scala, and AppTest is much more concise than Java one. Conciseness can hurt you at a very first stage, you can feel concise code less readable in some cases. But it is really an advantage: less code = less error, and a good code style can help you to keep your code readable even if concise.</li>
<li>Scala doesn&#8217;t need main() method to make a class executable. You just need to extends Application trait. WTF is a trait? We will have a lot of time to explain it better with some more useful samples. For now just think a trait as an interface with some methods implementation.</li>
<li>Underscore char ( _ ) is used in imports instead of star ( * ) as wild card. Moreover Scala support also imports of classes sets in same package using {firstClass,SecondClass} notation (have a look of that on MySpecTest).</li>
<li>The scala maven artifact create also a BDD spec. It&#8217;s because BDD is supported and suggested by the scala community. I&#8217;m not going to introduce you to BDD specs here, at least not today. Just keep in mind BDD is quite used in scala community.</li>
</ul>
<p>Ok, it has been just your first taste of Scala, I&#8217;ve already said too much and put too much things in our plate. In our next post we will take a look to some very basic language&#8217;s feature like how to define class, variables, and methods/procedures.</p>
<p>Of course all code is available on our <a href="http://github.com/maeste/java2scalaSamples" target="_blank">github project</a></p>
<p>Next post is coming in few days (probably during next week end) and it will be focus on basic variables and methods definition.</p>
<p>Stay tuned.</p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;title=java2scala+%232%3A+Hello+world" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;title=java2scala+%232%3A+Hello+world" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;title=java2scala+%232%3A+Hello+world&amp;desc=The%20first%20java2scala%20samples%20we%20are%20going%20to%20discuss%20is%20generated%20by%20creating%20project%20from%20maven%20archetype.%0D%0ALet%20me%20remember%20you%20that%20you%20need%20an%20environment%20with%3A%0D%0A%0D%0A%09Eclipse%20with%20eclipse-scala%20plugin%0D%0A%09maven%20wih%20maven-scala%20plugin%0D%0A%09git%20to%20clone%20the%20project%20from%20github.%20This%20is%20optional%2C%20you%20can%20o" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;title=java2scala+%232%3A+Hello+world&amp;description=The%20first%20java2scala%20samples%20we%20are%20going%20to%20discuss%20is%20generated%20by%20creating%20project%20from%20maven%20archetype.%0D%0ALet%20me%20remember%20you%20that%20you%20need%20an%20environment%20with%3A%0D%0A%0D%0A%09Eclipse%20with%20eclipse-scala%20plugin%0D%0A%09maven%20wih%20maven-scala%20plugin%0D%0A%09git%20to%20clone%20the%20project%20from%20github.%20This%20is%20optional%2C%20you%20can%20o" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;t=java2scala+%232%3A+Hello+world" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=java2scala+%232%3A+Hello+world&amp;link=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;title=java2scala+%232%3A+Hello+world&amp;srcUrl=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;srcTitle=java2scala+%232%3A+Hello+world&amp;snippet=The%20first%20java2scala%20samples%20we%20are%20going%20to%20discuss%20is%20generated%20by%20creating%20project%20from%20maven%20archetype.%0D%0ALet%20me%20remember%20you%20that%20you%20need%20an%20environment%20with%3A%0D%0A%0D%0A%09Eclipse%20with%20eclipse-scala%20plugin%0D%0A%09maven%20wih%20maven-scala%20plugin%0D%0A%09git%20to%20clone%20the%20project%20from%20github.%20This%20is%20optional%2C%20you%20can%20o" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;title=java2scala+%232%3A+Hello+world&amp;summary=The%20first%20java2scala%20samples%20we%20are%20going%20to%20discuss%20is%20generated%20by%20creating%20project%20from%20maven%20archetype.%0D%0ALet%20me%20remember%20you%20that%20you%20need%20an%20environment%20with%3A%0D%0A%0D%0A%09Eclipse%20with%20eclipse-scala%20plugin%0D%0A%09maven%20wih%20maven-scala%20plugin%0D%0A%09git%20to%20clone%20the%20project%20from%20github.%20This%20is%20optional%2C%20you%20can%20o&amp;source=Legolas in Minas Tirith" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;bm_description=java2scala+%232%3A+Hello+world&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;title=java2scala+%232%3A+Hello+world" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;title=java2scala+%232%3A+Hello+world" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/&amp;title=java2scala+%232%3A+Hello+world" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=RT+%40maeste+java2scala+%232%3A+Hello+world+-+http://cli.gs/DuMpg&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.javalinux.it/wordpress/2009/12/16/java2scala-2-hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>java2scala #1: Introduction</title>
		<link>http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/</link>
		<comments>http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 20:52:30 +0000</pubDate>
		<dc:creator>Stefano MAESTRI</dc:creator>
				<category><![CDATA[java2scala]]></category>

		<guid isPermaLink="false">http://www.javalinux.it/wordpress/?p=340</guid>
		<description><![CDATA[function fbs_click() { u=location.href; t=document.title; window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&#038;t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436"); return false; } html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;} html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;} Share This is the very first post of a new series in which I&#8217;ll try to introduce scala to [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><div style="float: right; width: 70px; margin: 0 0 0 10px;">
<script type="text/javascript">
function fbs_click() {
u=location.href;
t=document.title;
window.open("http://www.facebook.com/sharer.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t),"sharer","toolbar=0,status=0,width=626,height=436");
return false;
}
</script>
<style type="text/css">
html .fb_share_button {display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right;}
html .fb_share_button:hover {color:#fff; border-color:#295582; background:#3b5998 url(http://b.static.ak.fbcdn.net/images/share/facebook_share_icon.gif?8:26981) no-repeat top right; text-decoration:none;}
</style>
<a href="http://www.facebook.com/share.php?u=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/" class="fb_share_button" onclick="return fbs_click()" target="_blank" style="text-decoration:none;">Share</a></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		var dzone_url = "http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/";
		var dzone_title = "java2scala #1: Introduction";
		var dzone_style = "1";
		var dzone_blurb = "																				This is the very first post of a new series in which I&#8217;ll try to introduce scala to an audience supposed to be a quite expert and very busy Java programmer. I don&#8217;t want to discuss here if scala will be the next success...";
		//-->
		</script>
		<script language="javascript" src="http://widgets.dzone.com/widgets/zoneit.js"></script></div><div style="float: right; width: 42px; padding-right: 10px; margin: 0 0 0 10px;">
		<script type="text/javascript">
		<!--
		digg_url = "http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/";
		digg_bgcolor = "#FFFFFF";
		digg_skin = "";
		digg_window = "";
		digg_title = "java2scala #1: Introduction";
		digg_media = "news";
		digg_topic = "";
		digg_bodytext = "";
		//-->
		</script>
		<script src="http://digg.com/tools/diggthis.js" type="text/javascript"></script></div><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.javalinux.it%2Fwordpress%2F2009%2F12%2F13%2Fjava2scala-1-introduction%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.javalinux.it%2Fwordpress%2F2009%2F12%2F13%2Fjava2scala-1-introduction%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>This is the very first post of a new series in which I&#8217;ll try to introduce scala to an audience supposed to be a quite expert and very busy Java programmer. I don&#8217;t want to discuss here if <a href="http://www.scala-lang.org/" target="_blank">scala</a> will be the next success language in favour of Java (even if I agree with some opinions about that <a href="http://olabini.com/blog/2008/10/language-revolution/" target="_blank">[1]</a> <a href="http://markclittle.blogspot.com/2009/11/future-of-java.html" target="_blank">[2]</a>). I&#8217;d like to just suppose you:</p>
<ul>
<li>Are a quite expert Java developer. So you can read and understand in few seconds not too complex java samples.</li>
<li>You think a polyglot programmer is a must nowadays: see <a href="http://www.javalinux.it/wordpress/2008/07/20/soa-and-heterogeneous-technology-environmet-eggs-and-chicken-problem/" target="_blank">my opinion</a> and what a <a href="http://jbossdna.blogspot.com/2008/06/java-developers-should-learn-ruby.html" target="_blank">friend of mine said</a> about that.</li>
<li>You are very interested in <a href="http://www.scala-lang.org/" target="_blank">scala language</a> and would get in touch with it</li>
<li>You are terrible busy and/or prefer to learn from examples than from a book. Of course at some stage of your learning a good book would be a must. Don&#8217;t worry there are <a href="http://www.scala-lang.org/node/959" target="_blank">many good book about scala</a>. As said if you are busy some samples comparing a well known java with scala could help you to get a first idea about scala.</li>
</ul>
<p>At this point you have probably already got what I have in mind: a post series (maybe a long one) with a set of samples written in java and in scala doing the same things. I think it could be a good way for an expert java developer to compare the language, understand similarities, difference and totally new features of the language. Of course I&#8217;ll try to help you to get all these points with some opportune comment in my posts.</p>
<p>I&#8217;m trying to make your life easier. For example what I don&#8217;t like (from my java developer point of view) of all books article and tutorials about scala (and more generally speaking about all new languages around) is that all samples are written to run in console and suppose to demonstrate everything with the console output. Of course it is the easiest way to try something in the new language and (don&#8217;t misunderstand me) scala console is great to play with the language. But it isn&#8217;t what a java developer is used to. We are used to an IDE to edit our code, a build framework to build/package/resolve dependencies, unit tests to better understand and verify code, a version control system to keep track of our code changes and their history. And I&#8217;m trying to present java2scala samples with no console, but a complete environment where you will feel at home:</p>
<p style="text-align: center;">java2scala samples will be not only a series of blog posts, but also a project:</p>
<ul>
<li>Using Eclipse and the scala plugin as IDE</li>
<li>Using maven as build environment (with scala-maven-plugin and m2eclipse integration)</li>
<li>All samples will always have its own unit tests (both for java and scala sample)</li>
<li><a href="http://github.com/maeste/java2scalaSamples" target="_blank">The project is hosted on github</a> using git as SCM and having some great good feature of github like direct download of last committed code.</li>
<li>All samples will have a blog post describing every sample details and difference and features of both languages presented in the samples. I&#8217;ll try to keep my comment as minimal as possible, hoping sample code can explain itself. I&#8217;ll just try to point your attention to some crucial aspect of samples presented, but , of course, feel free to ask.</li>
</ul>
<p>The project will be always up to date to the last blog posts (at least master branch) and will contain 2 maven modules: java samples and scala samples. Of course both module will have same samples (and their unit tests) in the same packages written in the two different languages.</p>
<p>All what you have to do is to download (or much better &#8220;<code>git clone git://github.com/maeste/java2scalaSamples.git</code>&#8221; the project), import it as maven project in an eclipse workspace with m2eclipse and scala plugin installed and start to explore it. Of course don&#8217;t forget to follow this blog for posts explaining new samples (I think I&#8217;ll have 1 or 2 new posts a week).</p>
<p>Posts in this blog will be very important too describing samples and remarking differences, explaining what I have in mind and I would demonstrate abour Scale with various samples. Javadocs of any sample will contain a link to the dedicated blog post. All posts will be laced in a dedicated category <a href="http://www.javalinux.it/wordpress/categories/java2scala/" target="_blank">java2scala</a> and will also have its own <a href="http://www.javalinux.it/wordpress/java2scala/" target="_blank">homepage</a> with this description, some useful links and a link to the category index.</p>
<p>Would you contribute in some way? Of course the simplest way is comments on this blog to add some different point of view, or open a discussion about any sample, but also someone who would join with some sample written in another language would be cool: it would permit us to compare Java, Scala, and some other language out there. Any other ideas? Feel free to write me.</p>
<p>Anyway, let&#8217;s me start with next post description of the very first samples already committed in git project&#8230;it will be posted Tuesday night (CET).</p>
<p>Stay tuned.</p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;title=java2scala+%231%3A+Introduction" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;title=java2scala+%231%3A+Introduction" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;title=java2scala+%231%3A+Introduction&amp;desc=This%20is%20the%20very%20first%20post%20of%20a%20new%20series%20in%20which%20I%27ll%20try%20to%20introduce%20scala%20to%20an%20audience%20supposed%20to%20be%20a%20quite%20expert%20and%20very%20busy%20Java%20programmer.%20I%20don%27t%20want%20to%20discuss%20here%20if%20scala%20will%20be%20the%20next%20success%20language%20in%20favour%20of%20Java%20%28even%20if%20I%20agree%20with%20some%20opinions%20about%20that%20%5B1%5D%20%5B2" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;title=java2scala+%231%3A+Introduction&amp;description=This%20is%20the%20very%20first%20post%20of%20a%20new%20series%20in%20which%20I%27ll%20try%20to%20introduce%20scala%20to%20an%20audience%20supposed%20to%20be%20a%20quite%20expert%20and%20very%20busy%20Java%20programmer.%20I%20don%27t%20want%20to%20discuss%20here%20if%20scala%20will%20be%20the%20next%20success%20language%20in%20favour%20of%20Java%20%28even%20if%20I%20agree%20with%20some%20opinions%20about%20that%20%5B1%5D%20%5B2" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;t=java2scala+%231%3A+Introduction" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-friendfeed">
			<a href="http://www.friendfeed.com/share?title=java2scala+%231%3A+Introduction&amp;link=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/" rel="nofollow" class="external" title="Share this on FriendFeed">Share this on FriendFeed</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;title=java2scala+%231%3A+Introduction&amp;srcUrl=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;srcTitle=java2scala+%231%3A+Introduction&amp;snippet=This%20is%20the%20very%20first%20post%20of%20a%20new%20series%20in%20which%20I%27ll%20try%20to%20introduce%20scala%20to%20an%20audience%20supposed%20to%20be%20a%20quite%20expert%20and%20very%20busy%20Java%20programmer.%20I%20don%27t%20want%20to%20discuss%20here%20if%20scala%20will%20be%20the%20next%20success%20language%20in%20favour%20of%20Java%20%28even%20if%20I%20agree%20with%20some%20opinions%20about%20that%20%5B1%5D%20%5B2" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;title=java2scala+%231%3A+Introduction&amp;summary=This%20is%20the%20very%20first%20post%20of%20a%20new%20series%20in%20which%20I%27ll%20try%20to%20introduce%20scala%20to%20an%20audience%20supposed%20to%20be%20a%20quite%20expert%20and%20very%20busy%20Java%20programmer.%20I%20don%27t%20want%20to%20discuss%20here%20if%20scala%20will%20be%20the%20next%20success%20language%20in%20favour%20of%20Java%20%28even%20if%20I%20agree%20with%20some%20opinions%20about%20that%20%5B1%5D%20%5B2&amp;source=Legolas in Minas Tirith" rel="nofollow" class="external" title="Share this on LinkedIn">Share this on LinkedIn</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;bm_description=java2scala+%231%3A+Introduction&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;title=java2scala+%231%3A+Introduction" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;title=java2scala+%231%3A+Introduction" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/&amp;title=java2scala+%231%3A+Introduction" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=RT+%40maeste+java2scala+%231%3A+Introduction+-+http://cli.gs/MHBPP&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.javalinux.it/wordpress/2009/12/13/java2scala-1-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
