Wed, 02 Dec 2009 16:00:50 -0800, Andrei Alexandrescu wrote: > retard wrote: >> Wed, 02 Dec 2009 21:16:28 +0000, BCS wrote: >> >>> Hello Leandro, >> >>>> Again *optimization*. How many times should I say that I agree that D >>>> is better than almost every dynamic languages if you need speed? >>> 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.* >> >> Both the language used to represent D metaprograms and D are suboptimal >> for many kinds of DSLs. A dynamic language can provide better control >> over these issues without resorting to manual string parsing. If the >> DSL is closer to the problem domain, it can have a great effect on >> program correctness. >> >> For instance, you could define natural language like statements in your >> DSL with functional composition. In D you basically have to write all >> metaprograms inside strings and parse them with CTFE functions. In e.g. >> lisp or io the DSL is on the same abstraction level as the main >> language. These are of course slow, but in some environments you need >> to be able to provide non-developers an intuitive interface for writing >> business logic. Even the runtime metaprogramming system can provide >> optimizations after the DSL has been processed. >> >> I understand your logic. It's very simple. You use metaprogramming to >> improve performance. > > Static dimensional analysis doesn't improve performance, and I recall he > mentioned that.
Why not? I agree it does also static checking of type compatibility, but when done at runtime, computing the associated runtime type tag and comparing them also requires cpu cycles. If the analysis is done at compile time, the computational problem degenerates to operations on scalars and types can be erased on runtime if they are not used for anything else.