Hacker News new | ask | show | jobs
by skybrian 1544 days ago
This article explains the problems pretty well, but they are old problems and functional programmers have various solutions that the author seems unaware of.

I'm not a Haskell programmer but I do know about monads and have heard of lenses.

1 comments

Lenses don't help. They just make copying and updating large data structures cleaner to write. They don't solve the performance problem of copying everything.
Incorrect. Optics implementations can ensure updating a node in a large balanced tree is O(log n) instead of O(n), trivially, and I'm sure there are sufficiently clever collections with optics that would enable much better performance than the trivial optimizations I can think of.

The same holds true for large structure updates.

Not all data structures are a large balanced tree and a O(1) update is going to be faster than O(log n) updates. There is still going to be a significant performance hit from having to recreate a whole node instead of just updating a single value. While yes you can say large data structures are like a big node of a tree, having to copy all of the different records from the old one to a new one is going to be considerably slower than just modifying a single record.

It does help, but it's still going to be significantly slower than just modifying a single record in a data structure. It is a still a problem that will be slowing down your program.