www.flickr.com
Michael Kovacs' photos More of Michael Kovacs' photos
Recommend Me Cable Car Software logo

Thursday, May 08, 2008

JavaOne 2008 - Scala

Between working, waiting, wishing for my Wii to arrive (yay!) I've finally managed to make it to my first talk at JavaOne. Because my good friend David Pollak has been bugging me to check out lift (written in Scala) I decided to go and check out the guy behind the guy behind the guy (Martin Odersky) The creator of Scala. (Enough links in there for ya?)

What's scala? Well it's a fully JVM compliant language that integrates functional and object-oriented language features. Boy that sounds to me like it's gonna get complicated or bloated real fast. From Martin's presentation today:

Is Scala a kitchen sink language?
Roughly comparable to java, smaller than C++/#

Two design principles:

  1. focus on abstraction and composition so that users can implement their own specialized features

  2. have the same constructs work for small as well as large programs


Scala adds:

pure object system - everything is an object unlike Java and Ruby

operator overloading

closures - Rubyists take note

mixins - Rubyists take note

existential types

abstract types

pattern matching



Removes:

statics - it adds its own static of sorts with a singleton object (called a companion object) where you can define methods


class Sample(x: Int, val p: Int) {
def instMeth(y: Int) = x + y
}
object Sample { <-- companion object... contains statics
def staticMeth(x: Int, y: Int) = x * y
}

primitives

break,continue

special treatment of interfaces

wildcards

raw types

enums


There's a good beginner intro here.

It seems like the biggest thing that most people object to (myself included the first time I saw it) is the syntax of the language. Martin referred to it at today's talk:

x: Int instead of int x

why?

works better with type inference
works better for large type expressions
val x: HashMap[String, (String, List[Char])] = ...

instead of

public final HashMap>> x = ...

OK so this is all fine and good but what about the thing all Java devs care about... tool support. Well it turns out that there's some stuff in the works and out there for Scala:

scalac

shell: scala

testing:

sunit, scalacheck, specs

eclipse plugin v2 in beta

in the works:

intellij plugin

netbeans plugin (caoyuan)

OK so that's my nickel tour (hey you get what you pay for) of Scala. For those of you around SF after Friday checkout Scala lift off on Saturday morning at 9AM. Unfortunately I can't make it myself due to a trip I had planned but if I weren't out of town I'd definitely go check it out.

This page is powered by Blogger. Isn't yours?