( split from C++ Book recommendations thread and merged with ChaosEngine's response/discussion thread ~ Ken Fitlike )
I'm not really sure you need an entire book about how to use templates.
Printable View
( split from C++ Book recommendations thread and merged with ChaosEngine's response/discussion thread ~ Ken Fitlike )
I'm not really sure you need an entire book about how to use templates.
>> I'm not really sure you need an entire book about how to use templates.
If you want to use them (and C++) well, then both of those "entire" books would be good choices.
I think that a chapter in a larger good book is fine. Note that I am not talking about the STL, but rather the implementation of the template language feature.
This isn't exactly the place to discuss this, but are you familiar with what is contained in those books? I'm guessing that you are not and that you just don't realize the types of advanced programming techniques that are available through templates. If you consider yourself ready for advanced C++ programming, and you haven't read them already, consider buying or borrowing those books, or even reading through them in a bookstore.
No, I've read (and own) one. I don't happen to think you need an entire book to explain the topic. Some might, and I respect that. I think that you don't. Perosnal opinion, take it or leave it. I feel that a good chapter in a good book, combined with some research online, is sufficient. I felt that my money could have been better spent. That being said, there are those who can only learn through a real book, and if that is true, by all means, buy a book. If not, like me, skip it.
in this post I recommended some books.
manutd disagreed and I think this is an interesting discussion but I don't want to hijack the book thread (which IMHO is a good resource), hence this thread.
First, which book do you own? I'm assuming it's the Vandevoorde/Josuttis Template book since that's what you seem to be focusing on.Quote:
Originally Posted by manutd
Personally, I think templates are one of the largest and most complex areas of C++ and easily merit their own book (template meta-programming on it's own merits a book!). I'm curious as to exactly how much coding you've done with templates. If it's limited to a few template classes/functions, then yes a book is overkill, but once you get into policy-based design, tmp and all the rules regarding partial specialisation, I've found that book to be a very valuable resource that has some info not available on the web. for instance, do you know off the top of your head the formal ordering rules for template matching? If you do, you're a smarter man than I.
Yes, that's the one. I've done a lot of coding with templates, hence why I own the book. But for the number of times I actually need a reference on the formal ordering rules for template matching, I don't really think its worth the money.
I think it depends on what you want to do with templates
If you want to do what they are intended for then sure a few chapters in a book is enough about how to use templates, make your own templates and make template functions. And hmm, maybe a big chapter on how STL is designed although that needs its own book IMO.
But if you get into heavy template metaprogramming there seems to be no end with what you can do. Then sure, this can fill up a few books easily.
I bought the book of the guy who made the Loki library once, cant remember the name. That book was where I draw the line with what I wanted to know in C++. I really had the feeling in that book that C++ had become an academic toy for people who dont really want to make real programs but just wanna find out what stuff you can do with templates.
But the point still stands, you can do a lot with templates that the designers of C++ never thought of when they added templates to the language. Can fill up lots of books, but you dont need that knowledge to make real C++ programs
As I said, I'm not talking about the STL. That easily requires a book (or two). I feel that a C++ programmer only needs a chapter or two in a larger book, and if any additional features are needed, some research on the internet in order to use templates.
Are you including template meta-programming in that statement?
Yes. Remember, I have the book and have compared the information there to that available online, and I feel the amount of information available only in a book is not worth the money.
I thought you had the Vandevoorde book. I am not familiar with its contents, but the template meta-programming code and examples in Alexandrescu's book could not be covered by a chapter or two. That's what I was referring to.
Manutd, really take the advise already given to heart. Template based techniques are vast, powerful, and not always apparent from someone outside the loop. To think that templates can be fully covered by a chapter or two is to miss the point of template based programming.
Don't forget that C++ templates alone are responsible for an entire new programming paradigm.
Aiih! I have the book. I've read it and don't happen to agree with the neccesity of a whole book, given the information available on the internet.
???
But... then you surely don't agree with any book in C++!
>> I have the book.
Which book do you have? You said you had one of the books. Later you said it was the Vandevoorde book. I am talking about the Alexandrescu book. Unless you were mistaken earlier in the thread, my point still stands and applies to that book specifically.
I have the Vandevoorde book. My mistake, I didn't understand which book you were talking about. As I have been saying, using a book that covers template programming in a couple of chapters and the use of the Internet should be fine. However, as I also said, it is dependent on your situation. Some will need a book. I didn't, and so I put my opinion out there to tell those so that they had an opinion. Having seen both sides of this, I personaly don't think you need to plunk down $60 odd bucks on a book.
$40 and some, actually. Your opinion is worth what it is worth.
I have both books. Josuttis & Vandevoorde and Alexandrescu's. Saying that C++ Templates: The Complete Guide is not a book worth its money is really missing the point of the book. It's looking at the book and not understanding one word of what it is written there.
> As I have been saying, using a book that covers template programming in a couple of chapters and the use of the Internet should be fine
Right. So is the STL, and OOP and C++ for that matter!
Try looking for metaprogramming in the web. I'm interested in your findings and the amount of time you spend clearing all the clutter, dealing with all the misinformation and errors, and finally come up with real, useful information on what it is and how you do it.
> However, as I also said, it is dependent on your situation. Some will need a book. I didn't
If you didn't need a book about C++ templates, then you don't know the power of c++ templates. You only think you do. Just so that you know, before the Alexandrescu book, people hardly knew what to do with templates. That book was THE eye opener on the power of template based programming and spurred an whole movement. If this proves something is that just because templates are there, it doesn't mean we fully understand them.
However suit yourself. Just don't please offer your opinion as an advise. Your opinion is wrong.
Well, I liked the Vandevoorde book very much. It contains all the little details (and there's a lot of details) in one handy place. I'm afraid I just don't trust the internet to get all this information straight, and the standard itself is so unreadable ...
Your opinion is that I am wrong. I am not debating that Alexandrescu's book reinvented template programming. But now that it did, much of this information is available on the Internet.
Actually, I did. I also understood what I read on the Internet, much of the smae information. I do have a job in this, you know. I use templates in one way or another every day. And I use the Internet to look up things that I do not remember. I don't get out a book and look in that.Quote:
Originally Posted by Mario F.
WhatI said was that it wasn't worth it to me. I didn't need a book, as I found out after I had bought it and realized that the information was available online. For some, it absolutely is worth the money. I am providing my view for those who may think like me. Do not mistake that for thinking that the book is worthless.Quote:
Originally Posted by Mario F.
My opinion is being offered as advice. That's all it is. Advice. Not an order. From my experience you do not need a book. My experience. What I've experienced is not wrong, it is just different. Notice that I am not calling buying a book a stupid decision, just one I do not think is needed. Stop acting like you know that your opinion is the only one. It's not. Deal.Quote:
Originally Posted by Mario F.
And at CornedBee: DOn't get me wrong, I enjoyed the book. But I've been able to find the same info online and thus think that it is not need in my case. (Notice a theme).
>> Just don't please offer your opinion as an advise. Your opinion is wrong.
First, I disagree that manutd's opinion is wrong. It is an opinion. I disagree with it and happen to think it might be a misinformed opinion, which is why I entered the discussion, but it is a valid opinion nonetheless.
Second, you of all people should not be chastising others for offering incorrect information as advice, and certainly not with such an arrogant tone. At least that's my opinion on the matter.
> you of all people
Great!
Not sure if I understand what that means. But I try my best to offer good advice. If I failed sometimes certainly I did being ignorant of the fact. I do remember though, that I always retract my words on the few ocasions I was called to attention. I don't stick to my opinions (especially when I'm shown I was wrong) like a mantra.
I did appreciate that "of all people" though. It was quiet informative of your opinion.
an opinion can never be wrong, they get formed by certain experiences.Quote:
Originally Posted by Mario F.
I would love to see manut give a typelist example here though :)
It is my opinion then that opinions can be wrong and can be debated.
But that is counter intuitive. By definition, you do not have to agree with me. But it is my opinion and as it is formed by my experiences, do not call it wrong. Also, I haven't been "shown wrong". Others have had different opinions and experiences than I have. Its not a "mantra". It is my belief and, whether you agree or not, you'd do well to be less arrogant and self-assured.
Don't assume I'm being arrogant, because I'm not. I'm talking and defending a point of view different than yours. Self-assured perhaps because I truly believe opinions exist to be discussed and evaluated for their worth. Counter-intuitive is assuming that just because I have an opinion based on my experience I can't be wrong.
Are you that sure you know all there is to know about templates? What will you think when it comes the time you have to apply that knowledge and you find that the non indexed, widely dispersed, and quiet frequently erroneous and non detailed information over the web doesn't allow you to code what you have been asked to?
Are you going to buy a book? Are you coming back here, revitalize this thread and agree that your strategy didn't work after all? Or will you prefer to post the question and silently forget what you said before?
By your own experience, you can easily extrapolate that you don't need books to learn STL, OOP, Threads, or even C++. In a way you are right. The information does in fact exist in the web. My doubt though arises from the fact this information is not organized, neither it is fully correct on all instances, it isn't comprehensive on most cases, and all in all, is a nightmare to collect, organize and become by itself the sole learning tool.
The opinion that you are arrogant could be formed based on the experiences with you in this thread lolQuote:
Originally Posted by Mario F.
You can say that you're not, but that wouldnt make the opinion "wrong"
I still wanna see manut give a typelist example though!
Oh really?Quote:
Originally Posted by Mario F.
Arrogant.Quote:
Originally Posted by Mario F.
Arrogant. Enough?Quote:
Originally Posted by Mario F.
No, that is intuitive. My experience and my job tell me this.Quote:
Originally Posted by Mario F.
No, but this would hardly be possible. Do you know everything?Quote:
Originally Posted by Mario F.
Apparently you can't understand these words: I use templates in my job! The time has come and gone many times!Quote:
Originally Posted by Mario F.
I don't agree. A chapter or two of the basic essentials of meta-programming in a book and then the rest of the small details can be found relatively quickly.Quote:
Originally Posted by Mario F.
I said all I had to say about this.
Agreed. Good debate, but this isn't going to get resolved anytime soon. Each person can have their own opinion(s), so lets leave it there.
but you havent given the typelist example yet :(Quote:
Originally Posted by manutd
You just want a most basic one?
at least an infinite number of types should be possible :)Quote:
Originally Posted by manutd
Yes, but you need to be more specific. Here's one, holding all floating points:Of course there are other ways to do this, but this is one.Code:template <class H, class T>
struct typelist
{
typedef H head;
typedef T tail;
};
class null_typelist {};
typedef typelist<float, typelist<double, typelist<long double, null_typelist> > > fpt;
C++ Templates: The Complete Guide was loaned to me by my boss and... well, when the boss gives you a book you read it. =) I'm still only about halfway done with it though, so
I enjoy reading this book. It comes off a bit like a book of trivia however. Somethings in it (like eclectic uses of the typename keyword) I can imagine using, but in the years I've coded, it hasn't come up. Other features (the use of export w/ respect to templates) will pretty obviously never be in itself, useful information.
So, is the book useless? Yes and no. The book is not meant as a functional education of templates. Also, it's not really better than just reading the standard as a reference. The book is mainly of interest because it discusses obscure template features.
These obscure features are part of the language for the sake of addressing fundamental problems with templates. Reading about these makes you consider the nature of the beast. If you were, say, going to write a language which uses templates, then this would be a very good read because it gives you a perspective of the wisdom and flaws of C++'s templates.
lol indeed I should've been more specific. The article you copy pasted that from is a lot longer though with the get functions and all, but even in this small example you're using lots of template features which need explaining.Quote:
Originally Posted by manutd
a template struct with just 2 typedefs of its template parameters. An empty class as list terminater needs explaining, the recursive template instantiation etc. And the example in the article is just a prerequisite to making VARIANT type unions possible with which you can mix classes and primitive types in a union which is normally not possible.
Also, in modern C++ design he makes way more typelists possible.
And this is just 1 thing you can do with metaprogramming, theres much much more.
Definately can use a few books to have all the information packed in one with a good explanation.
No kidding. I gave one example. I didn't explain, it wasn't a tutorial. And, yes, I copied and pasted, to prove my point that this information is available online.
No in the article the features and why he does that etc arent explained either! If you only use the internet to learn templates, then the article only gets useful if you found the other bits of information about metaprogramming at a random site somewhere else.Quote:
Originally Posted by manutd
but whatever, this thread bores me ^^
I also found a pdf first with no code examples but explanation..I skipped it because I already know how to do this.