blog dds

2009.07.22

A Tiny Review of Scala

Earlier today I finished reading the Programming in Scala book. My review of the book should appear soon in the reviews.com site and the ACM Computing Reviews. Here I outline briefly my view of the Scala language.

Scala combines with care, pragmatism, and gusto object-oriented and functional programming. Only the most die-hard fanatics would fault its support for functional programming, yet Java programmers will initially feel at ease in the language's object-oriented cocoon. By supporting immutable values and actor syntax Scala may also offer us a way to tame the power of multi-core processors. In general, Scala follows Perl’s “the language must serve the programmer” rather than Ada’s “the language must discipline the programmer” philosophy. As a result although it has 10 fewer keywords than Java and 13 less than C++ Scala feels a bit heavy and difficult to master. Perhaps a small comprehensive quick reference card could help in this regard.

The language is a remarkable improvement over many of its predecessors; it’s a language I think worth mastering. I'm particularly impressed by its innovative support for API programming through library-provided domain-specific languages. However, I can’t say I’m completely satisfied with Scala. My immediate reservations from reading the book are the following.

  • It’s probably impossible for an average programmer to understand the language’s type system. Consequently, the only way to verify whether a program is correct is to compile it. Although the courageous revolutionary decision to adopt a sophisticated type system may advance the state of the art of programming, my fear is that it will promote a hacking mentality. How else is a programmer supposed to respond to the error message "covariant type T occurs in contravariant position"?
  • Java’s annotations although useful, are clearly an afterthought bolted onto the language. I would have hoped that Scala would integrate them into the language-proper in a graceful manner.
  • I don’t think that native support for XML was justified. XML is a lousy format for presenting structured data in a human-readable form, and has no place inside a program’s source code. Scala’s DSL capability would be enough to support structured data specifications through a simple library.
  • Scala’s syntax could do with some more ironing to increase orthogonality and consistency. For instance, why do we write
    i <- 1 to 10
    and not
    i in 1 to 10
    or
    i <- 1 ... 10
  • Java did all programmers a favor by doing away with shorthand identifiers. Scala’s mkString method brings us back to the dark ages of C’s strpbrk function.

I've already downloaded the Scala implementation, and I intend to write a substantial project in Scala. After that I hope to have a more comprehensive opinion on it.

Read and post comments    AddThis Social Bookmark Button


Creative Commons License Last modified: Wednesday, July 22, 2009 6:32 pm
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.