May 20, 2008

Adventures in Scala: Part I

I am attempting to learn at least one new language a year and one of them this year is Scala. It is a multi-paradigm language that pretty much just takes Java and modernizes it. By that I mean it adds functional-style ways of doing things, like lambda statements, type inferencing, and gives it a much prettier syntax.

This article is about how to install Scala on Ubuntu. First off, you need Java installed. Scala programs compile to Java bytecode, which means you need the Java virtual machine in order to run your Scala programs. My advice is to install the sun-java6-jdk package. There are open-source Java implementations, but they suck. The Sun one is much better (the fact that it actually works is my main reason for using it).

Now the next step you might think is to then install the scala package from the Ubuntu repositories. Unfortunately as of today, that version is 2.3, and the most up-to-date one from the Scala pages is 2.7. You're much better off just doing this:
wget http://www.scala-lang.org/downloads/distrib/files/scala-2.7.1.final.tar.gz
tar -zxvf scala-2.7.1.final.tar.gz
sudo mv scala-2.7.1.final /usr/share/scala
sudo ln -s /usr/share/scala/bin/scala /usr/bin/scala
sudo ln -s /usr/share/scala/bin/scalac /usr/bin/scalac
Now you have a working Scala implementation! Make sure to check the most up-to-date version on their website. I'll try and keep this up-to-date, but I'm only human and only check the Scala website every now and then.

To uninstall:
sudo rm -rf /usr/share/scala /usr/bin/scala /usr/bin/scalac

4 comments:

Anonymous said...

mkdir -p /usr/share/vim/addons/ftdetect
mkdir -p /usr/share/vim/addons/indent
mkdir -p /usr/share/vim/addons/syntax
wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/browser/scala-tool-support/trunk/src/vim/ftdetect/scala.vim?format=raw -O /usr/share/vim/addons/ftdetect/scala.vim
wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/browser/scala-tool-support/trunk/src/vim/indent/scala.vim?format=raw -O /usr/share/vim/addons/indent/scala.vim
wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/browser/scala-tool-support/trunk/src/vim/syntax/scala.vim?format=raw -O /usr/share/vim/addons/syntax/scala.vim

Anonymous said...

mkdir -p /usr/share/vim/vimcurrent/ftdetect
mkdir -p /usr/share/vim/vimcurrent/indent
mkdir -p /usr/share/vim/vimcurrent/syntax
wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/browser/scala-tool-support/trunk/src/vim/ftdetect/scala.vim?format=raw -O /usr/share/vim/vimcurrent/ftdetect/scala.vim
wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/browser/scala-tool-support/trunk/src/vim/indent/scala.vim?format=raw -O /usr/share/vim/vimcurrent/indent/scala.vim
wget --no-check-certificate https://lampsvn.epfl.ch/trac/scala/browser/scala-tool-support/trunk/src/vim/syntax/scala.vim?format=raw -O /usr/share/vim/vimcurrent/syntax/scala.vim

IllegalCharacter said...

Thank you Anonymous (whoever you are!).

The three links that you can see here are the filetype detection (ftdetect), indentation settings and syntax highlighting details for programming Scala in Vim. Always handy!

You'll need to run this stuff as root, or use sudo to do it. I wonder if there is a way to do it for an individual user?

Anonymous said...

For an individual user, use ~/.vim/ instead of /usr/share/vim/vimcurrent.