C++ exception (2) — throwing an exception

This is the second post of a series that 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 (1) — zero-cost exception handlingThis is the first post of a series I am making…

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 [https://en.wikipedia.org/wiki/Application_binary_interface] 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…

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

`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 { int x; }; void stack(…

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

Fiber-compatible Future

folly [https://github.com/facebook/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.md But how does it…

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…