4 ms·
For sufficiently complex & performant functional code you need to have immutable data structures. Clojurescript has this built into the core data types by defau
by drcode 10y ago
For sufficiently complex & performant functional code you need to have immutable data structures. Clojurescript has this built into the core data types by default, in Javascript you need to use an immutable type library, but then you have to do a lot of awkward data marshalling into the immutable types that really hampers the experience.
- tdb7893 10y agoThis 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.