By villane
via villane.wordpress.com
Published: Feb 07 2008 / 10:07
Scala's for expressions are much more powerful than while loops or Java 5's for each, but iterating over Ranges can be quite slow in the current release version of Scala. Part of this seems to be caused by a performance blooper in Range that is already fixed for the next release, though. But the other part is that for expressions get converted into much more powerful functional constructs, whereas the imperative while is implemented as efficient byte-code that is very similar to the Java equivalent. At the end is an example of how for expressions make XML processing in Scala really simple.



Comments
obzen replied ago:
Thanks for these performance insights! Keep 'em coming.
Voters For This Link (8)
Voters Against This Link (0)