Journal Articles
Browse in : |
All
> Journals
> CVu
> 324
(9)
|
Note: when you create a new publication type, the articles module will automatically use the templates user-display-[publicationtype].xt and user-summary-[publicationtype].xt. If those templates do not exist when you try to preview or display a new article, you'll get this warning :-) Please place your own templates in themes/yourtheme/modules/articles . The templates will get the extension .xt there.
Title: Reviews
Author: Bob Schmidt
Date: 01 September 2020 16:56:13 +01:00 or Tue, 01 September 2020 16:56:13 +01:00
Summary: The latest roundup of reviews.
Body:
We are always happy to receive reviews of anything that may be of use, or of interest, to software developers. The emphasis will tend to be on technical books, but we are also interested in less-technical works – for example the humanities or fiction – and in media other than traditional print books.
Do you know of something you think deserves – or does not deserve – a wider audience? Share it here. We're keen to highlight differing opinions on the same work, so if you disagree with a review here do send in your own! Contact Ian Bruntlett at reviews@accu.org.
A Tour of C++ (Second Edition)
By Bjarne Stroustrup, published by Pearson Addison-Wesley, ISBN 0-13-499783-2, website: stroustrup.com
Reviewed by : Ian Bruntlett
Highly recommended
The Preface of this book states that it should be treated like a sightseeing tour of a city – but of C++ – after which the language can be explored in more detail.
The first chapter deals with the basics – an overview of the fundamentals of C++ (the notation of C++, its model of memory and of computation) and the basic mechanisms for organising code into a program (procedural programming). The more advanced topics are dealt with in later chapters. There are a few example programs that the reader could type in. The rest are fragments. This is a pity but if you want examples to type in, there are other books that provide them. The next chapter deals with ‘User-Defined Types’ – structs/classes, unions (but prefer std::variant
) and enum classes. The next chapter, ‘Modularity’, covers how C++ programs can be developed from individually developed parts – from functions through to class hierarchies and templates and logical modularity (namespaces). Exceptions and other error handling alternatives are covered, including contracts (sadly dropped from C++20) and static assertions.
A huge chunk of the C++ Language is covered by chapters 4 through to 7 and I will attempt to do them justice. Chapter 4, ‘Classes’, illustrates different uses of the class mechanism – concrete types, resource handles, abstract types, class hierarchies... with good examples. It left some details unanswered, though – I presume that the details are to be found in the author’s other books (The C++ Programming Language, 4th Edition, published by Addison Wesley in 2013), the C++ standard or www.cppreference.com. The next chapter deals with ‘Essential Operations’, covering certain operations (construction, assignment, destruction) that the language makes certain assumptions about. It looks innocuous enough but it is full of essential information. It introduces the ‘rule of zero’ which states “either define all of the essential or none†– coupled with exceptions, this shows how to have memory and other resource handling performed automatically without the need for an explicit Garbage Collector. The next two chapters – ‘Templates’, ‘Concepts and Generic Programming’ are mind-bending and I will be supplementing the information given here with other C++ books.
The rest of the book (barring a ‘History and Compatibility’ final chapter which also details when certain features were introduced) is all about the standard library and would have been even better with more examples. It starts with an overview chapter and on to chapters on ‘Strings and Regular Expressions’, ‘Input and Output’, ‘Containers’, ‘Algorithms’, ‘Utilities’, ‘Numerics’, and ‘Concurrency’. The book lacks a Glossary – however, the author provides one online at www.stroustrup.com/glossary.html.
This book is a useful, brief, introduction to C++17 (and hints of C++20 and later standards). I think its unique selling points are its brevity and the advice given by the author.
C++ Crash Course – A fast-paced introduction
By Josh Lospinoso, published by No Starch Press (2019), ISBN: 978-1-59327-888-5, website: ccc.codes
Reviewed by Ian Bruntlett
Highly recommended
This book consists of ‘An Overture to C Programmers’ followed by two main parts, ‘The Core Language’ and ‘C++ Libraries and Frameworks’. At first glance, the order in which the language is introduced is somewhat unusual (but good) – it is intended for intermediate to seasoned programmers, so time will tell. Helpfully, most chapters end with a ‘Further Reading’ section. I used this book as a kind of C++17 Primer with examples. In addition, the text often explains example programs in great detail. I am not a C++ expert but I have done my best to verify my findings. No Starch Press kindly provided a physical and electronic copy of this work.
‘An Overture to C Programmers’ tries to sell this book – and C++ in general – to experienced C programmers as a kind of ‘Super C’. It does give an assembler listing to show an optimisation of constexpr
but only refers to an x86 book – there are plenty of x64 resources out there and most programmers using Intel/AMD hardware are most likely to be using x64 cores. I think that the examples should have been introduced with the proviso ‘You are not intended to understand this… yet’.
Part 1 covers the core language in 9 chapters and just over 270 pages. It brings in the language concepts at the beginning. For simplicity and familiarity, it uses printf
in its examples, rather than iostreams
, which I feel is unfortunate.
The first chapter, ‘Up and Running’, explains an example C program, shows how to set up a C++ development environment (Visual Studio, Xcode, gdb). It can get quite involved and, ideally, you’ll either know how to do it already or know someone else that does. It has a section on Bootstrapping C++ that introduces the basic concepts of C++. It finishes with a section on debugging with an example being debugged in the previously mentioned tools.
The next chapter, ‘Types’, is ambitious. It starts with fundamental types, and progresses through arrays and user defined types all the way to fully featured C++ classes – methods, access control, constructors and initialisation, and destructors. It is particularly detailed in its coverage of the different ways to initialise objects, concluding that in general always use {}
except for when using certain stdlib classes. Strikingly, it overlooks the protected
keyword.
The next chapter, ‘Reference Types’, concentrates on pointers and references and their differences. As is customary in some C++ texts, it recommends declaring a pointer variable as int * my_ptr
. This can mislead the reader into thinking that you can declare two pointer variables with int * my_ptr, another_ptr
, which is wrong. It illustrates the hazards of sloppy pointer arithmetic. It does cover address space layout randomisation – but surprisingly it doesn’t illustrate physical memory as a sequence of bytes, the machine stack or the free store. The const
keyword (arguments, methods, member variables) are dealt with as is the auto
keyword. The author recommends “As a general rule, use auto
always†– which I believe is a bit extreme. Some examples are highly contrived and, at first glance, got me thinking ‘What are they trying to achieve here?’ but the abundant examples have greatly assisted my learning of C++. One thing bugged me – it kept on referring to C++ idioms as Design Patterns.
The ‘Object Life Cycle’ chapter discusses local, static, thread local and free store variables. It illustrates their behaviour. It gets one thing wrong – in its thread_local
example, the relevant variable is never referenced so it got optimised out of existence. Some help from accu-general got it working properly. It also covers how to use and react to exceptions and provides a SimpleString
class to show how constructors use exceptions and how destructors are used to release resources. It shows how naive copy
semantics cause problems and how move
semantics can add a welcome boost in performance. It does mention value categories, something I’ll have to learn more about.
The ‘Runtime Polymorphism’ chapter washes its hands of implementation inheritance. It recommends the use of pure-virtual classes to implement interfaces. It discusses the use of constructor injection and property injection as well.
‘Compile-time Polymorphism’ is all about templates. It covers a lot of ground so some material is a bit thin because of that. I have some experience of putting templates into practice and even so, I found it necessary to re-read this chapter. It covers const_cast<>
et al, a function template example, and a smart pointer template example. It also covers the Concepts TS and illustrates how to define your own concepts and the use of type traits as a compromise for situations where Concepts are not available. It recommends other books to build on this foundation.
‘Expressions’. Everyone knows all about expressions, don’t they? This chapter might change your mind. There is the usual operator precedence and associativity with a useful table. Unfortunately, when it comes to order of evaluation advice (on page 196) it is still based on C++11. See [1] for current wisdom. Because, to quote Bjarne Stroustrup’s A Tour of C++ 2nd Edition section 1.4, “The order of evaluation of expressions is left to right, except for assignments, which are right to left. The order of evaluation of function arguments is unfortunately unspecifiedâ€. It shows how to overload new and delete and how to implement your own free store management. User defined literals are mentioned briefly. Type conversions are discussed in depth. There is an interesting constexpr
example – rgb_to_hsv
.
The ‘Statements’ chapter covers basics – the usual stuff plus namespaces, type aliasing, structured bindings, attributes, constexpr if
. However, one example shows a range class for Fibonacci numbers, which I thought was particularly welcome.
The ‘Functions’ chapter finishes off Part 1. It seems fairly comprehensive, ranging from simple stuff through to mind-bending stuff (lambdas, templates). Again, the examples were really helpful.
Part 2 of this book (430+ pages) covers many things with chapters on testing, smart pointers, utilities, containers, iterators, strings, streams, filesystems, (stdlib
) algorithms, concurrency and parallelism and Boost ASIO (network programming) and odds and ends for writing applications. For a lot of examples, the Catch2 TDD framework is used, to illustrate the behaviour being taught. A mixture of standard library and Boost’s library facilities are covered here.
The ‘Testing’ chapter explores TDD using an extended example of a braking system for an autonomous vehicle. It starts off with simple assertions and then moves onto more ambitious facilities (Catch v2, Google Test, Boost Test). It covers Mocking Frameworks (Google Mock, Hippo Mock).
The ‘Smart Pointers’ chapter covers families of smart pointers (scoped, unique, shared, weak, intrusive). It finishes off with an example of a toy allocator.
The ‘Utilties’ chapter covers “a motley collection of toolsâ€. There are Data Structures (tribool, optional, pair, tuple, any, variant). There is quite a section on Dates and Times and finally Numerics (functions, complex numbers, constants, random numbers, numeric limits and compile time rational arithmetic).
The ‘Containers’ chapter covers a variety of containers from stdlib and Boost. It acts both as a tutorial and as an abbreviated reference. Some parts needed to cover broad topics, so further reading is required. Again, there are useful examples using Catch v2 to illustrate container behaviour.
The ‘Iterators’ chapter covers iterators with some very useful reference tables that lists the operations that different iterator types support.
The ‘Strings’ chapter is over 40 pages long, covering the varieties of std::string
, a multitude of methods – including std::string_view
and regular expressions from both stdlib and Boost.
The ‘Streams’ chapter is interesting but I feel that the later examples would be better understood after reading other C++ books.
The ‘Filesystems’ chapter covers stdlib and Boost facilities that provide platform agnostic facilities for interacting with the kinds of hierarchical provided by Linux and Windows and other operating systems. It covers a forest of facilities, not always supported by every platform – it can be difficult to separate the wood from the trees.
The ‘Algorithms’ chapter covers a big topic, is a large chapter with Catch v2 examples of algorithms in action, divided into the usual categories – non-modifying sequence operations etc.
The ‘Concurrency and Parallelism’ chapter is a necessarily short coverage of the topic. The examples require an up-to-date toolchain. There is quite a selection of examples to experiment with but I am not familiar enough with this topic to comment further.
The ‘Networking with Boost ASIO library’ chapter is present because the stdlib does not currently support networking. It is interesting but I am out of my depth with this chapter.
The final chapter, ‘Writing Applications’, is an assortment of useful things to know including std::atexit
, std::abort
, std::system
, std::getenv
, std::signal
, and Boost ProgramOptions for dealing with command line parameters.
Conclusion: This is a comprehensive book, both in size (over 700 pages, taking 5 months to review) and breadth of coverage. It provides suggested reading at the end of most chapters and has a decent index. The examples are built using the CMake cross-platform system which helps a lot.
All in all, highly recommended.
References
[1] ‘Refining Expression Evaluation Order for Idiomatic C++’:http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0145r3.pdf
Girl Decoded: A Scientist's Quest to Reclaim our Humanity by Bringing Emotional Intelligence to Technology
By Rana el Kaliouby and Carol Colman, published by Penguin Random House, ISBN 9781984824769
Reviewed by Silas S. Brown
Recommended
I may be biased – Rana was my fellow PhD student (and she mentions me in this book) – but I must say it’s a good read, although be warned Rana’s story does have its dark times. Don’t expect much technical content from this book: phrases like ‘dynamic Bayesian networks’ (in Rana's algorithm for interpreting facial expressions) are about as much detail as you’ll get, although there’s more of that in her thesis ‘Mind-reading machines: automated inference of complex mental states’, which is available online. Girl Decoded†is Rana’s memoir, showing how she became interested in the face’s role in communication and wanted to unlock the medical potential of automated emotion detectors, especially for training people with autism (she collaborated with Simon Baron-Cohen, who had popularised the observation that autism is a spectrum not a single condition). Although her team later had to put this idea ‘on hold’ to focus on getting funding from market-research departments measuring test-audience reactions to advertising, they’ve opened their SDK for medical and safety benefits – autism training, suicide prevention support, measuring outcome of reconstructive plastic surgery, early diagnosis of Parkinson’s disease (coded by a 15-year-old schoolgirl), healthcare-support robots, tools for self-training at speaking skills, and systems that remind inattentive drivers to stay safe. On the other hand, they refuse to let their SDK be used for surveillance purposes, turning down lucrative contracts even when the company was in trouble. The narrative is compelling and could be an inspiration to anyone wanting to get into coding, especially from a minority background.
One thing this book touches on only briefly is accuracy. No AI classifier will be right 100% of the time, and its limitations must be kept in mind to avoid ‘automation bias’ – the feeling that ‘it must be true because a computer said it’. In this area, 90% is considered good, but that’s still wrong one case out of every ten. But what surprised me in Rana’s research is that humans can be even worse – in one situation involving subtle differences, they were answering wrongly as much as 30% of the time, a figure I like to quote whenever somebody thinks their colleague hates them because they can ‘see it in their eyes’ (there’s a 30% chance you’re misinterpreting) although it didn’t end up in this book. If face-reading is to be used in job interviews, Rana would rather it be done by her algorithm than a human, and perhaps the most valuable piece of information in the book is the hint about what these algorithms will likely be set to look for.
While this is not the usual kind of technical book reviewed by ACCU, I think the ACCU readership would enjoy this and in some cases may be able to pass it on to inspire someone else to take up our craft.
Notes:
More fields may be available via dynamicdata ..