Mircea Baja's Posts
-
01 February 2024
Fix not required
An interesting lesson on C++ capabilities and complexity and an introspection on developer’s thinking process.
-
01 January 2024
Books Read in 2024
List of books I’ve read in 2024
-
23 June 2023
C++ coroutines
C++ coroutines lab presentations. WORK IN PROGRESS
-
20 April 2023
Computational models
Computational models from mathematics to software engineering
-
15 April 2023
Are the natural numbers real?
No. They are largely a human invention.
-
10 April 2023
Software Engineering
Software engineering is much more than coding: it’s dealing with other people and with uncertainties. Philosophical thoughts on situations that you might encounter as a professional developer.
-
06 April 2023
Shallow vs. deep
Brief note on terminology that is fine for describing an element of a class design, but not useful when deciding how to design a class.
-
02 April 2023
begin()
C++ standard library variations on obtaining the start iterator for a sequence (as of C++20-ish). Not all the begin()s are the same.
-
28 March 2023
The things we know
Algorithmic efficiency often has at its roots things we know, and therefore skip unnecessary calculations. Not all the things we know can be checked by the computer.
-
25 March 2023
The future of regular
It’s good and common to want to use regular data types. But still creating them is more difficult than it should be.
-
21 March 2023
Regular wannabes
There are all sorts of types that sometimes try to have regular characteristics. A taxonomy of regular types.
-
17 March 2023
Pragmatic Regular structs
How to implement Regular data structures, using the spaceship operator, before better capabilities are added to C++
-
13 March 2023
History of the spaceship operator in C++
How the three-way comparison, aka. the spaceship operator came to be in C++
-
05 March 2023
The many relations
Let’s get better at understanding relations (and I don’t mean the inter-personal ones) and they translate from mathematics to programming (C++ in particular).
-
01 January 2023
Books Read in 2023
List of books I’ve read in 2023
-
22 December 2022
History of concepts in C++
A brief history of concepts in C++
-
18 December 2022
Regular: syntax and semantics
What are the characteristics of a normal, regular data type?
-
14 December 2022
Rule of three and composing
Rule of three. Or rule of five. Or none of those rules: composing, interfaces, reference members and Pimpl.
-
11 December 2022
C++ move rationale
Why is C++ move not destructive and what does that mean? We see that the way move is implemented in C++ is only one of the ways of doing move....
-
08 December 2022
Templates and STL
Templates and STL come to C++.
-
05 December 2022
C++ comparison (first attempt)
The first attempt in C++ to handle equality and order: ask programmer to explicitly implement all comparisons operators.
-
02 December 2022
Exception safety, noexcept
Ideas on exception safety, leading to noexcept, in the context of the special operations of a type.
-
30 November 2022
C++ copy
Copy in C++.
-
27 November 2022
Default constructor
Some C++ constructors are special, the default constructor is one of them.
-
25 November 2022
C++ constructor, destructor and class
C++ introduces innovations such as constructor, destructor and class.
-
22 November 2022
C copy
C structs get copy, but not comparison.
-
19 November 2022
Struct from C
C++ got struct from C. The initial state of affairs. Memory, padding and first attempts at copy.
-
16 November 2022
History of normal type in C++
The ideas of regular data in C++ have a long and instructive history.
-
09 November 2022
Programming idiom remarks
Closing remarks on programming idioms. Divergence from idioms, smart pointers in the mocking interfaces idiom, threading issues. Programmer’s Occam’s razor.
-
05 November 2022
The C.12 rule on const
Coding guidelines are the Strunk & White for programming languages: famous, influential, in demand, but mediocre. A look at the C.12 rule on const usage from the C++ Core Guidelines....
-
02 November 2022
Const ref member: Yes
Are there cases where you might want a const reference member? Yes.
-
29 October 2022
Const ref member: No
Should you use const for the members that store the interface references in the mockable interfaces idiom?
-
26 October 2022
Idiom: Mockable interfaces
Mockable interfaces for easy testing.
-
23 October 2022
Idiom: C API wrapper
Wrapping C APIs in C++.
-
20 October 2022
Idiom: regular data and functions
Handling normal, pure data and functions.
-
17 October 2022
Programming idioms introduction
What are programming idioms?
-
14 October 2022
Wise quotes
“Gradually and then suddenly” and “All happy families are alike; each unhappy family is unhappy in its own way”
-
10 October 2022
The Intelligent Investor - reading notes
Despite the cheesy title, “The Intelligent Investor” by Benjamin Graham is one of the best investing books (if read carefully)
-
10 September 2022
The Interpretation of Financial Statements - reading notes
Reading notes on “The Interpretation of Financial Statements” by Benjamin Graham and Charles McGorlick
-
07 July 2022
Clean git
Effective use of git in the real world
-
29 June 2022
Fit RAII - revisited
Wrapping C API calls, improving the “fit RAII”.
-
04 June 2022
XMLHTTPRPCSerializer
How to handle acronyms in various programming naming conventions
-
31 May 2022
Unit tests: mocks, fakes and spies
Mocks, fakes and spies are techniques for isolating a subset of the component graph for unit tests
-
25 May 2022
Unit tests: Pure vs API tests
Not all the unit tests are pure calculation tests.
-
23 May 2022
Tests pyramid
Because of the cost versus reward, it makes sense to have a few system tests, some component tests and lots of unit tests.
-
20 May 2022
Recursive functions
What are recursive functions?
-
09 May 2022
2022 Russian invasion of Ukraine
Thoughts on what’s going on in Ukraine
-
09 January 2022
Dedekind cuts
Describing real numbers in terms of natural numbers
-
01 January 2022
Books Read in 2022
List of books I’ve read in 2022
-
30 December 2021
Carboniferous
All the coal was created in Carboniferous. Why?
-
09 October 2021
Examples 5 and 6
Examples 5 and 6 from Kleene’s IM (1952) page 149
-
30 September 2021
Deduction Theorem - Meaning
A brief discussion of the meaning of the deduction theorem
-
27 September 2021
Deduction Theorem - For predicate calculus
Deduction theorem for the predicate calculus
-
24 September 2021
Deduction Theorem - Dependence and variation
The dependent and varied terminology is meant to define some restrictions to applying some rules in predicate logic.
-
21 September 2021
Deduction Theorem - Free and bound
The free and bound terminology is meant to define some restrictions to applying some rules in predicate logic.
-
17 September 2021
Deduction Theorem - On subsidiary deductions
Notes on subsidiary deductions
-
15 September 2021
Deduction Theorem - For propositional calculus
Deduction theorem for the propositional calculus
-
01 September 2021
Deduction Theorem - Induction
Quick recap of induction
-
28 August 2021
Deduction Theorem - A implies A
Sample proof that A implies A
-
24 August 2021
Deduction Theorem - Sample formal systems
Sample family of formal systems for number theory
-
21 August 2021
Deduction Theorem - Mathematical logic
Basic introduction to how formal systems in mathematical logic came to be a thing
-
18 August 2021
Deduction Theorem - Introduction
Introduction to the deduction theorem
-
26 June 2021
Bikeshedding
“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
Chess notes
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
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
Freeman Dyson
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
C++11 volatile
A brief history of the meaning of volatile in C++
-
02 November 2019
C++11 synchronizes-with
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
Compiler reordering
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
-
16 September 2019
Remove a folder - registry enumeration digression
How hard can it be to remove a folder in Windows? Part 2 supplement: registry enumeration digression
-
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
Keyboards
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 Ideology
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 corners
std::string_view introduction and the dark corners of it’s usage
-
07 November 2018
Mathematics History
Very short mathematics history. Also wrong, but approximately right.
-
19 September 2018
Bad start
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
Book review
-
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
Partition basics
Partitioning a range
-
03 August 2018
Swap basics
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
Enlightenment Now
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
API Fragmentation
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
Fit RAII
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
Port 80
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
Protected constructor
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
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
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
Evaluation Timeline
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
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
Class Lifetime
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
Struct Classes
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
Fat RAII
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
Slim RAII
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
Classic RAII
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
C Objects
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...