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.

Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen.

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit /  Bijwerken )

Google photo

Je reageert onder je Google account. Log uit /  Bijwerken )

Twitter-afbeelding

Je reageert onder je Twitter account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )

Verbinden met %s

%d bloggers liken dit: