Hacker News new | past | comments | ask | show | jobs | submit login
Why is my Scala code running slow? (stackoverflow.com)
27 points by swah on June 16, 2011 | hide | past | favorite | 2 comments



Never use in Scala

  for (x <- Y to Z) 
if you need performance. It is doing not what you think :) Use while for optimization.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: