Slashdot Mirror


Practical C++

jsight writes with his review of Rob McGregor's Practical C++, published by QUE. He writes "Some books attempt to do one thing really well, and others attempt a little of everything. This book is clearly an example of the latter, in full force. Weighing in at a hefty 900 pages, you would expect this book to be crammed with chapters and details on every aspect of the STL and basic C++. In the following review, I am going to cover where it succeeds in doing this, and where it fails." (This book has been out for a few years; what books would make more sense today for a C++ learner's library?) Practical C++ author Rob McGregor pages 900 publisher QUE rating 7/10 reviewer Jess Sightler ISBN 0789721449 summary Provides a practical guidebook to learning C++ Section I -- Programming 101 At first glance, the book appears to be written for people with experience programming, however reading through this section clearly dispels that myth. Here we have a section which goes over everything from for loops to if conditionals while simultaneously using verbose, duplicitous language at every step. Perhaps this was intended as a means of reinforcement, however, it seems most of the effort here would be wasted.

The technical depth is what you would expect for a novice, but without enough hand-holding and examples to make a novice feel comfortable. Making matters worse, there are numerous typos in this section, including quite a few in the examples (making them uncompilable without corrections). Some of these appear to be type-setting errors, however, there are enough to potentially confuse novice developers.

I believe that the combination of weak examples, and significant typographical errors are strong enough to give a novice much difficulty in learning the C++ language.

Having said that, the section should be provide no difficulty for any programmer with a good knowledge of any vaguely similar language (eg, Perl, Java, PHP, etc).

Section II -- Beyond the Basics

Ah, now we're getting down to Brass Tacks... this section goes over everything from Function overloading to Structure and Unions. The section on function members within structures also does an excellent job of preparing the reader for the upcoming introduction of Object Oriented concepts.

The sections on Memory management, both from an allocation standpoint, and from a bit manipulation standpoint are first-rate. Details are perhaps not as strong as they could have been, however the material is very accessible, and clearly described.

Probably my only complaint with this chapter is the overly general section on compiling and debugging programs. However, as this book does attempt to be somewhat compiler/debugger agnostic, this is forgivable. From here, we dive into the real power of C++, Object Orientation.

Section III

From the beginning, this book treats Objects as an extension of the structure syntax taught previously (with the default of Public switched to Private). This, along with the classic Plans vs. Product description of the difference between a Class and an Object are quite clear and robust.

Again, this is a solid chapter, describing the details of getting a system of classes up and running, as well as some sample data structure implementations.

And then finally, the last section is a slightly less than 200 page description of the STL. This section is probably the book's weakest part, as it is just strong enough to give you a taste of what is available, but often not strong enough to grasp the details. It's a good start, but much more attention should have been made to this subject (potentially even at the cost of some of the wasted words on how a 'for' loop works). It makes a decent introduction for someone with very limited STL background, however, there is not enough depth to reach a strong level of understanding here.

Summary Overall, this is a solid book for an existing programmer to pick up C++ concepts. A programmer with a strong knowledge of an existing procedural language (such as C) would have no trouble digesting the concepts of this book. Having said that, the poor typographical issues, and verbose wording often muddle an otherwise good book.

You can purchase Practical C++ from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

