Mircea Baja's Posts
26 June 2021
“Agreed on the core issues with some bikeshedding required on the following function names”. Huh?
25 June 2021
AWS S3 consistency history
A case study of how the evolution of Amazon S3 consistency is linked to issues postulated by the CAP theorem. An example of eventual consistency.
20 May 2021
Consistency: ACID and CAP
Introduction to consistency problems in distributed systems
17 April 2021
Branch stability basics
A basic description of options for source code branch stability (with references to git, but applies to other version control systems)
08 April 2021
IM reading notes
Reading notes for Stephen Cole Kleene: Introduction to Metamathematics (Ishi Press: 2009 reprint)
04 April 2021
Choice of postulates in IM
The choice of postulates in Stephen Cole Kleene’s Introduction to Metamathematics
16 March 2021
Things I wish I knew when I was a child about the game of chess.
10 March 2021
Is there any bug?
In this code, is there any bug?
27 February 2021
Fixed vs. latest
Your software A depends on another piece of software B. Should you build against a fixed version of B or always get the latest?
01 January 2021
Books Read in 2021
List of books I’ve read in 2021
10 May 2020
How vector works - the other vectors
“The std::vector is only one kind of vector”, I’m paraphrasing Alex Stepanov here. Let’s look at the options.
08 May 2020
How vector works - copy vs. move
When a vector resizes and needs to transfer existing values to the larger array: does it copy or does it move them? It’s more complicated than it should be.
04 May 2020
Exception safety refers to what are the reasonable expectation regarding how a function deals with exceptions.
28 April 2020
How vector works - push_back
A close examination of the push_back operation for vector.
20 April 2020
How vector works - basic
The basics of the std::vector, the default container in C++.
06 April 2020
How vector works - array and positions
What we need to know about C arrays so that we get the C++ vector.
04 April 2020
Notes on Freeman Dyson’s story on his encounter with Fermi
22 March 2020
Fibonacci Implementation Experiments
Lessons learned while calculating the 1 millionth entry in the Fibonacci sequence
20 March 2020
Advanced Introduction to Multithreading
Advanced in that it assumes audience used/heard of threads, introduction in that the subject is deep and complex
26 February 2020
Irregularity in Generic Programming
Link to presentation slides @ ACCU Oxford - 26th February 2020
01 January 2020
Books Read in 2020
List of books I’ve read in 2020
12 November 2019
The thread sandwich pattern
A common code structure pattern for multi-threading is the sandwich pattern
05 November 2019
A brief history of the meaning of volatile in C++
02 November 2019
A few examples involving synchronizes-with: the C++ key word for basic thread synchronization
31 October 2019
C++11 data race
Data races in C++11 are undefined behaviour
29 October 2019
Threading before C++11
Threading was possible before C++11. How did it work?
25 October 2019
CPU memory model
Modeling CPU concurrency
23 October 2019
Detailed example of execution reordering by the compiler
28 September 2019
Remove a folder - twice
How hard can it be to remove a folder in Windows? Part 4: random errors on empty folder
19 September 2019
Remove a folder - errors
How hard can it be to remove a folder in Windows? Part 3: errors
14 September 2019
Remove a folder - enumerate
How hard can it be to remove a folder in Windows? Part 2: enumerate while deleting
09 September 2019
Remove a folder - standard libraries
How hard can it be to remove a folder in Windows? Part 1: Using C++ standard libraries
20 April 2019
Survey of the available keyboards on the market; for the coder.
14 April 2019
The limits of TDD
TDD is a useful tool to have in programming. But it has limits.
04 April 2019
Brexit is not just a series of accidental shambles with large and long term negative consequences. It comes with an internal logic driven by ideology. The ideology is fundamentally flawed...
08 February 2019
The Unreasonable Effectiveness - reading notes
Reading notes on two papers on the subject of the unreasonable effectiveness of mathematics
21 January 2019
The Humble Programmer - reading notes
Reading notes on Dijkstra’s Turing lecture
18 January 2019
Premature optimisation - reading notes
Reading notes on Knuth’s article
09 January 2019
All we know takes less than 128 bytes
A surprising consequence of using SHA-1 in git.
01 January 2019
Books Read in 2019
List of books I’ve read in 2019
15 November 2018
std::string_view introduction and the dark corners of it’s usage
07 November 2018
Very short mathematics history. Also wrong, but approximately right.
19 September 2018
Regard classes with start and stop methods with suspicion
17 September 2018
Avoid too many smart pointers
Too many smart pointers considered evil
22 August 2018
The Annotated Turing
09 August 2018
Lower bound basics
Efficient find in a sorted range
07 August 2018
Partition point basics
Finding the partition point for a partitioned range
05 August 2018
Partitioning a range
03 August 2018
Swapping two values
01 August 2018
Linear find basics
Finding a value by linear traversal
29 July 2018
Min and max basics
Finding the smaller and the larger of two values, how hard can it be, right?
27 July 2018
Pragmatic StrictTotallyOrdered structs
How to implement comparisons for user defined data structures, using tie, before better reflection capabilities are added to C++
06 July 2018
On coding style
Applying writing style theory to code writing.
30 June 2018
Linked Lists - Implementing
Commented source code of what it would mean to implement the core of a linked list in C++.
28 June 2018
Linked Lists - Examples
Example of linked lists types.
23 June 2018
Linked Lists - Options
Catalogue of variations and implementation choices for linked lists.
06 May 2018
Efficient Programming with Components - Pearls
Alex Stepanov’s pontificative pearls from Efficient Programming with Components (A9 Videos)
03 May 2018
Reading thoughts on Steven Pinker’s book ‘Enlightenment Now’. Rating: 10 out of 10
12 April 2018
Destructors: Scope Guard
Using scope guard to perform one-off cleanups
18 March 2018
Destructors: Recommended Idiom for C++11/17
The C++11/17 recommended idiom for destructor exception safety for most C++ applications. Realistic cases of how to handle code that destructors call. Cosmic rays damaging CPU or memory and bugs...
16 March 2018
Destructors: Exception Safety Language Rules in C++11/17
Summary of the C++11/17 language rules related to destructor exception safety. We’ll look at the language rules as informal as possible without going into too much legalese.
15 March 2018
Error handling: provide two functions
One approach of dealing with the fact that sometimes exceptions are appropriate, sometimes error codes are better is to provide two related functions: one that throws, the other that returns...
09 March 2018
C++ FAQ - Zen Version
Zen version for frequently asked questions related to C++
07 March 2018
While writing generic code that can be reused is a great ideal, I claim that in practice there is a need to repeatedly implement similar functionality.
01 March 2018
File layout in a large project
File layout in a large project benefits from regularity. Here are some sample rules for a C++ project.
28 February 2018
This article looks at an idiom of wrapping C APIs that increases code reuse compared with the classic, slim and fat RAII variants described in previous articles.
29 January 2018
Boilerplate, metaprogramming, reflection in C++
Link to presentation slides @ ACCU Oxford - 29th January 2018
01 January 2018
Books Read in 2018
List of books I’ve read in 2018
11 October 2017
Counting Bits - Processor can do best
Counting the bits set: processor can do best
10 October 2017
Counting Bits - Better Adding bits in groups
Counting the bits set: better adding bits in groups
09 October 2017
Counting Bits - Adding Bits In Groups
Counting the bits set: adding bits in groups
08 October 2017
Counting Bits - Lookup
Counting the bits set: lookup methods.
07 October 2017
Counting Bits - Better Loop
Counting the bits set: the better loop approach.
06 October 2017
Counting Bits - Naive Loop
You have a 32-bit (unsigned) integer. Write a function to calculate how many bits are set. The naive implementation.
18 July 2017
C++ concepts basics
C++ concepts (N4647): cover the basics and show how they relate to templates (the “peel off onion layers” technique).
24 June 2017
Unexpected leftover from C hits back.
09 June 2017
Unordered hash conundrum
If you expected to use thestd::tie trick to also implement the hash so that your type can be a key in a std unordered container … you’ll be...
10 March 2017
Using a tie in C++
There are two major uses for std::tie: simple implementation for comparison operators for user defined data structures and unpacking pair/tuples (e.g. return values).
22 February 2017
Noncopyable and unintended ADL
This is an in-depth look at the noncopyable class in the C++ boost libraries and the unintended argument dependend lookup (ADL) protection trick.
13 February 2017
Almost the opposite of a regular type is a class that cannot be constructed (except through a factory function that creates instances of such a class).
07 February 2017
Basic coding tools configs
Basic coding tools configuration: git, vim, tmux (to hit the ground running on a new system).
15 December 2016
EOP: Regular types and procedures
Short intro into what regular types and procedures are about (as per “Elements of Programming”).
14 December 2016
EOP: Implementing Fibonacci
Outline of how to implement a function to calculate a value in a Fibonacci series.
06 December 2016
EOP: Programming is science
The first in a series of articles on Alex Stepanov’s awesome book “Elements of Programming”, looks at a basic, but the most important idea in the book.
26 September 2016
Bayes' theorem for the layman
Bayes’ theorem: what it is, a simple example, and a counter-intuitive example that demonstrates the base rate fallacy.
18 September 2016
Beautiful maths: Euler's formula
Starting with power series and building on derivation, factorials, exponential function, trigonometry and complex numbers we’ll get to Euler’s formula; some of the most beautiful mathematics I’ve seen coming together....
20 July 2016
Spot the Event Handler Bug
Sometimes there is a significant gap between the intent of the code and what it actually accomplishes, as this event handler code shows. Try to spot the bug in the...
29 June 2016
Metaphoric programming: link to presentation slides @ ACCU Oxford - Lightning Talks - 29th June 2016
10 June 2016
One to one makefile
Example of makefile building one executable for each C++ file in a folder.
09 June 2016
Starter C++ Project makefile
Example of initial makefile for a simple C++ toy project
19 April 2016
Dependency Injection Using Templates and Concepts
Experiment wtih adding C++17 concepts/requirements to the dependency injection with templates example.
07 April 2016
C++ std::move and std::forward
C++ std::move does not move and std::forward does not forward. This article dives deep into a long list of rules on lvalues, rvalues, references, overloads and templates to be able...
29 March 2016
Special class operations. Comparing
This article looks at the next layer of fundamental behaviour of a class: how two instances compare (for equality and order).
27 March 2016
Special class operations. Declarative nature
A look at the dual imperative and declarative nature for the copy and move behaviour in the light of compiler optimisations.
26 March 2016
Special class operations. Lifetime examples
A few example of customizing constructor, destructor, copy and move operations.
25 March 2016
Special class operations. Lifetime syntax
This article looks at how we can define in C++ the most fundamentals behaviour of a class: what it does when it’s created, copied, moved and destroyed.
11 March 2016
Controlling the controller
Demonstration of the software stack I’m using for a project to manage a micro-controller using a web browser user interface.
27 January 2016
Microsoft Band - Review
Microsoft Band is a wearable device well designed for fitness activities, but with a few rough edges.
08 January 2016
Anthropomorphic design is an antipattern where developers design software components as if they were people.
22 December 2015
Software Engineering Misjudgements
This is a take on Charlie Munger’s collection of human misjudgements.
06 December 2015
A expression as simple as severity > 2 can mean different things with respect to when the intended expression is evaluated.
05 November 2015
C++ Class Taxonomy
Following the idea of describing and cataloguing organisms in biology, let’s have a look at various types of C++ classes. There’s a whole zoo out there.
04 November 2015
Dependency Injection - Conclusion
Summary of the issues around dependency injection discussed in the previous articles.
02 November 2015
Alternative Dependency Grouping
When reducing dependencies we usually have several ways of grouping dependencies.
01 November 2015
Dependency Injection Using Templates
Using C++ templates to implement dependency injection.
31 October 2015
Dependency Injection Using Interfaces
A look at what is dependency injection, and how to implement constructor injection in C++ for member variables of a class, using interfaces with virtual functions.
30 October 2015
Reducing dependencies is a fundamental refactoring technique. It addresses the problem of too many dependencies by introducing additional abstractions, where each abstraction in turn is smaller and simpler.
29 October 2015
Dependencies - The Problem
Sometimes a C++ class grows too big and complex, dealing with too many issues, to the point where it is difficult to reason about it and test it. This article...
04 October 2015
GertDuino Board Setup
Initial setup steps for a GertDuino board with an existing Raspberry Pi 2 system, and solve the Raspbery Pi reboot problem.
08 April 2015
Spot the Multi-Threading Bug
Multi-threading is difficult to get right even for the seasoned developer, a common source of “mostly works” type of program. Try to spot the bug in the example below.
02 April 2015
Not all the parts of a C++ class have the same lifespan. Distinct steps are executed in sequence in the order to build or cleanup a C++ class instance.
31 March 2015
This short article reminds that C++ structs are classes too.
25 March 2015
RAII vs finally
C++ does not have a finally construct and I believe this is a good thing. Bjarne Stroustrup explains that “in realistic systems, there are far more resource...
23 March 2015
This article looks at handling errors in C APIs using an all-singing-all-dancing approach that uses a fatted up RAII variant.
22 March 2015
This article looks at handling errors in C APIs using an if-error-return coding pattern which uses a slimmed down RAII variant which is sometimes useful.
17 March 2015
RAII (Resource Acquisition Is Initialization) is a difficult to say name that does not do justice to one of the most useful programming idioms. This article describes the classic way...
15 March 2015
If Error Goto
This article looks at handling errors in C APIs using an if-error-goto coding pattern which is an improvement over the if-error-else variant.
14 March 2015
If Error Else
This article looks at handling errors in C APIs using an if-error-else coding pattern. It describes the issues and options when using this coding style, with the full example of...
12 March 2015
Copy File No Error
This short article proposes a simple example that copies the contents of a file to another, with no error handling. Future articles will use this example as a base of...
06 March 2015
This article looks at the options for implementing objects in the C language from the C API user’s point of view. This is the first from a series of articles...