Rich Hickey's slides from jvm lang summit - worth a read?

bearophile bearophileHUGS at lycos.com
Thu Sep 24 15:00:56 PDT 2009


Walter Bright:

> Executive summary: pure functions and immutable data structures help 
> manage program complexity.

There's something missing in most of the articles I've read that praise pure functions and immutable data structures. When I write a 500-lines long Python program I often start using almost pure data structures and pure functions, they help me avoid bugs and keep things tidy. Then if the performance is good enough I may stop (I add more tests, docs, etc).

If the performance isn't good enough I often profile the code and (beside trying to improve algorithms and data structures, catching and pre-processing, etc), I also sometimes reduce the purity of some performance critical functions/methods and change the code in some spots so it modifies some big data structures in place, to avoid repeated allocations and reduce GC activity. This speeds up the code.

I'd like a language that helps me perform such changes from almost purity to a code that in certain spots is less functional/pure. I'd like such language to give me quick ways to go back to a more pure code, to help me modify/debug the code further, because during program design or during debugging purity/immutability help. But once I have optimized my Python code, I have lost some of such simplicity, and it requires work if you want to go back to a more pure code to perform more debugging/code improvements. I think such ideas may be applied to D programs too.

Bye,
bearophile



More information about the Digitalmars-d mailing list