www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Design Patterns in Dynamically-Typed Languages

reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
There's been quite some discussion lately about dynamically-typed 
languages et al. Here's a pretty good and easy-to-follow presentation by 
Peter Norvig (AI guru among other gurusdoms he owns) on how 
dynamically-typed languages make implementation of various design 
patterns considerably easier:

http://norvig.com/design-patterns/


Andrei
Apr 21 2009
next sibling parent bearophile <bearophileHUGS lycos.com> writes:
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
Apr 21 2009
prev sibling next sibling parent "Nick Sabalausky" <a a.a> writes:
"Andrei Alexandrescu" <SeeWebsiteForEmail erdani.org> wrote in message 
news:gskusq$2bd9$1 digitalmars.com...
 There's been quite some discussion lately about dynamically-typed 
 languages et al. Here's a pretty good and easy-to-follow presentation by 
 Peter Norvig (AI guru among other gurusdoms he owns) on how 
 dynamically-typed languages make implementation of various design patterns 
 considerably easier:

 http://norvig.com/design-patterns/
Not to be a curmudgeon, but I don't think that brings to the table anything about dynamic languages that hasn't already been discussed to death in the static vs dynamic war. Dynamic languages are already well known for having less boilerplate. And according to static-language people, that comes at the cost of increased difficulty in bug prevention/detection. The observations in that presentation seem to be purely symptomatic of that well-knon fact about dynamic languages and not only glosses over the potential downsides but also falls into the common failing of attributing certain things to being inherently "dynamic-language" despite D containing proof to the contrary.
Apr 21 2009
prev sibling parent Michel Fortin <michel.fortin michelf.com> writes:
On 2009-04-21 13:14:07 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail erdani.org> said:

 There's been quite some discussion lately about dynamically-typed 
 languages et al. Here's a pretty good and easy-to-follow presentation 
 by Peter Norvig (AI guru among other gurusdoms he owns) on how 
 dynamically-typed languages make implementation of various design 
 patterns considerably easier:
 
 http://norvig.com/design-patterns/
I love that sentence: "Long ago, a subroutine call was just a pattern" followed by some assembler code equivalent to a function call. Somewhere in there it says that in a dynamic language types and classes are objects available at runtime, which means you can put types into variables. That's very true in Objective-C (where classes are themselves objects). We're almost there in D: ClassInfo represents a class, TypeInfo a type, but what we can do with them currently is of limited utility. They're also distinct entities from the compile-time type concept. Allowing automatic unboxing of compile-time types to TypeInfo/ClassInfo, and adding runtime-reflection equivalent to what is available through compile-time reflection) would help drastically at using D as a dynamic language. -- Michel Fortin michel.fortin michelf.com http://michelf.com/
Apr 22 2009