Scala Meetup Hamburg – 11. Juli 2013

Am Donnerstag, den 11. Juli 2013, fand mal wieder das Scala Meetup Hamburg statt. Als eine Art Kurzprotokoll hatte ich versprochen hier ein paar Worte aufzuschreiben. Hier also der Inhalt des durchaus gelungenen Abends:

  • Markus stellt sein “Bastel-Projekt” Scalar vor. Neben vielen interessanten Einblicken in den Code, gibt es Kurzausflüge zu Heroku und WebJars
  • Mini-Hacksession zum Thema Macros in Scala 2.10
  • Planung eines Scala-Hackatons in Hamburg (wer Interesse an der Orga hat kann sich gerne direkt bei mir melden)
  • Viele interessante Gespräche auf der Sonnenterrasse

Wer Blut geleckt hat, hier gibt’s noch einen alten Blogeintrag zum Thema Play 2.0 + Heroku und seit ein paar Wochen gibt es auch Native Support für Play 2.0 bei  NewRelic, welches auch als Heroku Plugin bereit steht.

Last but not least, nochmal ein Großes Dankeschön an oose Innovative Informatik und inoio für Lokation, Kaltgetränke und Snacks!

Bis zum 15. August 2013!

Three things I have learned from taking “Functional Programming Principles in Scala”

I have just handed in my solution the the last assignment of Odersky’s Functional Programming Principles in Scala. Time for a quick recap. Here are the three most important things which I have learned from taking the course:

1. Mutability sucks
So get rid of it. If you can design your algorithms by using immutable data structures, do it! It really does make reasoning, bug hunting and maintenance easier. Not to speak about the huge potential of the easy parallelization and scaleability when using immutable state. Speaking of good stuff and easy usage, I will defiantly miss pattern matching, higher-order functions and Scala’s excellent collection library in my daily hassle with Java.

2. The Scala community is strong
A strong language needs a strong community which drives future development and usage of it. The Scala community is growing very fast right now. Around 50,000 people took the course. But not only taking the course, but also communicating and exchanging very heavily. In the words of Martin “I was blown away by the level of interest and the high quality of your contributions in the assignments and discussion boards.” Thanks everyone for making the course such a sucess! Also a big thanks to Scala-Hamburg for organizing weekly Meetups and coding sessions.

3. Scala has a bright future (which is yet to come)
I have been working with Scala for some time now, and I have always been a fan of it. I am sure that Scala will have a bright future. On the other hand, there are still many obstacle to overcome. The tooling gets better, extremely fast I have to admit, but we are still far away from Java tooling qualities. Language stability and binary compatibility is a problem in the Scala universe, right now. With Scala 2.10 there will be many changes again. Many good changes, but binary compatibility needs to be taken more seriously. Once version 2.10 is out this will get better, and it is finally time for companies to adapt Scala.

To conclude, it was more then an interesting lecture. Many thanks to Martin Odersky and his team for pulling up this course! I can defiantly recommend it to anyone who wants to learn Scala or functional programming in general! So if there is going to be another class next year, make sure to enroll!

Downloading Sources of Required Libraries with Scala and SBT

This one is mostly a reminder to myself, as I keep forgetting what needs to be done, to download the sources of required Scala libraries into Eclipse.

Assumption One: You are already using SBT to build your project.

Assumption Two: You are already using sbteclipse to create eclipse project files.

And then: Add EclipseKeys.withSource := true to your build.sbt (more about Settings)

Double Challenge #5 – More Sports, More SUGH

Is it time again? Seems like it has been a while since I have started the last double challenge. So let’s have a quick retrospective and an outlook on the next challenges.


In one word: successful. In nine words: successful, but still a lot of work to do. We managed to set up a Scala User Group in Hamburg and do our first steps together, but now the actual work begins. I am quite curios where we are going with this and I am looking forward to work on such a great topic with such a nice group of talented people. On the sports front, I was able to find some time in February and get myself a solid basis for next months training plan.

Upcoming double challenge:

So, what are my next goals? I am going to run the Half-Marathon in Kassel together with some friends of mine. The goal is to get physically fit to finish the run without pain in less then two hours. Should be possible, I guess. Regarding IT, I will try to put some more effort into the Scala User Group to establish a communication and discussion space of Scala (and related topics) in northern Germany.

