Category Archives: Meetup

IET Meetup: Digital Twins, the Next Phase of the AI Revolution


I was lucky to get a ticket to this well-attended EngTalk at the Institute of Engineering and Technology.

The idea of an Intelligent Digital Avatar conjures up many images from a complete virtual world that one can safely define, develop and play in to rogue robots running amok and destroying mankind. The reality is much less dramatic but no less far reaching and exciting.

This year’s Turing Talk will be delivered by Mark Girolami; an academic statistician and the Sir Kirby Laing Professorship of Civil Engineering at the University of Cambridge.

Mark will discuss Digital Twins and chart their history to present day technological capability, looking at some of the advances being made and the opportunities along with the open challenges faced to realise the potential of Digital Twins.

The historical part of this talk was very interesting, with examples from 100BC (the Antikythera, the Greek instrument used to predict astronomical positions and eclipses), Kelvin’s mechanical device for predicting tides (used up to 1940, including D-day landings) to weather balloons to model and predict atmospheric pressure.

Mark’s premise was that, whilst 2015 was about BigData, 2020 is about Digital twins – layering mathematical models over complex data streams in order to extract useful information. He stressed the importance of the provenance of information, error checking and acknowledging bias in such models. He was also keen to point out that models should not be used to blindly infer causation (an observed effect might be caused by some outside factor that was not understood or included in the model).

Leave a comment

Filed under Meetup

C++ London Meetup: Type Punning and Counting Nanoseconds

September’s C++ London Meetup featured two talks: Type Punning by Timur Doumler and Counting Nanoseconds by David Gross of Optiver. Optiver were the generous sponsors of this event, hosted at SkillsMatter near Moorgate.

Counting Nanoseconds

Optiver are based in Amsterdam and operate in the High-Frequency Trading sphere. Naturally, they need code to be fast in order to take trades more quickly than their competitors, but the benefits of fast code also extend to minimising energy costs in data centres and extending battery life on portable devices for other applications. David Gross spoke about micro-benchmarking – boiling code down to very small numbers of instructions to aid comparisons and improve performance. The caveat was that it’s always vital to measure performance in production using real data as well as doing this offline, low-level analysis against potted test cases. David warning against relying on the high-resolution clock which can be problematic (may not be steady and may not have the resolution you need). He often uses Intel Time Stamp Counter (TSC), although that’s not the original intention of that metric.

Type Punning

Timur is fascinated by the ability to take an object and treat it as another type in C++. Yet, in many cases, this results in undefined behaviour. For example:

class Gizmo {
  public:
  virtual void print(){ std::cout << "Gizmo\n"; }
};
class Widget {
  public:
  virtual void print(){ std::cout << "Widget\n"; }
};
Gizmo g;
Widget* w = (Widget*)(&g);
w->print();

The behaviour of this code is undefined, because Widget and Gizmo are unrelated, although both have a virtual print function, so the virtual function table is the same. The standard says that you can’t call a method on a reinterpret-cast’d object – you can only cast it back to the actual type of the object. But on most compilers tried by Timur, the code runs and prints “Gizmo”. He referenced the CppCon 2018 talk, Undefined Behaviour is Not an Error.

Other examples concerned how to share memory across multiple data types, such as treating 4 bytes as either a char array or as a float. Even using a union can result in undefined behaviour, because only one member is ‘alive’ at a time. In order to write portable code, you must consider aliasing rules, object lifetime rules and alignment rules. In same cases, you can use C++17’s std::memcpy to ensure alignment (but only if the types are the same size and trivially copyable). std::bit_cast is coming with C++20. And in C++23, there’s a proposal for std::start_lifetime_as(char[]) to implicitly create objects, for example when reading from a buffer.

The video for this talk is available on SkillsCast.

Leave a comment

Filed under C++, C++ Code, Meetup, Programming

C++ London Meetup: C++ 11 was only the Beginning

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.

Leave a comment

Filed under C++, Meetup, Programming

C++ London Meetup: Pointers and Errors

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.

Leave a comment

Filed under C++, Meetup, Programming

IET Meetup: Debugging the Brain


In 2011, Ed Boyden won the IET Harvey Prize in recognition of his contribution in the field of optogenetics. Now some years later, he came to the IET to update the organisation on the progress his team have made in that field and how their contrarian approach has led to developments elsewhere.

The field combines light-based optical technologies and genetics to control the activity of neurons, enabling treatment of conditions resulting from a wide variety of brain disorders, such as epilepsy, post-traumatic stress disorder, and Parkinson’s disease.

Boyden described novel techniques, such as repeated miniaturisation of structures by injecting a lattice and using dehydration of hydrogels. This was discovered by reversing a process performed to increase the scale of neutrons in brain tissue so they could be visualised for research projects.

Marquee events like this are always very popular at the IET and this one was was very well attended. What was particularly notable was the number of well-informed questions after his presentation from researchers in similar fields who had travelled to attend the event.

