Design Patterns in Dynamic Programming
Via reddit (great site if you suffer attention defecit): Design Patterns in Dynamic Programming by Peter Norvig (Director Research at Google).
In slide form it’s somewhat tricky to extract anything more than the gist of what’s being said but there’s some really interesting stuff here. It’s perhaps easiest to understand in context of this old but (unusually) insightful post on /.;
The dirty unacknowledged secret of design patterns is that they’re strongly coupled to a language. For example, switching from a statically typed language like Java to a dynamic one with forwarding substantially changes the approach to Factory, Proxy, Singleton, Observer and others. In fact, they’re often rendered trivial.
This is the first serious attempt I’ve seen to identify patterns specific to dynamic languages and found myself nodding. For example Partial Evaluation [slide 1] and slide 2;
Intent: Write literate code, compile to efficient code
A prime example of that in PHP would be WACT’s template components which turn declarative template tags into “runtime” PHP spaghetti (that you don’t need to care about). Believe this is also a big selling point in Rails, which has made good use of Ruby’s macro capabilies for stuff like defining object relationships in active records – by way of comparison there, perhaps the closest PHP can get to that is illustrated by EZPDO, which has you place those statements in PHP comments alongside your code, which EZPDO extracts.