19 of 307 comments (clear)

  1. Re:"Practical C++" by BoomerSooner · · Score: 2, Insightful

    Lol

    cout "Hello World!";

    Thanks for the laugh.

  2. old!=obsolete by RLiegh · · Score: 5, Insightful

    If you're talking about the specifics of a language to the point where the book you're reading is going to be obsolete after the next standards commitee meets--maybe you're reading the wrong book?

    However, if the book you're reading concentrates on the principlas, instead of the individual bits and pieces, age shouldn't matter.

    They still use the ritchie book after all, right?

    1. Re:old!=obsolete by happyfrogcow · · Score: 2, Insightful

      Though if it were written based on compiler implementations of the C++ standard it may be old and obsolete, or at the very least, simply incomplete.

      For example, using exceptions as error handling, and moving it away from the normal operation of the code, instead of having tons of if..else cases everywhere right next to meaningfull algorithms. exceptions seem to be a relatively recent addition to C++ compilers as far as standard compliant compilers go.

  3. C++ had its day by mugnyte · · Score: 4, Insightful


    For many, this C derivative is still a daily living. Thats fine. It's powerful enough.

    These days, most people approach C++ as a way to "write fast code" or they desired to get to a lower level of the machine. Or, they know C and want to learn all about OO programming. NO harm there either, although I question all these motives.

    For the most part though, end-user applications have no need to run in C++. I know the typical exceptions are in gaming, image processing and system internals, but this is a small subset of commercial programming.

    I think elementary programming skills can be taught in C++ (i've done it), but you have to peel away so much of the language, one might as well start from C anyway, and then explain OO, and then combine the two. However, the ancestry of the syntax hangs newbies too often.

    These days, I think the same goals in being "practical" could be achieved with Java for the same (if not less) effort. Plus, one learns the concepts of Events, Interfaces and a more useful standard library.

    I've cranked out over 100K of C++ (haha, not hard to do with low-density langs) but in the end, I wish it would have been a longer-lived system. Many of our framework pieces are now part of the standard Java libraries, and we would have saved quite a bit of time.

    But I think it's time for new programmers to move on.

    1. Re:C++ had its day by Anonymous Coward · · Score: 1, Insightful

      What motives are you questioning, exactly? If I have to write a middleware daemon that has to handle thousands of requests simultaneously, I'm going to pick C/C++ every time. If I have to talk to some other middleware product, there's never a question that they have a C-based api.

      Why is it that everyone is so quick to jump on the "C/C++ is dead" bandwagon and insist that Java/C#/Whatever is the "best" way to go simply because it has more "object-oriented-ness" built into its core than C++ does? As far as C++ goes, it's as object-oriented as you want it to be; don't like multiple inheritance? Don't use it. Don't feel comfortable remembering that you should delete what you new? Fine, make everything either a member or stack-based.

      Only C and C++ offer the most in terms of power and flexibility, but with the unwritten rule that *you* have to take responsibility and decide what is the "right" way to use it; there's no one to hold your hand and what you get in return is a language that gets out of your way and lets you solve the problem, not hold you back because someone else decided you were too stupid to figure it out.

    2. Re:C++ had its day by Brandybuck · · Score: 2, Insightful

      Rule One: The closer you program to the "metal", the closer to the "metal" the language you use needs to be.

      Ever seen a workable kernel or device driver written in Java? Of course you haven't! You get down to the that level and you'll see C interspersed with assembly. Move up a step to low level system software and it's all C with a smattering of C++. You don't find mid to high level languages until you get to the application level. (I'm not counting high level interpreted languages performing remedial scripting duties).

      --
      Don't blame me, I didn't vote for either of them!
    3. Re:C++ had its day by Screaming+Lunatic · · Score: 2, Insightful
      For many, this C derivative is still a daily living. Thats fine. It's powerful enough.

      Funny how you use "C derivative" in a derogatory way. You can also call Java, C#, Python, PHP, and Objective-C "C derivatives" too. They all use the same syntax style.

      For the most part though, end-user applications have no need to run in C++. I know the typical exceptions are in gaming, image processing and system internals, but this is a small subset of commercial programming.

      We'll ignore the fact that the browser, office suite, instant messenger, IDE, mp3 player, image editor and desktop is most likely written in C++ if not C.

      I think elementary programming skills can be taught in C++ (i've done it), but you have to peel away so much of the language, one might as well start from C anyway, and then explain OO, and then combine the two.

      That's how C++ is currently taught and is not the way it should be taught. This is the hello world program newbies should see.

      #include <iostream>
      class Output
      {
      public:
      Output()
      {
      std::cout << "Hello World\n";
      }
      ~Output()
      {
      std::cout << "Goodbye World\n";
      }
      };

      int main()
      {
      Output output;
      return 0;
      }
      Unfortunately it is not because the people teaching C++ think just as you think. That C++ is just a strongly typed C.

      These days, I think the same goals in being "practical" could be achieved with Java for the same (if not less) effort. Plus, one learns the concepts of Events, Interfaces and a more useful standard library.

      With respect to Events and Interfaces. Functors are much more powerful and generically useful than Events. Abstract base classes in C++ are the same thing as Interfaces in Java. Same concept, different syntax.

      With respect to libraries. Have you used the STL? Have you used Boost? Have you used Loki?

      I've cranked out over 100K of C++ (haha, not hard to do with low-density langs) but in the end, I wish it would have been a longer-lived system.

      I call B.S. From the rest of your post it seems like you don't even have a basic understanding of C++. Seems like you treat it like a strongly typed C with this fangled class thing.

  4. Wrox by Anonymous Coward · · Score: 1, Insightful

    I know these guys are usually MS weanies, but they have a couple of good C++ books by Ivor Horton.

    I have "Beginning C++"
    One day when I get a break from Java, I will actually start reading it.

    The Bjourn Stroustrap stuff is excellent too. Should be since he is one of the leading proponents of OOP on C and helped define how C++ works.

    I only know how to write "Straight" c and need to learn this stuff.

    l8,
    AC

  5. For templates there is one excellent book by Chuchi · · Score: 3, Insightful

    C++ Templates The Complete Guide by Vandevoorde and Josuttis (ISBN 0-201-73484-2, Addison-Wesley) is an absolute must for anybody wishing to use templates (or discover new areas where to use templates).

    The book talks about all the aspects of templates, has plenty of clear examples.

    Apart from this I would not suggest the Stroustrup book for learning C++, but it is excellent as a reference manual.

    --
    Chuchi
  6. Enough with C++/C/Java books! We need wider topics by Anonymous Coward · · Score: 5, Insightful

    Isn't it time we start seeing reviews of books other than C/C++/Java/Perl/C#/HTML?

    I am a hard core C++ person myself, but even I am fed up with the series of similar books on these PLs.

    There are many other topics in programming that deserve better attention by the /. developer community. Examples from the top of my head:

    Books on

    - Code optimization techniques (both for C/C++ & assembly level and optimization for web programming and DB programming)

    - Algorithms and data structures - this one will never go away whatever high level garbage collecting foolproof language/framework you end up using.

    - Software design topics (design patterns and its relatives, UML, alternative paradigms such as extreme programming)

    - Software project management topics ...

    Come on people!

  7. Stroustrup Book by Black-Man · · Score: 2, Insightful

    It obviously is the bible... but I feel is more of a reference. I keep it on my bookshelf and use it often as a reference... there is no way you can sit down and read this like a text book. Way too dry.

  8. Re:about the title by pavon · · Score: 2, Insightful

    Actually practicality is the only thing that C++ has going for it. It certainly is not the most elegant language, or the easiest to learn, or the fastest to write, or the least prone to programming errors. But it is powerfull and efficient, which is why it has been such a practical, popular language.

  9. Re:The C++ Programming Language by drudd · · Score: 2, Insightful

    I've actually found that typos can be helpful for the learning student. Sure, in the short term they'll pull their hair out, but in the long term, when they make similar typos, they know what to look for, and how to diagnose problems.

    Doug

    --
    Venn ist das nurnstuck git und Slotermeyer? Ya! Beigerhund das oder die Flipperwaldt gersput!
  10. Re:C++ had its day...and it is today by dmeranda · · Score: 5, Insightful

    I find that those who write off C++ really don't know the language, or at least the "modern" standardized language. C++ is incredibly powerful, and if you use solid OO techniques you really shouldn't have many issues with memory management. At least in C++ (as apposed to Java) the language guarantees that all destructors will be called and with well defined ordering. That allows you to use resource allocation patterns that greatly simplify memory manangement or resource issues entirely.

    Although you can compare pure Java with C++ as languages, it is meaningless to compare a Java framework/JDK such as J2EE with C++, as the former is an entire environment, not just the underlying language. There's lots of stuff that C++ does better than Java (generics/templates, destructors, high-performance containers, abstract algorithms). Not to mention that C++ is a completely standardized and *free* language, whereas Java is a fast moving pseudo non-free standard.

    Oh, and the syntax problems you complain about are not really all that different from Java, or even C#. Yes, they are each somewhat different and some have cleaner syntaxes for specific issues, but in the grand scheme of computer languages they are almost the same. And there are syntax problems with Java too which C++ doesn't suffer...they are both strongly based upon a C foundation, like C#, Javascript, etc.

    And yes, I've written very large C++ projects with many developers very successfully, and C++ has proven to be a very nice language indeed as long as you take the initial time to learn it correctly rather than out of a C++ for Dummy's tutorial.

    Now if you want to talk high-level languages (both Java and C++ are low-level of approximately the same power), then you should be talking about something like Python, or more academically Haskell. But Java is by no means a high level language, just as C++ is not.

  11. duplicitous != redundant by uncadonna · · Score: 2, Insightful

    did the reviewer really mean duplicitous as in fraudulent, or did he just mean to say redundant?

    --
    mt
  12. Re:Enough with C++/C/Java books! We need wider top by yamla · · Score: 4, Insightful

    Stop complaining and write a review yourself.

    --

    Oceania has always been at war with Eastasia.
  13. Re:"Practical C++" by Erratio · · Score: 2, Insightful

    It's probably details like that that are better off forgotten anyway. As time consuming as that line is to type in, if anything it makes the code a little more logical at a glance and considering the quirks specific to all the C based languages, I'd say stuff like that should be left in for legibility. That way more time can be spent by anyone dealing with code worrying about things that actually affect the working of the program.

    --
    I don't try to be right, I just try to make people think
  14. Re:C AND C++ ARE THE WORST LANGUAGES EVER DEVELOPE by tchernobog · · Score: 2, Insightful

    In fact, Mr. Knuth wrote "The Art Of Computer Programming" with MIX...

    Anyway, for those who love java and such languages... you simply like them because you don't have to know what you're doing. I say: first learn C or C++ AND assembly, then learn java (or other high-level languages), so you'll have a grasp on what the compiler/interpreter does with what you write, and you'll understand the other ones fully. Don't hate pointers... they're your best friend.

    Btw, why do you think that c and c++ are so widely used still today, if they suck so much?

    --
    42.
  15. Re:C++ had its day...and it is today by Anonymous Coward · · Score: 2, Insightful
    There's lots of stuff that C++ does better than Java (generics/templates, destructors, high-performance containers, abstract algorithms). Not to mention that C++ is a completely standardized and *free* language, whereas Java is a fast moving pseudo non-free standard.

    *cough*... Oh, you are ignoring the C++ ABI. Which of course is the best thing to do when it comes to the C++ ABI. And which of course is also what most C++ tool writers have been doing as much as they can. I just went to the PalmSource conference, and they announced that they are using C++ in PalmOS 6, but they aren't exposing any C++ APIs from the operating system to the app writer because there is not yet a standard C++ ABI for the platform they're running on. C++ has been around for at least, what 15 years now, and there is still no standard ABI, so you are pretty much forced to stick with one proprietary ABI or to compile everything (shared libraries included) all at once if it is meant to work together and/or match up the versions carefully.

    Meanwhile, in Java, despite the fact that the language has changed some, the ABI is basically constant across time and across platforms. So you can build your class libraries with whatever tools you want, one time, and they just work with anything else that wants to call them or be called by them. This is a Good Thing.

    I'm not saying that Java is superior to C++, I'm just saying there are some things that Java does waaaaaay better than C++. Plus, I'm also reacting against the wording "completely standardized" in reference to C++. It's just not true.

    By the way, I agree neither Java NOR C++ is a high-level language...