Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> This lack of laziness (even on code that does notionally work without it) manifests in blowing stacks, in Scala at least.

Please don't spread FUD.

The std. lib functions in Scala are stack safe. (Simple, fast while loops under the hood when it comes to collections).

To pick up the `zip` example:

  val r = (1 to 100_000_000).zip(1 to 100_000_000)
won't blow up with a stack overflow.

https://scastie.scala-lang.org/a4v5w1bKTeadQaPtK9CC5A

Also custom recursive functions can be made safe (for example by using trampolining).

You blow stack in Scala only when you explicitly ask for it by writing unsafe code. (Which is BTW something that applies to more or less all languages as almost nobody ever repeated the mistake to build a lazy by default language).

https://news.ycombinator.com/item?id=1924061



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

Search: