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 …

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 …

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 …

C++ hack: explicitly hiding names

Sometimes you’ll encounter situations where a variable is still in scope, but cannot legally be accessed anymore. A typical example is if the variable has been moved from and we want to make sure we don’t accidentally reference it again, but there are other examples as well, for example …

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 …

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 …