Small, Fast, & Simple

February 2, 2015

Functions

Small
Fast
Simple

I’ve come to prefer first-class and higher-order functions with closures in place of classes and objects. Nothing will stop you from writing large functions, but you’ll face more resistence than you will writing large classes. The interface for a function is well-defined and battle-tested: values are passed in, values are available from the enclosing scope, and a value is returned. By contrast, every class in an object-oriented system tends toward being a snowflake whose interface has to be studied each and every time. Many common OOP design patterns can be replaced by functions.