dynamic classes and duck typing

Don nospam at nospam.com
Wed Dec 2 13:20:22 PST 2009


Leandro Lucarella wrote:
> BCS, el  2 de diciembre a las 17:37 me escribiste:
>> Hello Leandro,
>>
>>
>>> If you say dynamic languages don't have metaprogramming capabilities,
>>> you just don't have any idea of what a dynamic language really is.
>>>
>> If you say you can do metaprogramming at runtime you just don't have
>> any idea of what I want to do with metaprogramming. For example:
> 
> What you say next, is not metaprogramming per se, they are performance
> issues (that you resolve using compile-time metaprogramming). 

They are metaprogramming tasks. Dynamic languages can do some 
metaprogramming tasks. They can't do those ones.

> You are right, but if you *don't* need *speed*, you don't need all that
> stuff, that's not metaprogramming to fix a "logic" problem, they are all
> optimization tricks, if you don't need speed, you don't need optimization
> tricks.

"you don't need speed" is a pretty glib statement. I think the reality 
is that you don't care about constant factors in speed, even if they are 
large (say 200 times slower is OK). But bubble-sort is probably still 
not acceptable.
Metaprogramming can be used to reduce big-O complexity rather than just 
constant-factor improvement. Lumping that in with "optimisation" is 
highly misleading.

> The kind of metaprogramming I'm talking about is, for example, generating
> boring, repetitive boilerplate code.



More information about the Digitalmars-d mailing list