Interview on Scala

I just saw the very interesting and inspiring interview on the emerging programming language Scala. Normally, I don’t like interviews alot (I rather read), but I got this link recommended by a collegue. The interview is with Martin Odersky, someone who I didn’t know but apparently worked on the creation of Scala, at his university in Switzerland.
I was already very interested on Scala, but the few things I have with the language was downloading the Scala plugin for Eclipse and playing with the interpreter. I created a Hello World program, but that’s not alot.
I am very keen on writing some useful program with it. Unfortunately, I don’t have that much time and it’s a bit hard to find the discipline in the evening and weekends to work on learning a new language.
The article is quite inspiring, and informative. Scala, resembles Haskell a lot, a purely functional language. I used the language a lot at my university. I hated it and loved it, as the language has many fine features, but it’s also very hard to develop anything practical. One of the nice (and hard) features of Haskell are, you’ll need to write only few lines of code to perform already quite a lot.
Popular demonstrations in Haskell are display of recursive functions, like Fibonacci. Let’s try this in Scala, to create a function that produces the n’t number of a Fibonacci row. With a bit of help of the web on the syntax of Scala (lots of tutorials) and the definition of Fibonacci (sigh), I produced this:
package gerbrand;

object TestMe {
def fib(n : Int):Int =
if (n==0)
1
else if (n==1)
1
else
fib(n – 2)+fib(n-1)

def main(args : Array[String]) : Unit = {
print (“Fibonacci: “)
for (n <- 0 to 10)
print (fib(n)+” “)
}
}

Looks pretty neat. The syntax is quite different from Java (it’s also a completely other language), but the program still runs inside the JVM. Java classes, components can be accessed from Java, so you can also use that).

There’s a link to a book on Scala. I’m tempted to buy it, unfortunatelly there’s only an online, and it’s still work in progress.
I wondered if there’s already a Scala on Rails. After some very short searching, I found Lift (also mentioned in the interview).  Looks cool from what I see in the code. Unfortunatelly, I can’t get the samples to run, seems the Maven repositery seems currently to miss jetty and the scala repository seems down. Let’s try tomorrow.

Keizersgracht

Enkele dagen terug liep ik in Amsterdam, langs een gracht. Ik moest bij een adres langs de Keizersgracht zijn. Ik vermoedde al langs de juiste gracht te lopen. Ik vroeg een voorbijganger of ik langs de Keizersgracht liep. Hij negeerde me alleen volledig en liep met een strak gezicht langs me heen. Een toerist vermoedde ik, en zat me te bedenken dat ik toch niet graag in het centrum van Amsterdam zou willen wonen, waar in helft van de restaurants en kroegen door de barmannen en serveerders alleen Engels gesproken wordt.
Ik liep verder en vroeg een meisje dat ik tegenkwam of dit de keizersgracht. “Ik hoop het wel”. Ik zag al een bordje met Keizersgracht. Even later zag ik terug, dat de man die langs me heen liep door het meisje toegeschreeuwd worden. Blijkbaar hadden ze hier afgesproken.
Het was een beetje leuk om mee te maken. Ik liep overigens aan de verkeerde kant van de gracht, waardoor ik net 5 minuten te laat aankwam.