

What's New in Scala 2.8: The Architecture of Scala Collections - pan69
http://www.artima.com/scalazine/articles/scala_collections_architecture.html

======
punditator
I suppose it isn't surprising that Odersky glosses over the fact that the new
collections library in Scala isn't type-safe. They apparently just couldn't
get the variances on type parameters to work out, so they cheated and added an
annotation to ignore them: @uncheckedVariance.

"Scala is a general purpose programming language designed to express common
programming patterns in a concise, elegant, and type-safe way."

Really? But not expressive enough to write the standard collections library I
guess?

[UPDATE]: It gets even more amusing -- I just learned they have a paper on the
collections library called "Fighting Bit Rot with Types" where they again make
no mention of @uncheckedVariance. I guess mentioning that they had to cheat
the type system would have undermined their goal of "focussing on the role
that type systems play in keeping software architectures coherent over time."

~~~
viraptor
Not that I disagree that it's a bad example in general if you cannot express
the internals in your language using the same language... but I see why they'd
do that really. "But not expressive enough to write the standard collections
library I guess?" - standard, truly extensive and universal collections
library is far from a "common programming patterns" really. If sticking to the
type-safety which can be provided right now means weaker or less flexible
collections - maybe it's the right tradeoff they made?

For more explanation on why it's needed, here's a good link:
<http://stackoverflow.com/questions/2454281> ("Since we can't abstract over
the variance annotation (yet ;-)) in GenericTraversableTemplate, so that we
could have instantiated it to either one depending on the subclass, we have to
resort to casting (@uncheckVariance is essentially a kind-cast). ")

~~~
punditator
If it is truly the correct tradeoff, then why are they trying so hard to sweep
it under the rug? It smacks of intellectual dishonesty.

~~~
viraptor
Is it really sweeping under the rug? Not only the author of the bitrot paper
himself answered the question on stackoverflow by pointing out the problems,
he also gave the impression that they're working on eliminating the
limitation: "can't abstract over the variance annotation (yet ;-))"

Scala mailing lists are open to everyone ;)