Leave a comment

Filed under Meetup

IET Meetup: Appleton Lecture – AI and Human Digitization


The first address in this year’s Appleton lecture was given by Dr Sarah Atkinson. She gave a historical view of “fake news” created by manipulation of media, starting with the Cottingley fairies. This set the scene for Dr Hao Li’s excellent presentation of his research into animation of people, initially through long-running processes for film effects, but latterly in real-time for Animoji on the iPhone X.
Dr Hao Li - Animoji Mastermind
There are plenty of applications for the techniques, such as video conferencing, social media and even films. However, the common theme was that, as these technologies become mainstream, we should no longer assume that video evidence of a speaker saying something is actual real.

Leave a comment

Filed under Meetup

IET Meetup: Mountbatten Lecture, 2018

I was lucky to attend the 2018 Mountbatten lecture at Savoy Place, London. This year’s speakers were Dr Julia Sutcliffe of BAE Systems and Air Marshal Julian Young of the Royal Air Force.

Dr Sutcliffe’s theme was “Air Sector Technology – is the sky still the limit?” and spoke of breakthrough technologies such as cloud computing and artificial intelligence as the 4th Industrial Revolution (after Steam, Electricity and Electronics/Computing). Her interest in military air systems is the generation of huge amounts of information for each single flight – not only from machine performance but also from crew health metrics. It would be a game changer to be able to receive the telemetry in real time so that appropriate action could be anticipated and actioned as soon as the plane returns to base. Other topics were unmanned systems for dirty or dangerous tasks and “Chemputation“, a method for using algorithms to build materials.

Air Marshal Young’s theme was “RAF 2118 – Engineering the next 100 years”. His point was that the Royal Air Force has been entwined with technology throughout its whole life, with innovation often the deciding factor in conflicts. Innovation has produced accuracy improvements in weapons delivery as well as amazing reliability for engines (such as the EJ200 in Typhoons). Novel technologies can also deliver increased operational performance, reduce production costs and reduce through-life savings – leaving more money to buy shiny new aeroplanes.

Interestingly, multi-core processors are not currently sanctioned for use in safety-critical systems because predictability is paramount. And whilst 3D printing could potentially allow spares to be produced “in theatre”, in practice it’s more reliable to produce them at home in a factory and send them in one of the daily flights transporting crew/cargo to the area.

The RAF Engineering teams breed a culture of innovation and “restless improvement” with each new generation.

Leave a comment

Filed under Meetup

C++ London Meetup: Tuppence more on Standard Algorithms

This evening of talks was split into a set of Lightning Talks in the first half followed by a discussion about the Standard Library in the second half.

Part 1 – Lightning Talks
Richard Chandler – ACCU 2018 Trip Report – much on C++14 and C++17 standards to catch up on as well as introduction to Kotlin and a number of talks on diversity and inclusivity.

Phil Nash – East End Story
Phil dived into the controversial East Const v West Const debate

    void f( T const& t ) // East const
    void f( const T& )   // West const

i.e. should you put the const before or after the type. This topic was introduced by Dan Saks in 2011 – Simplifying const Syntax, Dr Dobbs and revived by Jon Kalb in A Foolish Inconsistency.

“Const applies to what is on its left, unless there is nothing to the left, in which case it applies to what is on the right.” But using east const format, it always applies to the left! West const reads more naturally from left to right, e.g. “const integer” – the East const argument is that you would always read declarations inside out and right to left!

    char const * const pc = str // pc is a const pointer to a const char, reading right to left

Developers are already accustomed to using East const for const member functions (must put const on the ‘east’ side). And there are other examples of going East:

    // moving the return type further east as a result of c++11
    auto someFunc( int i ) -> std::string; 

    // you have to put the return type on the east side
    auto lambda = [] -> double { return 0; } 

Other considerations: Swift/Haskell have trailing return type; putting auto at the start of list of function definitions, the start of the names line up; C++ standard NL.26 says use conventional const notation, endorses West Const notation, but is itself inconsistent!

Phil is now using trailing return types everywhere in production code – see his blog, East End Functions (LevelOfIndirection.com)

Stewart Becker – A Fool’s Consistency, the rebuttal (Jonathan Muller’s talk)

East const gives more consistency? If 83% of people write const T (i.e. West const), you need to be consistent with everyone else in your codebase.
Const pointer to const fallacy – with modern c++, use const std::string_view instead. Can use std::as_const(x) to get the const cast.
Right-to-left fallacy – but we read loops etc from left to right, and ‘const’ is an adjective which goes before the noun in English.
Clockwise-Spiral rule for function pointers.

const east west const – you are allowed to write const in both the East and West positions!!

Part 2 – Tuppence More on Standard Algorithms – Iakov Sergeev
Iakov believes the standard algorithms should make code easier to implement and read, but are forgotten in practice. He raised issues with inconsistencies and the learning curve to use STL (output iterator, predicates, modifying input sequences, could take both begin/end iterators).

Historically, the predicates were hard to implement where you had to supply a functor to call algorithms. Now, with lambdas, it’s much easier and localised to call algorithms.

The audience felt that Eric Niebler’s work on the Ranges TS should help a lot with adoption of standard algorithms.

Leave a comment

Filed under C++, Meetup, Programming

IET Turing Lecture: Innovation and Technology – Art or Science

This evening at the IET was split into two lectures, the first by Larissa Suzuki entitled “Brave New Smart World”. Larissa covered a lot of ground, scaring the audience with figures on our over-population of the planet, over-consumption and lack of recycling. Then she showed how we may have potential to engineer our way out of these global problems – with smart cities, self-driving cars and smart-recycling.
Quote of the Day:

You cannot jujitsu your way out of bad data


The main Turing Lecture was by Andy Harter, who among other things invented VNC (used for connecting to remote computing devices). The stated intention of the lecture was to make the audience think about whether innovation and technology owe more to Art or Science. The lecturer admitted that his hope was that we’d agree that both are necessary. He covered a number of facets that he believes are the ingredients behind the best inventions: Creativity, Necessity, Storytelling, Timing, Retrospection, Observation, Laziness, Simplicity, Responsiveness and Generosity.

If necessity is the mother of all inventions, laziness is the father!

This quote was quite pertinent to the speaker, who invented VNC so that he didn’t have to leave his office to help a colleague down the corridor with issues on his machine!

Leave a comment

Filed under Meetup

ACCU Meetup: Code Craft

Jason Gorman of CodeManShip gave an interesting talk on code craft this week. The talk began with the business case for Code Craft, based on the cost of changing a line of code. If you compare the number of changes in source code repository to the expense of their development teams, the cost generally increases massively over time – 40X more expensive per line of code change after 8 years for one company. The same hockey-stick chart appears in Kent Beck’s book “Extreme Programming Explained”. Code Craft skills tend to flatten the cost-of-change curve, which is good for the business, and make the code easier to change, which is good for the developers.

Code Craft Skills

Write good unit tests, use version control, do continuous integration, apply design principles, refactor code safely.

Cost – if the cost of a change in design is 1, then the cost in implementation is 6.5, in testing is 15 and in maintenance is 100.  Bringing testing forward in the development process gives a massive return on investment.  Legacy code can be defined as any code that doesn’t have fast running, automated unit tests that can discover a bug quickly – enabling a cheap fix.  You must automate testing and enable the feedback loop to iterate quickly – ideally in minutes or seconds.

Readability – 50%-80% of time spent on a codebase is reading code, not writing it.  Making code easier to read and understand has a great pay-off.  Code that’s hard to understand is easy to break.

Complexity – attack complexity, try to replace it with the simplest thing, which is less likely to be wrong.

Duplication – never copy/paste code, especially off the internet!  You have no idea if it works or even compiles.  Making changes to common logic is multiplied if there’s duplicate code.  Duplication is the opposite of reuse – generate an abstraction to help improve the design.  Duplication can be hard to spot (e.g. customer playing several roles which could have been parameterised).

Ripple Effect – a change to one area of code breaks a much wider circle of code.  Cost of change greatly increased – need to have a local effect from a small change to code.

Principles of Clean Code

The speaker also coaches teams in the following principles:

1. Shorter feedback loops – automated unit testing.  Not possible with manual testing iterations or a manual testing phase.  Automated system testing can give good coverage, but is often too slow, can take hours to run.  Need to run in minutes or seconds.  Ideal chain is Unit Testing -> Integration testing -> System testing.  Want most of the testing in first layer, minimal number of smoke tests in the top System layer.

2. Simple Design – the code works, clearly reveals intent, free of duplication, made out of simple parts.  Need another pair of eyes to check the code is easy to read.  Code review your own code every few minutes.

3. Single responsibility – traditionally, this is taught as classes should only have one reason to change.  Or better, look at the number of combinations of the sections of code implemented in a function – it’s more powerful to break functions into smaller parts then use composition to implement the larger function.  Smaller components/functions => many more ways to re-use. So give each piece of software a single responsibility.

4. Tell, don’t ask – lots of low-level coupling between objects. Better to have objects sharing smallest possible interface to each other. Don’t pass the whole object – pass the data needed to do the operation.  Put the work where the knowledge lives – do the work in the right place so that data and behaviour belong together.

5. Dependency Inversion – you should be able to swap your dependencies.  Talk to dependencies as abstractions through interfaces.  Eg1 all commands inherit from ICommand and high-level components work on generic interface, not concrete classes.  Eg2 VideoRental example, rather than coupling to Imdb, replace with an interface.  Better for mocking/testing as well.

Leave a comment

Filed under Meetup, Programming