Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
288 views
in Technique[技术] by (71.8m points)

Does functional programming take up more memory?

Warning! possibly a very dumb question

Does functional programming eat up more memory than procedural programming? I mean ... if your objects(data structures whatever) are all imutable. Don't you end up having more object in the memory at a given time.

Doesn't this eat up more memory?

question from:https://stackoverflow.com/questions/4522304/does-functional-programming-take-up-more-memory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It depends on what you're doing. With functional programming you don't have to create defensive copies, so for certain problems it can end up using less memory.

Many functional programming languages also have good support for laziness, which can further reduce memory usage as you don't create objects until you actually use them. This is arguably something that's only correlated with functional programming rather than a direct cause, however.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...