Daily downloads in decline
QAston via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jun 11 15:30:21 PDT 2015
On Thursday, 11 June 2015 at 15:08:48 UTC, Dicebot wrote:
> My experience of explaining those concepts to other people
> indicates otherwise. D templates and mixins are dirty but also
> very simple concepts that pretty much any new programmers gets
> quickly and intuitively, learning how to do more complicated
> magic in a small steps. Macros are just never really simple as
> they operate within AST domain and programmers not familiar
> with language developer tend to be more confortable with
> thinking on the source code level. It is a more robust power
> tool for experienced developers but that does not feel like a
> good justification.
I bet you don't show ranges implementation to those people, or
they don't write new ones. Yes - predicates are simple and
powerful combined with conditional compilation and there's even a
certain elegance to that. But proper usage, for example to
implement a custom range or a wrapper, is difficult as seen here
on forums. Still - it's way way easier than in C++.
In the end D has much more powerful compile-time capabilities
(except encapsulating and manipulating syntax because of no
macros; D can only encapsulate declarations). The price paid for
those is in possible tooling. No analysis can be done on an
arbitrary predicate to suggest you how to match it. With simple
(not turing complete) macros and templates that's easy to do.
It's a tradeoff, pick what you like.
Rust's macros may feel difficult to undestrand exactly because
they're limited and therfore can't use regular runtime APIs.
There're macro systems which allow arbitrary functions creating
ASTs - Lisp is an example. Yes - Lisps had ctfe before it was
cool. Just like you glue strings in D using runtime API, you glue
lists in Lisp using runtime API. It has the same consequences:
Lisp macros can't really be checked without runtime in the
background running the macros and there're no suggestions
available for their usage.
More information about the Digitalmars-d
mailing list