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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access