Web frameworks for Scala

The best way for me to learn a language generally is to build a project using that language. I have decided to start on this Scala journey and so far it’s been all theory and very little practice. In any case I have always been a web developer and that is where I would like to stay. So a web project in Scala is naturally the path I would want to go with. I kept stumbling across the Lift framework, I like Lift but it’s a bit tricky for me right now at this level and so I will perhaps visit it later.

I then came across the parsimonious Scalatra. I love it it’s light elegant and doesn’t require you to do too much to get started. I have not used it long enough to say that this is going to be my weapon of choice for any future developments but it’s a very strong candidate.

I only just now discovered the Play framework and on first glance it’s a brilliant looking MVC framework, honing in on my Zend experience with PHP. It feels like Zend, I have not actually started writing anything in it yet but I am going to attempt a full blown web project in it and see how that goes. Perhaps something for an EC2 instance.

Setting Up SBT on Ubuntu

So I have had to re-install my OS several times over the past month mainly due to my impatience (installing 11.10 beta and not having it working properly) and I have found that my SBT configurations generally evaporate with every re-installation so I wrote a little script to automate the whole process. A bit like my previous get Scala script so once again just copy and paste this into a text file, make it executable with chmod +x <filename> and run it

#!/bin/bash

cd ~

echo --------------------------------------------------------------------------------------------
echo - Getting SBT Launcher
echo --------------------------------------------------------------------------------------------
wget http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/0.11.0/sbt-launch.jar

printf 'java -Xmx512M -jar `dirname $0`/sbt-launch.jar "$@"' > sbt

chmod +x ./sbt

echo --------------------------------------------
echo - Move sbt and sbt-lauch to share
echo --------------------------------------------

sudo mv sbt /usr/share/sbt
sudo mv sbt /usr/share/sbt-launch.jar

echo --------------------------------------------------------------------------------------------
echo - symlinking sbt and sbt-lauch to /usr/bin/{sbt, sbt-lanch.jar}
echo --------------------------------------------------------------------------------------------
sudo ln -s /usr/share/sbt /usr/bin/sbt
sudo ln -s /usr/share/sbt-launch.jar /usr/bin/sbt-launch.jar

I suppose, when I get time I can make this accept parameters so you can specify the version of SBT you want and the file name you want to use etc but for now this should suffice…
comments welcome.

Installing Scala on Debian Based Systems (e.g Ubuntu)

Having followed instructions from here, which I thought was really easy, I put together a little bash script to do exactly that. And being a sucker for the latest I went with the 2.9.0.1 installation. I am honestly not sure why Ubuntu still has 2.7.7 in its repository. Ubuntu 11.10 (oneiric)  now has scala 2.9.x so you may want to use that instead of this script but if you want to keep up to date with the latest Scala release then:

Simply copy this and paste into a file, name it whatever you want, and make it executable with chmod +x

#!/bin/bash

cd ~

echo --------------------------------------------------------------------------------------------
echo - Getting Scala 2.9.0.1
echo --------------------------------------------------------------------------------------------
wget http://www.scala-lang.org/downloads/distrib/files/scala-2.9.0.1.tgz

echo --------------------------------------------------------------------------------------------
echo - Decompressing
echo --------------------------------------------------------------------------------------------
tar zxf scala-2.9.0.1.tgz

echo --------------------------------------------------------------------------------------------
echo - moving scala to /usr/share/scala
echo --------------------------------------------------------------------------------------------
sudo mv scala-2.9.0.1 /usr/share/scala

echo --------------------------------------------------------------------------------------------
echo - Symlinking executables
echo --------------------------------------------------------------------------------------------
sudo ln -s /usr/share/scala/bin/scala /usr/bin/scala
sudo ln -s /usr/share/scala/bin/scalac /usr/bin/scalac
sudo ln -s /usr/share/scala/bin/fsc /usr/bin/fsc
sudo ln -s /usr/share/scala/bin/sbaz /usr/bin/sbaz
sudo ln -s /usr/share/scala/bin/sbaz-setup /usr/bin/sbaz-setup
sudo ln -s /usr/share/scala/bin/scaladoc /usr/bin/scaladoc
sudo ln -s /usr/share/scala/bin/scalap /usr/bin/scalap