The Artima Developer Community
Sponsored Link

Ideas, Languages, and Programs
The Myth Makers 1: Scala's "Type Types"
by Martin Odersky
December 18, 2008
Summary
Busting some myths that have sprung up around Scala.

Advertisement

2008 has seen a lot of activity around Scala. All major IDEs now have working Scala plugins. A complete Scala tutorial and reference book was published and several others are in the pipeline. Scala is used in popular environments and frameworks, and is being adopted by more and more professional programmers in organizations like Twitter, Sony Imageworks, and Nature, along with many others.

It's also a sign of growing momentum that well-known commentators like Ted Neward, Daniel Spiewak and the JavaPosse have covered Scala in depth. Other bloggers have argued more from the outside, without really getting into Scala all that deeply. I find the latter also useful, because it shows how Scala is perceived in other parts of the programming community. But sometimes, initial misconceptions can create myths which stand in the way of deeper understanding.

So, as an effort of engaging in the debate, let me address in a series of blog posts some of the myths that have sprung up in the last months around and about Scala. I'll start with a post by Steve Yegge. Like many of Steve's blogs, this one is quite funny, but that does not make it true.

Steve (in his own words) "disses" Scala as "Frankenstein's Monster" because "there are type types, and type type types". (Don't ask me what that means!) In fact, it seems he took a look at the Scala Language Specification, and found its systematic use of types intimidating. I can sympathize with that. A specification is not a tutorial. Its purpose is to give compiler writers some common ground on which to base their implementations. This is not just a theoretical nicety: the implementation of JetBrains' Scala compiler for IntelliJ makes essential use of the language specification; that's how they can match our standard Scala compiler pretty closely. The other purpose of a specification is that "language lawyers" - people who know the language deeply - can resolve issues of differing interpretations. Both groups of people value precision over extensive prose. Scala's way of achieving precision in the spec is to be rather formal and to express all aspects of compile-time knowledge as types. That's a notational trick which let us keep the Scala spec within 150 pages - compared to, for instance, the 600 pages of the Java Language Specification.

The way a spec is written has nothing to do with the experience of programmers. Programmers generally find Scala's type system helpful in a sophisticated way. It's smart enough to infer many type annotations that Java programmers have to write. It's flexible enough to let them express APIs any way they like. And it's pragmatic enough to offer easy access to dynamic typing where required. In fact Scala's types get out of the way so much that Scala was invited to be a contender in last JavaOne's Script Bowl, which is normally a shootout for scripting languages.

But Steve's rant was not really about technical issues anyway. He makes it clear that this is just one move in a match between statically and dynamically typed languages. He seems to see this as something like a rugby match (or rather football match in the US), where to score you need just one player who makes it to the ground line. Steve's on the dynamically typed side, pushing Rhino as the Next Big Language. Java is the 800-Pound Gorilla on the statically typed side. Steve thinks he has Java covered, because its type system makes it an easy target. Then out of left field comes another statically typed language that's much more nimble and agile. So he needs to do a quick dash to block it. If he can't get at the programming experience, it must be the complexity of the specification. This is a bit like saying you should stay away from cars with antilock braking systems because the internal workings of such systems are sophisticated!

Not quite surprisingly, a number of other bloggers have taken Steve's rather lighthearted jokes as the truth without bothering to check the details too much and then have added their own myths to it. I'll write about some of them in the next weeks.

Talk Back!

Have an opinion? Readers have already posted 13 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Martin Odersky adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Martin Odersky is the inventor of the Scala language and professor at EPFL in Lausanne, Switzerland. In 2008, he was appointed fellow of the ACM for his contributions to the fusion of functional and object-oriented programming. He believes the two paradigms are two sides of the same coin, to be unified as much as possible. To prove this, he has worked on a number of language designs, from Pizza to GJ to Functional Nets. He has also influenced the development of Java as a co-designer of Java generics and as the original author of the current javac reference compiler.

This weblog entry is Copyright © 2008 Martin Odersky. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us