dynamic classes and duck typing

Bill Baxter wbaxter at gmail.com
Wed Dec 2 15:41:04 PST 2009


On Wed, Dec 2, 2009 at 3:26 PM, BCS <none at anon.com> wrote:
> Hello Sergey,
>
>> BCS wrote:
>>
>>> I'm not arguing on that point. What I'm arguing is that (at least for
>>> me) the primary advantages of metaprogramming are static checks (for
>>> non-perf benefits) and performance. Both of these must be done at
>>> compile time. Runtime metaprogramming just seems pointless *to me.*
>>>
>> One of important applications of metaprogramming is code generation
>> which would be too tedious or bug-prone to generate and support
>> manually.  Dynamic languages can definitely provide for that.
>>
>
> They can, but I question if it's the best way to do it in those languages.
> Generating code and running it at runtime seems to be pointless. Why have
> the intermediate step with the code? I have something I want to do, so I use
> encode it as one abstraction (a DSL), translate it into another (the host
> language) and then compute it in a third (the runtime). If it's all at
> runtime anyway, why not just use the runtime to evaluate/interpret the DSL
> directly.

You may be able to memoize the generated code so you only have to
generate it once per run, but use it many times.
Probably performance is the reason you wouldn't want to reinterpret
the DSL from scratch every use.  Even dynamic language users have
their limits on how long they're willing to wait for something to
finish.

--bb



More information about the Digitalmars-d mailing list