Rust's early vs. late lifetime binding

Lifetime in many ways are similar to types but also different. The goal of this post is to explain my mental model of rust's lifetime binding works, when it takes place, and a trick to force late lifetime binding when needed. Here's a motivating example that I will use throughout…

zsh interprets a standalone redirect as a `cat` command

I use zsh and yesterday I was testing a program with myprogram 2>/dev/null. In one iteration, I accidentally copied a newline character after the myprogram command and the zsh prompt looked something like $ myprogram 2>/dev/null The program appeared to hang after printing out the expected output.…

C++ coroutine and lambda's lifetime

We rarely need to worry about lambda's lifetime more than any other objects in C++ until we are dealing with coroutine at the same time. folly's wiki has a good example of why we need to be careful about lambda's lifetime – https://github.com/facebook/folly/blob/main/folly/experimental/…

`folly::IOBuf` and zero-copy networking

I see folly::IOBuf often used as a return value (sub-)type in RPC definitions for data intensive and high performance applications. I looked at the code, and it says Well if it's used primarily for networking code, why do applications use it? I don't think people use sk_buff…

What I learned about `inline` recently

C++'s inline is pretty nice, in my opinion. I define an inline function with external linkage, things work as expected (https://en.cppreference.com/w/cpp/language/inline): * taking the address of the inline function works * function-local static objects work as expected (shared across all translation units) * no ODR…

`ssh` to my workstation over Internet

I have eero at home with eero plus subscription as I like the parental controls. To my delight, the subscription also comes with DDNS. I wanted to set it up so I can ssh to my workstation from a laptop from our town library or a coffee shop. 1. Enabled…

What Good Are Impossibility Results

Here is the section 3.5 of Nancy Lynch's 1989 paper – A Hundred Impossibility Proofs for Distributed Computing, which is profound: What good are impossibility results, anyway? They don't seem very useful at first, since they don't allow computers to do anything they couldn't previously. Most obviously, impossibility results tell…

Caching Partially Materialized Views Consistently

Cache and Materialized View According to the PostgreSQL wiki, A materialized view is a table that actually contains rows, but behaves like a view. That is, the data in the table changes when the data in the underlying tables changes. According to Wikipedia, ... a materialized view is a database object…