
Why is my Scala code running slow? - swah
http://stackoverflow.com/questions/6146182/why-is-my-scala-code-running-slow
======
mike_esspe
Never use in Scala

    
    
      for (x <- Y to Z) 
    

if you need performance. It is doing not what you think :) Use while for
optimization.

~~~
podperson
This is like a booby trap in a language. Presumably it can be solved with
optimization in the compiler at some point (according to the thread, turning
on optimizations improved performance somewhat, but replacing for with while
made performance identical to Java).

Personally, I don't like languages to have a whole bunch of slightly different
iterators for specialized purposes, but having for turn out to be dramatically
different from while performance-wise violates the principle of least
surprise.

