Wednesday, 7 October 2009

On Learning Scala

I wanted to learn Scala because I was excited about its paradigms: functional, oo and imperative. Then I ordered the book Programming in Scala and started reading. As I mentioned in my previous post, the book is a complete guide for the language regardless of the programming languages you already know.

Along with reading the book I recommend using the Scala interpreter (apt-get install scala). Small examples in the book are done with the interpreter. In addition to implementing the examples, try whatever you like in the interpreter in order to get a feeling for the language.

My next step in learning Scala was an example application with Scala's Actors. Implementing a small program on my own helped me to understand the language. I know, that's nothing new, the way of learning a programming language is always the same. But I think that the simple application of your choice should be based upon one of the language's specialities. I picked Scala's Actors. On my way through the code I tried to use different styles of Scala's control structures. The book could provide a solution almost every time I stumbled upon something. Of course I used the Scala API specification as well.

One thing I had to google:
As a for loop in Scala has a return value, I wanted to use it with the ++ method (add all) of the collection.

// add the resulting collection of the for loop to a map
// compile error: illegal start of simple expression
map ++ for {
...
} yield ...

I think that the compiler sees a false-positive there. It took me some time to find a solution. Adding surrounding parentheses to the for expression helps.

// parentheses saved the day
map ++ ( for {
...
} yield ... )

Taxes, a simple example with Scala's actors


You need Git http://git-scm.com/ and Maven http://maven.apache.org/

git clone http://github.com/rawyler/taxactors
cd taxactors
mvn install

Monday, 24 August 2009

Programming in Scala


I have read Programming in Scala from cover to cover and wanted to share some thoughts about it. First of all, I have to say that this book is great. It is the best programming language related book I have ever seen. It was written by Martin Odersky, Lex Spoon and Bill Venners.
What a beautiful language!
You will learn to love the Scala language with this book. I like its composition with all the little comparisons between Scala and Java. The book covers all the features of Scala and even gives a good introduction to functional programming. I found the examples very understandable and eligible. The desire to write a Scala program grows with each chapter. So if you want to learn Scala I definitely recommend Programming in Scala.

Friday, 17 July 2009

Round Table Meeting with James Gosling

James Gosling
I had the great opportunity to meet the father of Java at Sun's location in Zurich, Switzerland. There were around 20 invited guests sitting in a small conference room and listening what James had to say. His speech was moderated by a Swiss Sun colleague.
The first topic was JavaOne which remained the main topic for the whole round table meeting. I didn't attend this years JavaOne, so James gave me a good insight of what has been going on there.
The real money is in games.
He talked a lot about embedded systems and mobile phones. James mentioned the Java Store which is going to be kinda similar to the Apple Store but differs the most in licensing and deployment. He said that there will be the possibility of multiple licenses for one product. The deploy to anything feature is an obvious feature of the store for Java applications. There will be difficulties for the developers to make their applications deployable to anything, e.g. even the screen resolution of different systems can mess up the simplest user interface. In the end, James mentioned that they will drop Java ME soon and improve Java's modularity with jdk7. When he was asked what he thinks about all the additional languages for the jvm, he said having lots of languages is a good thing, to which I agree.
Scala is pretty high on my list.