O'Reilly logo

Functional Programming: A PragPub Anthology by Michael Swaine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

What About Debugging and Performance?

From the debugging point of view, functional style is a winner. Since there are no mutable states, there are fewer opportunities for errors than in code with several mutable parts. We can write unit tests on each of the intermediate steps separately and also on the collective results. We can step through the code individually or collectively. We can also store the intermediate values in immutable vals along the way so we can examine those.

But what about performance? Surely immutability comes at a cost of performance? Well, if the collection is fairly small, we won’t see any significant performance impact, but if the collection is fairly large, we may indeed face some copy overhead, but don’t assume. Languages ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required