TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Isn't functional programming space inefficient?

2 pointsby optbuildabout 2 years ago
Yes, mutation is bad as it gives rise to untraceable bugs that are sometimes hard to track. Yes, FP is more mathematical, easy to reason, parallel friendly.<p>But what about space. When dealing with large objects, functions have to copy them and process them and sometimes even produce large objects that are slightly modified than the input object. Doesn&#x27;t this require lot of space?<p>Are we just wasting resources because memory is cheap now?

2 comments

nikonyrhabout 2 years ago
There is no need to copy them, you can just kind of &quot;store the delta&quot; and re-use the unchanged part. Checkout immutable &#x2F; persistent data-structures, they are quite fascinating.
ggeorgovassilisabout 2 years ago
&gt; functions have to copy them<p>I&#x27;m not an FP expert, but I understand that objects usually are immutable, which means functions don&#x27;t change them, which means that there is no need to copy them. Even if there are changes, unchanged properties would point to the respective properties of the old object, minimising memory footpint.