Scala User Group Hamburg

Die Scala User Group Hamburg ist da. Nachdem wir bereits im letzten Jahr innerhalb der Firma unsere Bemühungen verstärkt hatten das Thema Scala voranzutreiben, wagen wir nun den Schritt an die Öffentlichkeit. Ich bin gespannt wo uns die Reise hinführt, aktuell gibt es noch viele denkbare Richtungen und vielfältige Möglichkeiten sich einzubringen. Zunächst freue ich mich aber erstmal auf spannende Diskussionen bei den ersten Treffen und auf der Mailingliste. Also: Anmelden und Mitdiskutieren!

@all non-german-speakers: Sorry that this post is not in german, but as the User Group is German as well, understanding this post would be of little help for you anyways 😉

Double Challenge #4 – Scala User Group and Some Sports

Finally! It took some time to finish my last challenge, but in the end I managed to deploy a simple Play application to Heroku and I have also written a tutorial about it. So the curious folks among you might have a look at it, and hopefully get the application running faster than me. Well, probably the writing part took me twice as long as creating and deploying the application. Overall I have to say Play 2.0, Heroku and Scala left a very good impression, individually and in combination.

So what are the next items in my pipeline:

  • Take our work-internal Scala group to the next level and start the first Scala User Group in Hamburg
  • Get fit and healthy for the summer (Exercise/work out three times a week)

Getting started with Play 2.0, Heroku and Scala

This is another tutorial of the category ‘quick start for absolute beginners’. This time the topic is on Play 2.0, Heroku and Scala. The reason for this tutorial is that recent announcements indicate that the three topics will have a bright future together. A really nice overview of all three topics can be found in this presentation on slideshare (simply skip the Akka part. Or even better, read it as well!).

Play 2.0

As the time of writing Play 2.0 is still in beta status and according to the official homepage, APIs are likely to change a bit in the future. Nevertheless, I guess it is time to have a quick look into the new features of the framework and create a simple application.

Installing Play

As we would like to access all latest features, we are going to build Play from the source code ourselves. Therefore, you need to retrieve the sources from GitHub. If you haven’t installed git yet, do so now. Next, clone the play repository by calling git clone git://

Once you have the source code on your local machine, switch to the ../play20/framework folder and type build. This will start up an embedded sbt shell, in which you have to execute the build-repository command. (Make sure that you have a solid internet connection, as this step will require to download some megabytes of data. I tried it in the train, which was very frustrating…)

To complete the installation, you need to add the ../play20/ folder to your systems PATH environment variable.

More detailed instructions on how to install Play 2.0 (either from source, or from pre-compiled binary packages) can be found in the Play 2.0 wiki.

Creating a Simple Application

Once Play 2.0 is setup on your machine, you can create a simple applicationby typing play new myFirstApp. Provide the name of your application and as we would like to use Scala as our main development language, select the according entry. And that is it! You have just created your first Play application.

Play 2.0 comes with a nifty little console, which supports many development task out of the box. The most common command for you to execute is likely to be run. Others might include, console, clean, compile and test. The commands are more or less self explanatory. Nevertheless, there is also a help goal (you may guess what this one does), and a little bit of documentation.

If you don’t want to open the Play Console just to execute a single command, you can also type play [your_command]. For now, this is what you should do, type play run to start the server in development mode.

After the server has been started, open a browser and go to http://localhost:9000 You should see something similar to the screenshot below.

Creating and running a Play application

Play 2.0 Application

Where to go from here

In the previous section we have successfully created a simple Play 2.0 application. The second part of this post will show you how to get this application running on Heroku. But before we go there, I would like to point you to some further resources to get familiar with Play 2.0.

Most defiantly you should have a closer look on the anatomy of a Play 2.0 application. Furthermore, there are three nice sample applications, which are provided within the Play 2.0 sources and documented adequately in the wiki. Last but not least you might also want to browse through Play’s scala api manual.


I promised you, that this article will show you how to get your Play application running on Heroku. So let’s see how this is done.

Quickstarting Heroku

First of all, go to heroku signup page and enter your E-Mail address. After you have received a confirmation mail and provided a password, you are successfully signed up.

