Recent Posts

Recent Comments

Top Commentators

Archives


« Houses and Chrome – Interviewing Ben Goodger | Main | JAOO is all about free stuff – Comment and win »

A Scala tutorial with Bill Venners

By Therese Hansen | September 28, 2008

scala book cover small1 Today I wrote my first Scala program ever. And then the second and the third and so on. I went to the tutorial named “The Scala Experience – Programming with Functional Objects” with Bill Venners who is co-author of the book “Programming in Scala”.

The tutorial consisted of 4 short talks with exercises after each talk. It was learning by doing. For those of you who don’t know Scala, I will just write a short introduction (or steal it from the abstract of the tutorial):

Scala is a new general-purpose programming language that is fully interoperable with Java. It smoothly integrates features of object-oriented and functional languages. Scala allows a terseness of style comparable to scripting languages but has at the same time a strong and static type system.

And wikipedia says:

Scala runs on the Java Platform (Java Virtual Machine) and is compatible with existing Java programs. It also runs on Java Platform, Micro Edition Connected Limited Device Configuration. An alternative implementation exists for the .NET platform, but it has not been kept up to date.

I won’t go into detail about the code except to show you two examples of how you can write a hello world program in two different styles.

The first one is the way it was presented at the tutorial:

println("Hello, world!")

And the second one is from wikipedia:

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello, world!")
    }
}

I am not sure why you would prefer the long version, but it is the possible to use both notations.

Bill also presented what he calls “A balanced attitude for Scala programmers”. I quote:

Prefer vals, immutable objects and methods without side effects. Reach for them first. Use vars, mutable objects, and methods with side effects when you have a specific need and justification for them.

So use the functional style as long as you can, is his advice.

I could tell you much more about the Scala programming language; implicit conversions, auxiliary constructors, closures, pattern matching and type abstraction, but that would be against the spirit of the tutorial. Instead I will recommend that you get your hands dirty and play with the language yourself. Download Scala here and get the eBook here.

Happy coding!

Category: 2008 JAOO | Tags: , , , | 1 Comment »

One Response to “A Scala tutorial with Bill Venners”

  1. Karthikeyan Says:
    October 8th, 2008 at 7:01 am

    Nice introduction

Comments