2 ms·
This might be off topic but why does functional code specifically need immutability? I'm familiar with the benefits of immutability in general (actually one of
by tdb7893 10y ago
This might be off topic but why does functional code specifically need immutability? I'm familiar with the benefits of immutability in general (actually one of the best code bases I've ever seen was written in Java with mostly immutable object) but I'm not clear about the specifics of functional programming that makes it fit particularly well
- drcode 10y agoA function has the structure INPUT -> FUNCTION -> OUTPUT. Let's say you're adding a widget to the database: (DATABASE,NEW_WIDGET) -> FUNCTION -> (NEW_DATABASE) The only efficient way to return a brand new database that is the same as the old database plus 1 new widget is via immutable data structures.