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 ...

Get Functional Programming: A PragPub Anthology now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.