Boost logo

Boost Users :

From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-11-02 16:01:18


"David Abrahams" <dave_at_[hidden]> wrote
> "Arkadiy Vertleyb" <vertleyb_at_[hidden]> writes:
>> Well, it's all about approach to the problem. You present
>> metaprogramming as a systematic discipline. Andrei presents it as a
>> number of tricks. You define metafunction. Andrei just shows how
>> to select between types and implement typelist. For some people
>> your approach may be more natural, but I personaly prefer his as far
>> as the introduction to the subject is concerned. Once I get a good
>> feel of what can be done, and why, then I am ready to talk about
>> systematic approach.
>
> Hmm. Bottom-up vs. top-down is always a tension, and people have
> different learning styles that are more amenable to one or the other.

Yes.

> We do try to show some simple low-level examples right in the first
> chapter (e.g. binary). Admittedly, that's not as useful an example as
> some of the things Andrei does with low-level code, but then it's also
> a *lot* simpler. We then continue with an actual, useful example of
> low-level type selection using specialization in chapter 2. Although
> we introduce the general idea of a "metafunction" in the beginning of
> chapter 2, we don't really try to define it until long after that
> example is complete.
>
> I am not arguing with you; I just want to learn how to serve my
> readers better, and so far it doesn't make sense to me. What you seem
> to be saying, by analogy, is that you'd want to see a whole book's
> worth of material on OO programming in 'C' in order to understand why
> the OO paradigm is useful, before reading about how to do it in C++
> with real classes.

Well, I think the main reason I liked OO right away was that, by the moment
I was reading my first C++ book, I've already had implemented something like
virtual functions in Foxbase :-)

I think, in order to appreciate something, one has to be ready for it. To
appreciate STL one has to have basic understanding of what is involved in
writing linked list by hand. To appreciate MPL one has to understand how to
write typelist and what is involved in traversing it.

I am not saying one has to understand everything down to the registers. But
at least one level down wouldn't hurt.

>> Another thing that IMO doesn't help understanding of the material,
>> either in the book or in the MPL docs, is the extensive usage of
>> lambda. IMO it just adds extra magic to the examples, making one
>> feel that he doesn't really understand how things work. I think
>> examples with regular metafunction objects would be much easier to
>> understand, at least initially.
>
> But we _do_ start with "regular metafunction objects." We don't start
> using lambda expressions until after we've shown how to work with
> metafunction classes.

OK, then I have wrong memory about this. Probably related to MPL docs
rather than to the book.

>>> As great a book as "Modern C++ Design" is, it really surprises me
>>> to see it recommended as an introduction to template
>>> metaprogramming over "C++ Template Metaprogramming." MC++D is not
>>> about specifically TMP, and doesn't even attempt to describe what
>>> TMP is. It does contain numerous examples of basic TMP applied to
>>> traditional OO design patterns, which I think is the real point of
>>> that book, and IMO makes MC++D an ideal follow-on to C++TMP.
>>
>> Not really, once I read you book I would like to use MPL, right ;-)
>
> Cute. Yes, it would be nice to see a version of MC++D rewritten to
> use MPL... but then it would be a much shorter book ;-)

Maybe :-) But I would keep chapters 1 - 3 as they are. I do think they
represent a great introduction into TMP.

>> To summarize -- I think your book is great for the intermediate to
>> advanced metaprogrammers, but as far as beginners are conserned, it
>> may not always work. As in the case with the OP.
>
> Granted, it may not always work. I'm still looking for some insight
> as to why not.

Maybe because some people do prefer bottom-up? And then, is it really
possible to write a book that is ideal for everyone?

Regards,
Arkadiy


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net