The Erlang Factory, San Francisco (March 22-26) will have a tract called Give me a break on Friday, where other programming languages are discussed. I’m doing a talk called Scala for the Curious Erlang Programmer. I’ll compare the implementations of some features that both languages implement and discuss features that are available only in Scala or Erlang. I’ll try to highlight situations where I think Scala or Erlang is the best choice.

Scala Type Parameter "Gotcha"

November 25th, 2009

During the exercises for my Scala tutorial at QCon last week, one of the students was mystified by the error message he got when he ran the following (greatly simplified…) script:

  
trait Doubler[T] {
  def double(t: T): T
}
class IntDoubler[Int] extends Doubler[Int] {
  def double(t: Int) = t * 2  
}
  
  
(fragment of ....scala):5: error: value * is not a member of Int
  def double(t: Int) = t * 2  
                          ^
one error found
  

What?! Of course Int has the * member method!!

Well, yes, the final class scala.Int type does have a * method, but that’s not what the word Int means in the declaration of IntDoubler. Because he wrote IntDouble[Int] instead of IntDouble (without a type parameter), he effectively said that IntDouble is still parameterized and the type parameter now has the name Int. The declaration that yields the intended behavior is this:

  
class IntDoubler extends Doubler[Int] {
  def double(t: Int) = t * 2  
}
  

This is a common beginner (and not-so-beginner) mistake. We discussed it in Programming Scala and I posted an enhancement request today for the Scala compiler to provide some “help”. The compiler could disallow any type name that is in scope to be used as a type parameter name, as in our example, or the compiler could at least warn you that you probably didn’t mean for the new type to have a type parameter.

I’m teaching an all-day, introductory tutorial on Scala at QCon San Francisco, November 16th. You can find out more about it at the QConSF web site.

QCon San Francisco is a new conference (this is its second year), but it is already my favorite conference in the US for general coverage of software industry topics. It’s jointly organized by InfoQ and Trifork, the people who produce the highly-regarded JAOO conference in Denmark.

The end of QCon overlaps with the start of RubyConf, so I’ll be attending that one, too, and also the one-day JRubyConf on Sunday, November 2222.

I hope to see you at any or all of those conferences!

I'm Joining DRW Trading Group

November 5th, 2009

My time at Object Mentor has come to an end. On November 30th, I start at DRW Trading, where I’ll write all kinds of software for trading applications, some of which is written in Scala, Clojure, etc.

I’m organizing a group in Chicago for people interested in Scala, called the Chicago Area Scala Enthusiasts (CASE). If you’re interested, join the google group for more information.

I posted an S5-based presentation called The Seductions of Scala (Zip). I'm giving this presentation tonight at CJUG.

To view it, unzip the file and open html/all.html in your browser. Use the arrow keys to navigate or the controls in the lower right-hand corner (visible when you mouse over).

The corresponding code is in the code directory.

Feedback welcome and I hope to see you tonight!

Slides from My QCon Talk

November 20th, 2008

I posted an extended version of the slides from my QCon San Francisco talk, Radical Simplification Through Polyglot and Poly-Paradigm Programming (PDF). The PDF includes some slides I skipped in the actual talk, for time’s sake.

InfoQ.com may offer a video of this talk. Stay tuned.

Writing a Book on Scala

October 5th, 2008

I’m pleased to announce to Alex Payne (of Twitter fame) and I are writing a book on Scala, a new language for the JVM that combines a succinct syntax, an improved object model and type system, and full support for functional programming. O’Reilly will be the publisher.

I’ve blogged about Scala on the Object Mentor blog.