C++ exception (1) — zero-cost exception handling

This is the first post of a series I am making on C++ exceptions. C++ exception (1) — zero-cost exception handlingThis is the first post of a series I am making on C++ exceptions. C++ exception (2) — throwing an exceptionThis is the second post of a series that I am making…

Application Binary Interface from the Ground Up

ABI stands for Application Binary Interface. It includes a set of rules e.g. calling conventions. For a long time, I found the concept of ABI hard to grasp. I want to take a step back and see if we start from the ground up, where and why we would…

Fix Flickering Relay Switch caused by Nest Thermostat

About one month ago I noticed one relay switch was flickering from time to time at the zone control board. Narrow it downThe first step of debugging is to narrow the potential problem area down. Like any interesting (annoying) bugs, the problem doesn't happen all the time. So I waited…

`struct Foo f;` and `struct Foo f{};` are very different

Compare the following two programs, and can you predict what the outputs would be for each? // program #1 struct Foo { int x; }; void stack() { int x = 3; } void bar() { struct Foo foo{}; cout << foo.x << endl; } int main() { stack(); bar(); return 0; } // program #2 struct Foo…

Learning C++ Memory Model from a Distributed System's Perspective

If C++ standard were reworded using distributed system terms, it might be more readable. Your single machine is actually a distributed system in disguiseMultiple cachelines inside your multi-core machine make a distributed system. Cacheline coherence is 100% a distributed system problem. C++ tries to provide a high level abstraction for…

Fiber-compatible Future

folly's Future API is Fiber-compatible. Calling get() on a folly::Future object will only suspend the calling fiber-task. It won't block the system thread, letting it process other tasks. – https://github.com/facebook/folly/blob/master/folly/fibers/README.mdBut how does it actually work? E.g. what happens when…

DNS – the first distributed database

DNS was created in 1983. Before then, Stanford was storing the host name to IP address map on HOSTS.TXT, which obviously doesn't scale. DNS is the address book of the internet, which performs a simple function of translating domains to IP addresses. One way of looking at it is…

There's Nothing 100% in Computer Science

When it comes to correctness guarantees, there are few communities in Computer Science (software) more obsessed with them than the database and distributed system communities. They better be serious about correctness because everyone's bank account balances depend on it. You have heard about terms like Paxos, consensus, fault tolerance, but…