Monday, June 11, 2018

Interesting Book: The Modern C++ Challenge

I recently became aware of a nifty new book about C++, The Modern C++ Challenge. Today I saw that the ebook is available for $10, which strikes me as quite the bargain.

Before I tell you why I think the book is interesting, let me dispense with some caveats. First, I haven't read the entire book, I've only looked at parts of it. Second, I haven't looked closely enough at the source code to evaluate it. (Because the book uses some C++17 features and my involvement with C++ ended with C++14, I wouldn't really be able to fairly evaluate it, anyway.) Finally, I got the book for free when Packt sent me a (digital) copy.

Two things struck me when I looked inside the book:
  • The "Modern" in The Modern C++ Challenge is as modern as you can get: C++17 (with the occasional mention of C++20).  To run the solutions to the problems in the book, you'll need a C++17-conformant compiler.
  • The "C++" in The Modern C++ Challenge is broader than just the language proper and its standard library. The list of software used by the book includes over a dozen third-party cross-platform libraries, including Boost, Asio, Crypto++, Curl, NLohmann/json, PDF-Writer, PNGWriter, pugixml, SQLite, and ZipLib.
The book itself consists of a series of programming problems ("challenges") and sample solutions. Some are simple, such as Problem 1:
Write a program that calculates and prints the sum of all the natural numbers divisible by either 3 or 5, up to a given limit entered by the user.
Others are more difficult, such as Problem 22:
Write a small library that enables expressing temperatures in the three most used scales, Celsius, Fahrenheit, and Kelvin, and converting between them. The library must enable you to write temperature literals in all these scales, such as 36.5_deg for Celsius, 97.7_f for Fahrenheit, and 309.65_K for Kelvin; perform operations with these values; and convert between them.
All in all, there are 100 problems in a variety of areas, including string processing, dates and time, concurrency, cryptography, and networking.

Because the book isn't afraid to lean on third-party libraries, some of the problems ask you do to things that the standard library can't touch. For example, here's the last problem in the book:
Write a program that can identify people's faces from pictures. At a minimum, the program must detect the face area and the gender of the person. This information should be printed to the console. The pictures must be loaded from the disk.
Wow. Unless there have been big changes to the STL since C++14, there's no "gender_from_image" functionality in the standard library. I wouldn't know where to start. The book's solution begins with some really useful information:
This is yet another problem that can be solved using Microsoft Cognitive Services. One of the services available in this group, called Face API, provides algorithms for detecting faces, gender, age, emotion, and various face landmarks and attributes, as well as the ability to find face similarities, identify people, group pictures based on visual faces similarities, and others.
This is representative of what I view as a strength of the book: the ability to introduce you to libraries and APIs beyond standard C++ that you may not be familiar with. I think that's an important contribution to C++ and its effective application, and between that and the use of features new to C++17, I think it makes the book worth looking into.

The Modern C++ Challenge is currently available for ten bucks for the digital versions of the book and for $35 for the digital and print combo platter. I think that's very reasonable pricing, and, no, I don't get anything for encouraging you to look at the book, nor do I get a kickback of any kind on sales. I just think the book looks really interesting.


 

10 comments:

  1. Thanks Scott. It seems like a fun concept. I think I'll try it out and run the challenges with the team.

    Cheers
    Kjell

    ReplyDelete
  2. Thanks scott for recommending this book. I looks really fun. I will surely look into it.

    ReplyDelete
  3. Thanks for the recommendation! I've been looking for a book that would explore the realities of using libraries in day to day development tasks.

    ReplyDelete
  4. I have added the print+ebook combo into my cart. It says it is $34.99, but in the cart it is only $22.75. With free shipping.

    ReplyDelete
  5. Thank you, Scott. It looks very interesting.

    ReplyDelete
  6. Thank you Scott, very cool!

    ReplyDelete
  7. This is awesome! I think we need more such books.
    Thanks Scott! :)

    ReplyDelete
  8. Thank You for your recommendation Scott. it's important to be able to review a book that'is suggested by you. Thanks a lot!

    ReplyDelete
  9. Thank you for sharing your info. I really appreciate your
    efforts and I am waiting for your further write ups thank you once again.

    ReplyDelete