On 19/09/2006, at 6:34 PM, Erik de Castro Lopo wrote:

I also suspect that the flexibilty you see in Perl/Python/Ruby
has little to do with dynamic typing and has much more to do with
Perl/Python/Ruby being high level languages in comparision to
the statically typed languages you know like C/C++/Java.

Yeah, I think the power you get from Perl/Python/Ruby is actually due to two language runtime features that are totally orthogonal to dynamic typing:

  1.  A rich reflection/introspection API[1], and
2. Forwarding a method call on a non-existent method name on to a method[2].

The two features, combined, grants huge power, and I these two features are what's missing from the mainstream languages. As an example, I think all of Rails's really cool features (e.g. active records) rely heavily on both these features. If you stripped out Perl/Python/Ruby's method forwarding facilities and their reflection API, what you have is a pretty boring language indeed.

You can do both of these things in a statically typed environment; it's just that the static type camp hasn't seem to have acknowledged how useful these facilities are for making long-lived, extensible programs. Java is the only language I know off the top of my head that is statically typed and has a reflection API, but it still doesn't let you have feature (2) above, and its reflection API is cumbersome to use. C++ has Run-Time Type Information (RTTI), but that's so featureless that it's practically useless. I'd love to see a language with a static type system as powerful and useful as Haskell's with a reflection API that's as powerful as Perl/Python/Ruby.

1. Reflection/introspection means that you can get information about a class or method at runtime: you can find out what method names are implemented by the class, what their types are, call them, etc. Highly dynamic languages will let you add new methods, replace a class's method implementations with your own implementation, etc.

2. e.g. Objective-C has a method named forwardInvocation that gets called if you invoke a non-existent method on an object; forwardInvocation can then do what it likes with the method call, such as pass the method call on to another object.


--
% Andre Pang : trust.in.love.to.save  <http://www.algorithm.com.au/>



_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders

Reply via email to