Live data from Hacker News

The Rook's Guide to C++

rooksguide.org

11–20 of 33 posts

Re: The Rook's Guide to C++

#11
post #6

C++ is a programming language that is used in modern applications primarily for low level tasks like hardware interaction/embedded, games etc. This involves much dedication while learning, and a proper coverage of computer architecture aspects. This is why I do not see much point in learning C++ in a "For Rookies" way "in 21 days". If you want to be a C++ programmer, go find a good introductory C book which properly…

That is really bad advice. C style memory management is useless in the presence of exceptions, and a nightmare to get right even in C. Choose a book that teaches RAII from the beginning, and leaves C style memory management to a late, advanced chapter. Accelerated C++ used to be that book, don't know if there is a newer and better replacement.

I agree that in modern C++ you need to avoid all the bare-C ways. Actually, my C++ is almost C# if you look at it, especially with the new c++11 standard.

But I still believe that to learn C++ the best way is to start with C, pointer arithmetic, and classic strings. Otherwise you will just miss the point and join the hordes of script kiddies who "once started C++".

Re: The Rook's Guide to C++

#12
post #2

Anyone know the background. Is it worth a read compared to more traditional books, like Stroustrup's book?

not sure. It has some good basic introduction, mainly to syntax, but (imo) leaves out and even goes against quite some good prcatices. If it would include that, instead of just laying out dry theory, it could be pretty good (eg I especially like the C++ FAQ Lite way of explaining why and not just how).

For instance there's a very small chapter on const saying it declares a variable you cannot change. A novice will just read it and forget it. It should (again, imo) say "use const for everything possible" and explain why that is.

Likewise, the strnig chapter starts with saying "use code like using namespace std; string blabla; or you can also use std::string" and leaves it like that without further explanation. A novice might read that, think the first one is less effort and just continue using it. It would be better to make clear the second one has some advantages.

I could go on like that (all loops using post-increment, chapter on array while vector is only covered in the last chapter, chapter on pointers but references are mentioned nowhere, really??, new/delete but no smart pointers anywhere, templates, lamdas or most C++11 features for that matter, ...) but of course there's always a line between introductionary and deeper knwoledge and it's not entirley clear to me where the authors wanted to draw the line. Also there's a lot to tell about C++ of course. Yet, we're in 2013, close to C++14, and C++ has evolved a lot. Large parts of modern C++ programs look nowhere close to what is presented in this book.

Re: The Rook's Guide to C++

#13

Well I just skimmed the book but it seems to be incomplete. Even though it is referring to C++11 it is not talking about language features like: - lambdas - Templates (it's referring to the STL at the end though) Which since this is a contribution based book is not a bad thing. However this book still needs quite some work. Writing a C++ book is not easy. From all the C++ books I know there's less than a handful whic…

Which books could you personally recommend? I am still searching for a book which gives good advice for trickier problems.

On "GoingNative" Alexandrescu's "C++ Coding Standards: 101 Rules, Guidelines, and Best Practices" was touted as being written out of the real feed-back in the industry. It might be that "good advice for trickier problems", although it isn't a "guide" into C++ (as it assumes you already have a great deal of knowledge and expertise).

Re: The Rook's Guide to C++

#14
I have found a mistake: In table 9.1 of chapter 9 "Data types and Conversion" you wrote that the char data type ranges from -128 to 127, but that's not true, because the standard doesn't say that a char is signed or unsigned, it depends on the implementation. A char can be an unsigned char and in that case it will range from 0 to 255.

Re: The Rook's Guide to C++

#15

Earlier quoted context omitted.

Which books could you personally recommend? I am still searching for a book which gives good advice for trickier problems.

Well it depends on where you stand. For beginners a very good book from my experience is C++ Primer by Stanley B. Lippman, Josée LaJoie, Barbara E. Moo. The 5th edition even goes into the newer topics like the aforementioned lambdas, also variadic templates. A nice thing is that it comes with exercises, which in my particular case was how I learned programming. I found a new feature of the language, or a class new to…

The C++ Standard Library: A Tutorial and Reference

This is a book on STL (updated for C++ 11) is a classic, and actually very readable. Quite a lot for advanced users, but also not too dry!

http://www.amazon.co.uk/gp/product/0321623215/ref=pd_lpo_sbs...

I'd also recommend Zed Shaw's C The Hard Way, because although C++ is not C, getting good at C helps you understand C++ when it goes wrong.

Re: The Rook's Guide to C++

#16
post #15

Earlier quoted context omitted.

Well it depends on where you stand. For beginners a very good book from my experience is C++ Primer by Stanley B. Lippman, Josée LaJoie, Barbara E. Moo. The 5th edition even goes into the newer topics like the aforementioned lambdas, also variadic templates. A nice thing is that it comes with exercises, which in my particular case was how I learned programming. I found a new feature of the language, or a class new to…

The C++ Standard Library: A Tutorial and Reference This is a book on STL (updated for C++ 11) is a classic, and actually very readable. Quite a lot for advanced users, but also not too dry! http://www.amazon.co.uk/gp/product/0321623215/ref=pd_lpo_sbs... I'd also recommend Zed Shaw's C The Hard Way, because although C++ is not C, getting good at C helps you understand C++ when it goes wrong.

True, The C++ Standard Library is a very good book as well

Re: The Rook's Guide to C++

#17
Hmmmm. why do you teach arrays before containers? And why is so little if any time spent on the std:: containers (ctrl + f deque returns nothing).

The word template is mentioned 3 times, and never once on how to write your own basic templates (no, that's should not be considered advanced).

Finally, why do you keep using the `.open` member function for your streams rather than specifying the file path in the constructor and then testing the validity of the whole stream rather than individual flags.

ie:

    std::ofstream ofs { "my_file" };
    if(ofs) { ///sucess...
You also don't even begin to touch on the standard algorithms. Take for example the book "Accelerated C++". It's only 300 pages, but it has the reader writing modern code with containers and standard algorithms with in the first few pages. It's a much better approach in my opinion.

Re: The Rook's Guide to C++

#18

Earlier quoted context omitted.

Which books could you personally recommend? I am still searching for a book which gives good advice for trickier problems.

Well it depends on where you stand. For beginners a very good book from my experience is C++ Primer by Stanley B. Lippman, Josée LaJoie, Barbara E. Moo. The 5th edition even goes into the newer topics like the aforementioned lambdas, also variadic templates. A nice thing is that it comes with exercises, which in my particular case was how I learned programming. I found a new feature of the language, or a class new to…

Thanks for the list, I am going to check them out!

Re: The Rook's Guide to C++

#19
post #14

I have found a mistake: In table 9.1 of chapter 9 "Data types and Conversion" you wrote that the char data type ranges from -128 to 127, but that's not true, because the standard doesn't say that a char is signed or unsigned, it depends on the implementation. A char can be an unsigned char and in that case it will range from 0 to 255.

Thanks, I'll add it to the tracker.

Re: The Rook's Guide to C++

#20
post #7

Holy crap i know a lot more c++ then i thought i did.

My exact feelings, I did c++ in high school with some ancient borland c++ compiler. I always felt I don't know enough of c++ whenever I happen to go through some modern c++ source code. I just realized that is just the STL.
Post reply on HN