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 …
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 …
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 …
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 …