http://www.dmst.aueb.gr/dds/pubs/Breview/2010-CR-Scala/html/review.html This is an HTML rendering of a working paper draft that led to a publication. The publication should always be cited in preference to this draft using the following reference:
|
Odersky M., Spoon L., Venners B.
Programming in Scala: A Comprehensive Step-by-Step Guide
Artima Incorporation, Mountain View, CA, 2008.
776 pp.
Writing a GUI spreadsheet application in 200 lines of code is certainly a tall order. Yet this is exactly the example provided in the last chapter of the book “Programming in Scala”. The program relies on many of Scala’s features described in the book: the integration of functional and object-oriented programming, an advanced type system allowing the enhancement of built-in types through traits, pattern matching combinators, and a powerful event-handling abstraction. And these are not all areas where Scala shines. In the scary new world of multicore processors it provides a robust foundation for concurrent programming by supporting immutable value types and adopting Erlang’s actor mechanism. Scala also aids the many developers relying mostly on application programming interfaces (APIs) by making the corresponding code appear as a domain-specific language. Its type system also helps in this regard by inferring types in the API client code, thereby reducing the verbosity associated with static typing. Furthermore, the type system promotes code robustness by handling null-like results. A carefully constructed class hierarchy gives all elements an object-like appearance without sacrificing efficiency. Other powerful features of Scala explained in the book’s 33 chapters include partially applied functions, lazy evaluation, nested packages, singleton objects, case classes, and native XML support. As one can surmise from the preceding description Scala is a large and complex language. Although it is compatible with Java’s ecosystem, Java programmers will have scores of new concepts to master, with the functional programming style being the most difficult and rewarding element. The larger examples included in the book demonstrate effectively the language’s power and appropriate design and implementation techniques.
Books introducing a new programming language are in the unenviable position of being compared with Kernighan and Ritchie’s classic The C Programming Language work. Judged by this exacting standard the book has room for improvement. A machete-wielding editor could create an superior second edition of the book by cutting down comparisons with Java, implementation details, advocacy, footnotes, and the many examples of errors and suboptimal alternatives. Ideally, such an edition would also allow mere mortals to understand the language’s more esoteric features, like the variance annotations and abstract members. In its current form the book serves programmers admirably as a detailed and complete guide to an exciting new language.