Book Review: Programming: Principles and Practice Using C++, 2nd Edition

I learned C++ the hard way: in the early 1990’s, the best reference was Ellis’s and Stroustrup’s The Annotated C++ Reference Manual. At the advice of a good friend, I bought a copy, read it cover to cover several times, and spent the next several years of my career banging my head against the wall in largely C-only development projects trying to get mindshare to do things in C++. As a result, I learned a lot of bad habits at first, and wasn’t always the first guy to pick up on then-new things like the Standard Template Library when it became available. Add my extensive experience with Qt, and my C++ experience is actually quite spotty — there’s definitely room for improvement.

As a result, I jumped at the chance to review Bjarne Stroustrup’s Programming: Principles and Practice Using C++, 2nd Edition (Amazon link). This is an entry-level textbook on programming in C++ for new software developers; its target is obviously an undergraduate class for computer science majors, rather than a reference for a seasoned software developer. (If you’re looking for C++ for the seasoned developer, check out Stroustrup’s The C++ Programming Language, 4th Edition.)

Programming: Principles and Practice using C++ is an excellent modern introduction to what it means to be a programmer, while teaching all of the essentials of C++ you’re likely to need for your first few years. It covers a lot — C++ syntax, data types, the basics of object-oriented design, generic programming through templates, testing, and many other topics. The book is chock-full of code, often showing the iterative nature of programming as Stroustrup lays out the requirements for a program, and then shows version after version that works towards meeting those requirements. It clearly demonstrates how good software developers should approach programming problems, and is as much a book about thinking about programming as it is a book about programming. Which is, I think, exactly what the neophyte needs.

Don’t look here for a lot of information about clever data structures or algorithms — and that’s a good thing. Stroustrup leverages the STL for that, and emphasizes something I think good programmers already have learned — the best code is usually the code you didn’t write. There’s short discussions about some algorithms, of course, as befits a book on programming, as well as the idea behind an algorithm. But, for example, instead of learning to program a red-black tree, Stroustrup points the reader towards the STL’s map, and leaves it at that.

It’s scrupulously up to date, too, covering relevant portions of the latest C++14 standard, as well as using C++11 everywhere — which is great, because most compilers are C++11 compliant anyway, and students should be able to compose and understand programs using the latest language features.

Refreshingly, the book includes not just a discussion of object-oriented programming through the classic example of graphical programming, but actually enables readers to do simple graphical programming through a library on top of FLTK. In discussing the design and implementation of the library, Stroustrup covers classic object-oriented programming, including decomposition, inheritance, and data hiding. While the example is old, Stroustrup’s coverage of it is refreshingly up to date and thorough,

The strongest parts of the book are probably on the topic of generic programming and testing: one of the multi-chapter examples is a re-implmentation of the std::vector class, including almost everything in the standard library. This is an excellent introduction to a number of topics, including API design, memory management, pointers, templates, and generic programming in general. A little later is an excellent chapter going over iterators, looking at iterators as a classic example in generic programming.

It speaks highly of the book that I learned a few things in my read of the book; in some cases it was clarifying the reason behind a lesson I learned in the school of hard knocks, which is great to see in an introductory book of this sort. It was also refreshing to see how programming is taught today, especially using a language as fundamental as C++ is in the industry. In hiring engineers, I worry about the large number of developers who start with Java and never really get back to the basics; Stroustrup covers the basics quite nicely (including a chapter on embedded systems programming) without writing a textbook that’s only about the basics.

I’d recommend this book strongly to anyone just starting out in software development, and with some caveats for developers who already have significant programming experience. I think there’s someone for everyone in it, although the high price means if you’re skilled at teaching yourself programming languages — or just want to brush up on C++11 and C++14 — this might not be the most affordable purchase, even if it is a great read. But as an introductory textbook, it’s hard to beat, giving you a firm start in the fundamentals of programming in today’s world.

Book Review: Responsive Mobile Design

