Hacker News new | ask | show | jobs
by js8 1202 days ago
I agree, it would be nice to have a refactoring workflow that every program modification only creates new functions, never changes existing ones. Then we could get automated testing of new functions against old functions, or even, automated proof that the change doesn't affect the result.
1 comments

Purely-functional data structures are known for quite some time [1]. I can imagine that the very same approaches can be used to organize functions (the whole interdependency graphs of them), so that an update produces a new version with relevant parts changed, while the previous version remains there, completely unchanged. An IDE, or some other language tool, can fully automate the necessary legwork.

(It will of course also take some garbage collection mechanism to eventually remove old, disused versions when nobody depends on them any more.)

[1]: https://en.wikipedia.org/wiki/Purely_functional_data_structu...

Unison does this. Every function is identified by a hash of its content, so if the content changes, so does its hash. You can have multiple versions of the same function in the same project without any trouble, because there is never any ambiguity.