Next go to the quickstart guide and download the heroku toolbelt corresponding to your system and install it. After the installation is completed you can start to access heroku from the command line. Type heroku login to connect to the heroku platform servers. The first time you connect to heroku you need to provide your personal SSH key (or simply hit enter to automatically create a new one).

Now that you are logged in to Heroku, you are ready to deploy your Play application. Unfortunately, your app isn’t ready for that process yet, so let’s apply some minor changes.

Making your app ready for Heroku

The following section is based on the Deploying Play to Heroku tutorial, you might either read the original source or the summary given here.

Heroku needs to know how to start your add, therfore you should add a start script provided by the great folks at typesafe. Simply add the following line to your project/plugins.sbt file (Ensure that you also place a blank line before and after this line): addSbtPlugin(“com.typesafe.startscript” % “xsbt-start-script-plugin” % “0.5.0”)

Next, you need to create a plain text file in your application’s root directory called Procfile containing the following line: web: target/start

The next thing to do is create a local git repository for your application. In your application root folder, just type git init to create the repo, then type git add . to add all files and folder and finally make a commit by typing git commit -m “init”.

Last thing to do is creating your app at heroku, do this by typing heroku create –stack cedar. (Make sure you are still logged in to heroku!) You shoud note down the url where your application is going to be available. In my case that is

Making your app ready for heroku

Deploying your app

By now, everything you need to deploy your Play 2.0 application to Heroku should be set up. The last thing you need to do is simply push your contents from your local git repository to the heroku server. To do so, type git push heroku master, after your sources are transferred to the remote repository an automatic execution of sbt clean compile stage is triggered. If everything went well, you should see something similar to the screen shot below. You should also be able to go to your url and see your application running there.

Successful Heroku Deployment

You are now ready to develop some nice features for your application. Whenever you want to deploy a new version of your app heroku, simply push your changes by executing git push heroku master again. Three more hints before I leave you alone with your app: You can tpye heroku ps to check the state of your application, call heroku logs to access your applications log files, and even start a remote REPL session by executing heroku run sbt play.

And now, happy coding!

Double Challenge #3 – Play!

It’s December already, which means it is time for the last double challenge of the year and a quick retrospective.


November’s double challenge was pretty much successful. I’ve taken care of almost all Christmas presents (only minor things are missing) and have read the aimed 250 pages in my Scala book. With that preparation I think I am ready for the next steps in Scala… so here is the goal for this month.

Upcoming double challenge:

  • Deploy a simple Play! application, written in Scala, to Heroku. Why? Recent announcements indicate that the three topics will have a bright future together.
  • Do not drink any sugared/sweetened beverages until Christmas. Let’s find out how many drinks are actually full of sugar…

Double Challenge #2 – Christmas and Scala

It has been a bit more than a month since I ‘ve been writing about the first double challenge. Thus, I think it is time for a short retrospective and a call-out of the next challenges.


The first double challenge was only half a success. Cutting down meat consumption to three days a week has dramatically reduced my overall meat consumption. It wasn’t easy, but I can absolutely recommend this model (maybe start with two or three meat free days a week). I will defiantly stick with the four meat-less-days-a-week model for a few more months.
The technical challenge on the other hand was not that successful. Unfortunately, I couldn’t really find the time to get an application running on cloud foundry. Well, I got quite far with that (it is quite easy), but finding the time to write a tutorial about it was pretty much impossible. Fortunately, some good tutorials about this topic are already existent.

Upcoming double challenge:

  • Buy all Christmas presents until the end of November. Why? To escape the pre-christmas stress! Man, I hate shopping in December.
  • Work myself through another 250 pages of my beloved Scala book. (And write heaps of Scala code on the way.) Why? Scala! 😉

Scala & Maven – POM Example

Today, there is no waffle about what Scala or Maven is. This is just the plain configuration to build Scala projects with Maven. If you want more detailed information check Maven for Beginners at or browse through the documentation of the Scala-Maven-Plugin.

By the way,the configuration works as well if you want to mix Java and Scala within a single project. Just place your scala files in src/main/scala and your Java files in src/main/java (or the src/test equivalents). Maven will do the rest for you.


<project xmlns="" xmlns:xsi=""

      <name>Scala-tools Repository</name>
      <name>Scala-tools Repository</name>