Wrapping Up

Recursions provide a nice, intuitive, and expressive solution to many problems. However, programmers often either avoid recursions or are rather reluctant to use them because of the issue with stack overflow for large input values. The Scala compiler has built-in support to optimize recursions that are at the tail position into iterations, so you can avoid this problem. This optimization allows us to more liberally use recursions where it makes sense, without the worry of blowing out stacks. You also saw the Scala library support for working easily with trampoline recursions. Between these two solutions, solving critical algorithms and problems becomes a matter of writing just a few lines of code with fewer concerns to worry about.

Talking about critical algorithms and problems, we will look next at how Scala’s support for concurrency can make code execution faster and more responsive.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.3.154