Design Patterns in Dynamically-Typed Languages

bearophile bearophileHUGS at lycos.com
Tue Apr 21 10:43:11 PDT 2009


Andrei Alexandrescu:
> http://norvig.com/design-patterns/

That's a bit old.
This is another old document about this topic, with the Borg pattern too, by another smaller Guru, Alex Martelli:
http://www.aleax.it/Python/5ep.html

The moral of the story is: in Python about half design patterns "vanish", the other half becomes more flexible, or they change.

Python can also be seen as a way to move some design patterns from the idiom-land of the language to the language itself. This has the advantage that such idioms become more natural, syntactic-wise too.

Generally you can't remove complexity from a system, you can only move it elsewhere. Python and dynamic languages allow you to move some of such complexity into the language itself, this is often positive, but this may produce a slower interpreter/VM/language.

The disadvantage is that you often have to pay such increased flexibility with a lower running speed. And the running speed is *power*, because it allows you to implement (if/where you want) the flexibility you want (but you have to pay an increased program complexity).

Later JustInTime compilers come, and they change the situation a bit again (see Psyco, ShedSkin, PyPy JIT, and even http://code.google.com/p/unladen-swallow/ ).

Bye,
bearophile



More information about the Digitalmars-d mailing list