I was lucky to get a place at this month’s C++ London meet up, having a limited number of seats and being hosted by Smarkets at their offices in St Katherine’s Dock. Smarkets are an online betting exchange – and they’re currently hiring!
This evening was started by Alex Schmolck, presenting his work configuring the development and build systems for Smarkets. He’s experimented with Vagrant and Docker, but is now an advocate of Nix. He admits that Docker is initially more productive, but Nix has the edge for its efficiency and speed.
The main talk (see slides) was given by Mateusz Pusz, showing a series of examples to demonstrating how a body of code can evolve and improve significantly with the features introduced by C++11, C++14, C++17 and soon C++20.
For example, implementing functions with variable numbers of parameters – such as for populating a container of items for a testing library. With C++98, this might have led to many overloads with increasing numbers of arguments (but only ever handling up to some hand-coded limit). With C++11 onwards, you could use variadic templates, handling any number of parameters. And with C++17 onwards, you could use fold expressions to simplify the code further (no need to the ‘base class’ template overload).
Another interesting example was the evolution of Compile-Time Dispatch. Whereas even C++ 11requires hand-rolling overloads on a hierarchy of tag classes, post C++17, you can use constexpr to organise the code within a single method.
Our charity bookshop had a rather nice hardback edition of this thriller from Dan Brown’s Robert Langdon/Tom Hanks series, and I’m glad I bought it.
Here, we see Langdon as a mentor to a brilliant student, Edmond Kirsch, who has become a successful entrepreneur in the world of technology. And whereas Langdon has sometimes lacked depth, in this book his relationship with the beautiful Ambra Vidal (fiancee to the Prince Regent of Spain) is more nuanced than I expected. The book demonstrates the spread of social media and its ability to rapidly set the agenda. Even better, there’s a science fiction element to it in the form of Winston, an AI agent built and employed by Kirsch as his assistant.
There are also some quintessential Dan Brown moments, such as the hidden symbology in the Fedex logo, the history of the ampersand and, my personal favourite, the answer to I + IX (it’s 10 or 12, depending on your point of view).
The premise of the book is that Kirsch has made a great discovery about the origin and future of the planet – how did life on Earth begin and what is its destiny?
This book is an excellent primer on data science. It builds up concepts from scratch with code examples in Python. Whilst it uses some well-known libraries for utilities, the code that builds on the core Data Science concepts is all included and explained in the book.
I particularly enjoyed the conversational, often humorous style of the book. He gives a short introduction to NoSQL databases, then concludes: “Tomorrow’s flavour of the day might not even exist now, so I can’t do much more than let you know that NoSQL is a thing. So now you know. It’s a thing”. The author doesn’t get too stuck in jargon either – one example is his definition of a greedy algorithm: “… at each step, it chooses the most immediately best option” – perfect.
Some of the main topics covered are:
- Visualizing Data
- Gradient Descent
- Linear Regression
- Logistic Regression
- Neural Networks
Having covered the theory, the book extends to a few use cases – natural language processing, network analysis and collaborative filtering.
I bought a nice soft-back edition of this Jack Reacher thriller some time ago, but it was well worth re-reading. There has long been a gap in Reacher’s history – how did he go from being an elite investigator in the Military Police to travelling around America as a loner? This book fills in the gap and is one of the best in the series.
Reacher is assigned to go to Carter Crossing to shadow the town’s police department in their investigation of a murder. Although he’s supposed to be incognito, the police chief, beautiful Elizabeth Deveraux, unmasks him immediately. No matter, because the two develop a very close relationship working on the investigation together. The author plants seeds of doubt about Deveraux – perhaps she has a hazy past, taking revenge on former boyfriends? Could this murder, and two others of similarly beautiful young women, be her revenge after she was dumped by Captain Reed Riley, son of a US Senator? A side plot is that, sometimes the cover-up is worse than the crime. In this case, Reacher wants to know why local militia were employed to defend the military base outside the boundary – leading to the senseless murder of a journalist and the brother of one of the murder/rape victims. He confronts Colonel Frazer of military liaison at his office in the Pentagon – did he authorise the cover-up to protect his investment made building relationships with the Senator?
I always enjoy the Reacher books where he teams up with locals to solve the case – and as a bonus, this book features Reacher’s favourite Sergeant, Frances Neagley.
Another book from the SF Masterworks series, this one traces the adventurous Alvin, a unique individual in the city of Diaspar on Earth. Set a billion years into the future, Diaspar is the only city left, run by AI and repaired into perpetuity by autonomous robots. Yet Alvin feels that something is missing and has a deep yearning to explore beyond the city. He discovers a route to Lys, a community set in countryside far from the city, where the populace has evolved quite differently from those in Diaspar. His destiny is to unify these divided communities and to re-examine the shrouded history that separated them in the first place.
This C++ Meetup, held at Skillsmatter, was split into two talks.
The first by Ervin Bosenbacher was Modern C++ Smart Pointers in C++ 17, 20 & Beyond. It served as a good introduction to smart pointers and motivation for using them, particularly for developers new to C++ (or those who had not yet started to use C++11). The talk covered:
- Issues with use of raw pointers (ownership, how to delete, exception safety)
- std::auto_ptr and why not to use it
- std::unique_ptr and std::shared_ptr – trade-offs and performance figures
- Use RAII – assign a raw pointer to a smart pointer as soon as it is allocated
A good point was that use of std::shared_ptr means that other parts of the codebase can modify an object that you’re sharing – so synchronisation primitives (such as a std::mutex) are needed to ensure access to the underlying resource is thread-safe. This is often overlooked because the reference counting *is* thread-safe. In C++20, we will get atomic smart pointers to help with this.
Discussing std::shared_ptr with a friend, I also learnt about a secret constructor on std::shared_ptr to share the resource control block and keep a parent pointer alive.
The second talk was Arno Schödl on Error Handling. He described how Think Cell grade errors into different levels, each with a clearly defined error handling strategy. The aim is to minimise coding and testing overhead whilst maximising the ability to capture and debug error conditions.
A bit like The Right Stuff, this is a book most people have probably heard of, especially because of the famous film, made in collboration with the author. I knew that the plot involved the finding of black monolith, and a computer called HAL that mutinied against its crew.
Perhaps the most fascinating part of the story, though, is that the book was written in 1968 at the dawn of the space age. When Clarke described Extravehicular Activity (EVA), needed by the crew to repair the antenna on their ship, he defined the term used by future astronauts working outside the Space Shuttle or the International Space Station. He described the isolation felt by David Bowman on board, exaggerated because of time lag on communications between Earth and the space craft, and that lag forms part of space exploration experiments carried out today. When Dr Heywood Floyd plugged in his “newspad” to read the world’s major electronic papers, he effectively wrote the specification for today’s electronic tablets, 40 years before the first iPad was released.
There’s a fascinating scene where an alien intelligence has built an environment familiar to Bowman based on television and radio signals received out in space – yet books and magazines lack any content, because only the covers are transmitted. Perhaps the availability today of literature online means that, in a re-write, the aliens would be able to produce accurate re-print of the books.