TITLE: The Pareto Principle and Programming Purity AUTHOR: Eugene Wallingford DATE: October 02, 2012 4:14 PM DESC: ----- BODY: After talking about the advantages of making the changeable aspects of the system as declarative as possible, William Payne writes:
Having done a bit of Prolog programming in the dim and distant past, my intuition is that trying to make everything declarative is a mistake; one ends up tying oneself into knots. The mental gymnastics simply are not worth it. However, splitting the program into declarative-and-non-declarative parts seems reasonable.
This is an application of the Pareto Principle to programming, in the form of the purity of style. The Pareto Principle says that, "for many events, roughly 80% of the effects come from 20% of the causes". When I was first learning functional programming in Lisp as an AI researcher, a more experienced researcher told me that about 90% of a big system could be purely functional. The remaining 10% should include all side-effecting operations, cordoned off from the rest of the app into its own abstraction layer. Since that time, I've heard 85-15 used as a reasonable split for big Scheme programs. The lesson is: don't kill yourself trying to be 100%. As Payne says, the mental gymnastics simply are not worth it. You'll end up with code that easier to understand, maintain, and modify if you allow yourself a little impurity, in small, controlled doses. -----