This page is no longer maintained — Please continue to the home page at

A Taste of 2.8: Scala Collections

The collection library is undergoing a complete overhaul for Scala 2.8, with three goals in mind: a more coherent design; more code reuse; compatibility with existing sources. Download a recent nightly build (linux-mac / windows) to try the new library for yourself.

A coherent design

A visit of the 2.8 collections library (see its API) starts in the scala.collection package that contains an abstract version of all major collection types: maps, sets, sequences, etc. Two sub-packages contain actual implementations: mutable for implementations in which elements can be added and removed, immutable for implementations that can only be changed by creating a new copy (functional-style). Usual operations, such as creating a new collection, are available for all collections using a coherent design: Vector(1, 2)Set(1, 2) or Map("x" -> 1, "y" -> 2) will create new instances. Even abstract collections have standard constructors: call Iterable(1, 2) to get a default implementation.

Code reuse

As a user of the collection library, you may not have noticed the degree of code duplication in the 2.7 collections library. However, you may have noticed the bugs caused by it. The 2.8 collection library abstracts most of the implementation of collections to classes in the generic package. Collection classes are created by extending various bits of generic implementation, maximising the degree of code reuse. If you design new collections, you can also grab whatever bit of implementation you require from the generic package, and simplify your own implementation.

Compatibility with existing sources

Despite the Scala 2.8 collection library being rewritten from scratch, compatibility with existing source has been mostly retained. Some methods, which had to go, have been deprecated but will still be available in 2.8. Only users of JCL will be directly affected by the change: Java-compatibility mappings are provided by the collection library, but they could not be made compatible with JCL. Don't forget to recompile though: Scala 2.8 bytecode format is not compatible with that of 2.7.

Get ready for Scala 2.8

Nightly builds of Scala 2.8 ship with an early version of the new collections library. We are still tweaking the design, so let us know what you think of it. Also, download it (linux-mac / windows), try it on your code and let us know about your own experience of moving from the old collections to the new collections. If you want to know more about the 2.8 collection library, read Martin Odersky's SID that describes their implementation in details.

Re: A Taste of 2.8: Scala Collections

Very interesting, especially the the new implicit conversions. But - AFAIU - the conversions still are compiler-magic right? I still have to define them in my scala-code for JAVA to use? Or is it so that I can in 2.8 do from JAVA:

java.lang.Iterable myJavaIterable = myScalaList.asIterable();

Re: A Taste of 2.8: Scala Collections

Even a standard library to help go the other way would be great

Re: A Taste of 2.8: Scala Collections

I do hope that the nasty problem of different things with the same name goes away in 2.8. I get a lot of headache from error messages like this:

type mismatch; found : scala.collection.Map[String,Double] required: Map[String,Double]

And you can't even easily convert from one to the other I think.

Does this problem go away in 2.8?

Re: A Taste of 2.8: Scala Collections

i was pretty good at working with scala a couple of years ago

butnow i feel like i missed out a lot. what is the latest version?

i've got to freshen my knowledge

(the creator of mov to avi converter)

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland