🖨️ {fmt} — The C++ formatting library that should have existed from the start
Every C++ developer knows the pain.
`printf` is fast but unsafe — wrong format string, undefined behavior. `std::cout` is safe but verbose and slow. For decades there was no good middle ground. 💀
📦 Header-only & drop-in simple
One header, done. No build system changes, no heavy dependencies. No coincidence — spdlog uses {fmt} under the hood.
fmt::print("Connection from {} on port {}", ip, port);
Readable. Clean. No << chaos.
⚡ Faster than printf
Sounds too good to be true — but it's benchmarked. {fmt} beats printf in most cases because it knows more about types at compile time and decides less at runtime.
🛡️ Type-safe & compile-time checks
The real game changer:
fmt::print("{} {}", name); // ❌ Compile Error — argument missing
With printf that would have been silent undefined behavior. With {fmt} it breaks at compile time. Exactly where errors should be caught.
🔗 The red thread to C++20
{fmt} became so good it served as the blueprint for std::format in C++20. Using {fmt} today means learning the future of the C++ standard library at the same time.
🐧 printf was yesterday. cout is verbose. {fmt} is what C++ formatting should have always been.