Get the latest tech news

Honey, I shrunk {fmt}: bringing binary size to 14k and ditching the C++ runtime


The {fmt} formatting library is known for its small binary footprint, often producing code that is several times smaller per function call compared to alternatives like IOStreams, Boost Format, or, somewhat ironically, tinyformat. This is mainly achieved through careful application of type erasure on various levels, which effectively minimizes template bloat.

This approach confines template usage to a minimal top-level layer, leading to both a smaller binary size and faster build times. Most notably, {fmt} now uses the exceptional Dragonbox algorithm for floating-point formatting, kindly contributed by its author, Junekey Jeon. We’ll apply the same methodology as in previous work, examining the executable size of a program that uses {fmt}, as this is most relevant to end users.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of C++

C++

Photo of runtime

runtime

Photo of Honey

Honey

Related news:

News photo

Scpptool – a tool to enforce a memory and data race safe subset of C++

News photo

Programming terrain from scratch using C++ and OpenGL by Shamus Young (2006)

News photo

An AI that unexpectedly modified its own source code