The Fastest Mutexes by Justine Tunney (discussed on Hacker News) is an excellent work digging into the performance of commonly used mutex implementations, and presenting a new fast mutex in Cosmopolitan Libc. This kind of stuff underpins virtually every piece of software written, but it is …
C++ initialization footguns and how to avoid them
I Have No Constructor, and I Must Initialize (Hacker News discussion) goes into the gnarly details of initialization in C++, and all the immense, immense complexity and edge cases around it. As the top-voted comment on HN put it:
After almost 20 years of experience with C++, there are still some …
Order book in Rust: fixing the undefined behaviour
In the last post of the Implementing order books in C++ and Rust series I have proposed an unsafe Rust solution. Unfortunately, that solution turns out to invoke undefined behaviour (UB) due to violating the stacked borrows model of Rust. It does appear to work perfectly fine at the moment, but UB …
The hell of C++ modules
I’ve known from the moment that C++ modules were introduced that the whole thing is the kind of good-idea-turned-into-cursed-“solution” that only a C++ developer could have ever come up with. It has all the hallmarks: it tries to solve a well understood, already solved problem (see …
Linear types and how they let you control the future
Higher RAII, and the Seven Arcane Uses of Linear Types (discussed on Hacker News) introduced me to the concept of linear types and how they can be useful. It turns out: they can be extremely useful, because you can use them to make a promise to do something to the compiler, and it will hold you to …
Comparing implementations of std::string
Highly recommended reading for C++ developers: An informal comparison of the three major implementations of std::string (discussed on Reddit and Hacker News), which goes into how std::string is implemented by the 3 major compilers: GCC (libstdc++), MSVC, and Clang (libc++), and what design choices …
93% of Paint Splatters are Valid Perl Programs
93% of Paint Splatters are Valid Perl Programs (discussed on Hacker News) made me laugh, it is the kind of high-quality trolling that the field of computer science could definitely use more of. It is actually a scientific paper accepted by the SIGBOVIK 2019 conference, and that is glorious.
In this …
The Wisdom of James Mickens
I am here to talk to you non-believers about The Wisdom of James Mickens. At least those of you who are software developers or would vaguely identify yourselves as “computer scientists”, whatever that might mean.
James Mickens offers his timeless insights for free, because he loves you …
Arguing against accessor functions
One of the unpopular opinions I’ve long held in programming is that accessor methods (getters and setters) are a terrible practice. Now that I have found somebody who agrees with me (timestamps 1:13:06 to 1:16:25) I am ready to write about this!
This is what I mean (C++ code, but the same …
Implementing order books in C++ and Rust - part 3/3
In the previous part we have started working on our Rust orderbook re-implementation of the C++ original, and defined the types Order and OrderKey<Side>, where Side is a type implementing the OrderbookSide trait: either Bid (for buy orders) or Ask (for sell orders).
Defining OrderHandle …
Configuration knobs considered harmful (Abseil blog)
I found the recent Abseil article Performance Tip of the Week #52: Configuration knobs considered harmful to be insightful. Most people, developers included, would generally prefer more flexibility and configurability over less, but as the article points out, configuration options (flags) carry …
Graphs are hard
The Hunt for the Missing Data Type (discussion on Hacker News) is an article exploring why are graph implementations so rare while graph problems are so common:
I see graphs everywhere and use them to analyze all sorts of systems. At the same time, I dread actually using graphs in my code. There is …
Implementing order books in C++ and Rust - part 2/3
In the previous part, we have sketched out the structure of implementing a simple order book in C++, supporting order insertion and efficient cancellation. (Implementing uncrossing, that is, trades when a buy order and a sell order agree on a price, is an exercise left to the reader, as is …
Implementing order books in C++ and Rust - part 1/3
A fairly standard programming problem in the world of trading is building an order book. In this article, I will be showing one particular interesting aspect of this problem, and how to solve it in C++. In the next two parts, we will be trying to implement the same solution in Rust.
This is meant to …
Rust oddness: integer literal references?
I’m following Rust by Example to finally get into Rust properly, after several years spent as a primarily C++ developer. So far, most things have made sense to me, and I have been blown away by the compiler diagnostics: they are accurate and useful, which anybody with some C++ experience will …
Passing a struct of 3 or more words is slow on AMD64
I did not realize that the AMD64 ABI specifies a silly calling convention rule that forces structs with 3 or more word-sized (i.e. 8-byte) fields to be passed by pointer, even if you write your code expecting to have it be passed by value. I learned this from: Speed up your code: don’t pass …
Measuring work performance
In The value of your work I have talked about how in a job, work is useful for your individual career only if your manager deems it so, even though that is not always the same thing as what is valuable for your team or your organization. In fact, it is rather difficult to come up with a good, …
The frame pointers strike back
Interesting: Ubuntu 24.04 LTS will enable frame pointers by default, following Fedora which made the same change in version 38. In short: GCC will by default start emitting frame pointers again as if using -fno-omit-frame-pointer, which helps debugging and profiling tools a bit, at the cost of what …
The value of your work
2023-12-14
Work is valued if and only if it is something that management (or whoever evaluates your performance) cares about, which does not necessarily have to be in any way related to how much real value it provides.
Have you fixed a bug or introduced a feature that helps every software developer …
Recovering from segmentation faults
This is brilliant: Cleanly recovering from Segfaults under Windows and Linux (32-bit, x86).
I do not think I’d want to actually use this in production, for the same reason that the article itself points out: segmentation faults often indicate that something has gone horribly wrong inside the …
C++ vs Rust: performance vs safety
I was reading Why I think C++ is still a desirable coding platform compared to Rust on Low Latency Trading Insights, and wanted to share my thoughts. Overall, I really appreciate this article: it raises a very important subject and makes lots of good points. I do disagree with some of it, though I …
C++ language philosophy
C++ is one of the oldest mainstream programming languages in use today, and also easily one of the most controversial ones: some people love it (including myself), but if you read any online forums, you’d easily be under the impression that most people despise it.
The criticisms are, more …
Simultaneous multi-threading: priority signalling
I’ve encountered a statement today in a random blog post about the IBM PowerPC 600 series that broke my brain for a minute while I was trying to figure out what it could possibly have meant, so now I’m going to subject you to it as well. Here goes:
Moving a register to itself is …
A guide to error-handling
Error-handling is a heavily debated topic. Generally speaking, the following mechanisms exist to handle errors when implementing a function:
Return something to indicate the error: an error code, a sentinel value (like NaN), or using a result-or-error type (like C++’s std::expected or …
PRQL: it's like SQL but actually makes sense
I have never had to write particularly complex SQL queries, but I’ve written and seen enough to know that that SQL gets nasty and complicated once you start using the non-trivial features, not to mention things like optimizing queries based on the execution plan, or optimizing indexes, or the …