How are data stored in a .gz format?

Gz format was created as an open source alternative to other compression formats, first released in 1992 with the zlib library as its reference implementation. Owing to its permissive licence, it has become one of the most widespread compression algorithms over the years, used for example as part of the HTTP protocol or in the .png file format. It is faster and easier to use than formats like 7zip, bz2 or xz, but its compression ratio is worse. Newer compression formats like zstd have both better compression ratio and better performance than .gz, but they are not used in common protocols.

You can define template methods in .cpp files without explicit instantiation, as long as they are private

For years I’ve been programming in C++ with the belief that the bodies of template methods had to be in headers. Only recently I learned that splitting template methods between header and source is, in fact, often perfectly fine.

C++20 Resumable functions: Goodbye state machines, no one will mourn you

C++20 allows writing functions that suspend and can continue at the next line. This has an amazing application at avoiding writing annoying and error-prone state machines. This article showcases how coroutines can clean up a function that would usually need an ugly state machine.

Error codes are far slower than exceptions

TL;DR On modern 64-bit PC architectures, C++ exceptions only add unreachable code with destructor calls into functions and their effect on performance is below 1%, but such low values are difficult to measure. Handling rare errors with return values requires additional branching that slows down the program in realistic scenarios by about 5% and are also less convenient. If an exception is actually thrown, stack unwinding costs about 2 ┬Ás per stack frame.