When it comes to writing about food, some books marketed as cookbooks and really just catalogs of recipes, and other books are about food but have lots of recipes as well. Responsive Mobile Design (and at Amazon), by Phil Dutson, is a cookbook of the second sort, about responsive mobile design that has lots of recipes.

I never really did get the cookbook format for computer books; the few I’ve bought I’ve inevitably answer a few questions, but I never really read them cover to cover. Phil Dutson’s book is different — not only are there lots of clear examples and how-you-should-go-about-doing-this kinds of things, but there’s lots of information about responsive design, and modern design for the web in general. As such, it worked really well — Dutson introduces a topic, talks about it in very specific terms, and then looks at specific points that require closer attention with technical examples or pointers to frameworks. There are lots of examples, and lots of figures showing the output of the examples, so you can really see what he’s talking about.

The book begins with some general observations about web design and content, which though lightweight technically, are a welcome reminder that it’s all too possible to create a technically excellent site that wouldn’t interest anyone. From there, he moves on to discussing basic layout principles with grids, tables, and measurement, before getting into the details of media queries and typography. There’s a whole section (three chapters) on how to make multimedia responsive, and then five more chapters on the specifics of tuning the performance of mobile web site, looking at everything from server choices to optimizing JavaScript and measuring performance with modern browsers. Dutson provides a clear, engaging style throughout; I planned on pacing myself by reading a couple of chapters a night to let things sink in, and frequently moved on to a third or even fourth chapter before stopping.

I got a lot more out of the book than I expected, and I had pretty high hopes to begin with. If I had to name a fault of the book, it’s that I’m not sure how well it will age in some regards. Dutson is very good about discussing proposed standards and differences between browsers, which should hold up well. However, he often provides pointers to frameworks, and it’s not clear how many of these frameworks will be around or kept relevant in the two-to-four year lifespan of a printed book. On the other hand, having those pointers and a summary of what’s available is great — if you’re just getting started setting up a site, it’s nice to know the pros and cons of the various packages you can start with. So I think his decision was the right one, and it may mean a little more time with Bing or Google once the book’s been out for a while.

If you’re at all curious about what makes a modern web site tick, or if you’re presently engaged in working on responsive sites, this is definitely a book to have.

Book Review: Advanced Android Application Development…

(So, disclaimer first: I’ve been working with the publisher & authors of this book through every edition as a technical reviewer; I don’t get anything from the sale of the books, but I enjoy working with the publisher and the authors.)

So, I got my review copy of Advanced Android Application Development, fourth edition by Joseph Annuzi, Jr, Lauren Darcey, and Shane Conder last week, and all I can say is that this great book gets better with every edition.

There are a lot of Android books out there, and most of them churn through the same basic stuff about views, intents, and services, with a smattering of information about networking and databases thrown in for good measure. This is the book you turn to for what’s next: serious discussion about SQLite databases services, notifications, input methods, networking, telephony, and Google Services like maps, location, cloud messaging, in-app billing, and analytics. There’s even a whole section — multiple chapters — on graphics, both 2D and 3D graphics programming using Android’s support for graphics and OpenGL ES. Recently updated to its fourth edition, there’s even some coverage of Android Lollipop and Android Wear. And there’s plenty of review material about networking and web access, too.

The book has copious sample code; the text fortunately doesn’t just reprint listings and leave you to puzzle over what they do, but carefully chooses the pertinent bits and pieces of sample applications illustrating the proper way to use Android interfaces. The full sample code of the applications is available for download, just as you’d expect. In many cases the samples are good enough to adapt for your own work, although they occasionally elide much of the necessary error handling that a good mobile application would require.

It’s hard to find fault with this book: with excellent coverage of SQLite, Android’s notification system, input methods & accessibility, and internationalization. Written right when Android L and Android Gear were being unveiled, it’s a little short on details on those topics, but that’s to be expected — it’s still got more than many books on the market today.

If you’re doing Android development, I strongly recommend getting a copy of this book and at least leafing through the parts of it that are new to you; it’s my go-to reference for all things advanced in Android.