HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
fmtlib
fmt
C++2015–2026
fmtlib / fmt

fmt

A modern formatting library

32Distinct people
53Mentions
0Explicit recommenders
26KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A modern formatting library

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 8–Nov 15 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/15/2026, 12:45:45 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year53 dated mentions

Observed mentions: 2015-02-10 11:13:33 UTC to 2026-05-13 13:22:09 UTC.

0369122015-01-01 00:00:00 UTC to 2016-01-01 00:00:00 UTC (exclusive): 2 mentions; 2 submissions, 0 comments20152016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 comments2017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 3 mentions; 1 submissions, 2 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 6 mentions; 2 submissions, 4 comments20202021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 11 mentions; 0 submissions, 11 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 5 mentions; 1 submissions, 4 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 8 mentions; 2 submissions, 6 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20152015-01-01 00:00:00 UTC2016-01-01 00:00:00 UTC220
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC413
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC312
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC202
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC303
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC624
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC404
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC202
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC11011
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC514
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC826
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC303

What Hacker News says

11 sources
> This is from C++23, right? std::println is, yes. > I wonder how available this is within compilers https://en.cppreference.com/w/cpp/compiler_support says clang, gcc, and msvc all support it, though I don't know how recent those versions are off the top of my head. In my understanding, with this specific feature, if you want a polyfill for older compilers, or to use some more cutting-edge features that haven't been standardized yet, https://github.com/fmtlib/fmt is available to you.
In Learn Modern C++
<iostreams> are currently a good example of pure product of the 199X/2000s when the hype about Object Oriented was around its peak. Almost everything related to c++ iostreams has this code smell of OOP pushed too far: - Usage of runtime virtual dispatch with virtual calls when it was not necessary. Causing a negative unavoidable impact on performance. - Heavy usage of function overloading with the "<<" operator. Leading to pages long compilation errors when an overload fails. - Hidden states everywhere with the usage of state formatters and globals in the background. - Unnecessary complexity with std::locale which is almost entirely useless for proper internationalisation. - Bloat. Any statically compiled binary will inherit around ~100k of binary fat bloat when using iostream - Useless encapsulation with error reports done as abstracted
Read the rest
bit flags. Which is absolutely horrendous when dealing with file I/O: It hides away the underlying error with no proper way to access it. - Deep class hierarchy making the entire thing looks like spaghetti. - Useless abstraction with stringstream that hides the underlying buffer away, making it close to unusable on embedded safety critical systems where memory allocations are forbidden. All of that made <iostreams> aged pretty badly, and for good reasons. Fortunately there is an incoming way out of that with work of Victor Zverovich on std::format and libfmt [1]. [1]: https://github.com/fmtlib/fmt
In For processing strings, streams in C++ can be slow
I like C much more than C++, but even with that must say that https://github.com/fmtlib/fmt is pretty nice (which is the base for std::format). Together with pystring (https://github.com/imageworks/pystring) it makes string processing in C++ somewhat bearable (pystring is slow though because it still uses the std::string type which excessively allocates, but at least it's convenient compared to 'raw' C++ string functionality).
In For processing strings, streams in C++ can be slow
I noticed std::format and std::print aren't even available with my pretty up-to-date compilers (testing Debian bookworm gcc/clang right now). There is only https://github.com/fmtlib/fmt but it doesn't seem prepackaged for me. Have you actually used std::format_to_n? Did you go through the trouble of downloading it or are you using C++ package managers? I'm often getting the impression that these "you're a fool using these well-known but insecure libraries. Better use this new shiny thing because it's safe" discussions are a bit removed from reality. But I'm asking in earnest. Please also check out my benchmark in the sibling thread where I compared stringstream with stdio/snprintf build performance. Would in fact love to compare std::format_to_n, but can't be arsed to put in more time to get it running right now.
In C++23: The Next C++ Standard
> It haven't written C++ recently, but I recall that you can use ostringstream in place of ostream. I don't know about those specifically right now, but in general these things have huge compile time costs and are also generally less ergonomic IMO. [EDIT: cobbled together a working version and added it to my test below, see Version 0]. > About "sigh of despair" and "sigh of relief": Are you expressing concern about the template function signature? Yes. It's a mouthful, and I'm worried not only about static checks but about other things too -- like readability of errors, include & link dependencies, compile performance, amount of compiled code (which is minimal in case of snprintf/varargs)... I would need to check out std::format_to_n() as suggested by the sibling commenter. And hey -- snprintf has been available for easily 30+ years ... w
Read the rest
hile the <print> and <format> headers that people make such a fuss about, don't even seem available on gcc nor clang on my fully updated debian bookworm system. The reason is that those implementations aren't complete, even though <format> is C++20. The recommended way to get those headers is to grab https://github.com/fmtlib/fmt as an external library... Talk about the level of hype and lack of pragmatism that's going on around here. People are accusing each other for not using a standard library that isn't even implemented in compilers... And with a likelyhood they haven't used the external library themselves, and given that this library is external it's not heavily tested and probably contains bugs still, maybe CRASHES and SECURITY EXPLOITS. But let me test C++ features that actually exist: #if VERSION == 0 #include <iostream> #include <streambuf> struct membuf: std::streambuf { membuf(char *p, size_t size) { setp(p, p + size); } size_t written() { return pptr() - pbase(); } }; int main() { char buffer[256]; membuf sbuf(buffer, sizeof buffer); std::ostream out(&sbuf); out << "Hello " << 42 << "\n"; fwrite(buffer, 1, sbuf.written(), stdout); return 0; } #elif VERSION == 1 #include <sstream> #include <iostream> void test(std::stringstream& os) { os << "Hello " << 42 << "\n"; } int main() { std::stringstream os; test(os); std::cout << os.str(); return 0; } #elif VERSION == 2 #include <stdio.h> int test(char *buffer, int size) { int r = snprintf(buffer, size, "Hello %d\n", 42); return r; } int main() { char buffer[256]; int len = test(buffer, sizeof buffer); fwrite(buffer, 1, len, stdout); return 0; } #endif Compile & link: CT LT TT PT PL -DVERSION=0 0.361s 0.095s 0.456s 0.081s 32573 -DVERSION=1 0.364s 0.089s 0.453s 0.074s 32338 -DVERSION=2 0.039s 0.088s 0.127s 0.031s 918 CT=compile time, LT=link time, TT=total time (CT+LT), PT=preproc time (gcc -E), PL=preprocessor output lines Bench script: # put -DVERSION=1 or -DVERSION=2 as cmdline arg time clang++ -c "$@" -Wall -o test.o test.cpp time clang++ -Wall -o test test.o time clang++ "$@" -Wall -E -o test.preprocessed.txt test.cpp wc -l test.preprocessed.txt My clang version here is 14.0.6. I measured with g++ 12.2.0 as well and the results were similar (with only 50% of the link time for the snprintf-only version). For such a trivial file, the difference is ABYSMAL. If we extrapolate to real programs we can assume the difference in build times to be 5-10x longer for a general change in programming style. Wait 10 seconds or wait 1 minute. For a small gain in safety, how much are you willing to lose? And how much do this lost time and resources actually translate to working less on the robustness of the program, leaving more security problems (as well as other problems) in there? And talking about lost run time performance, that is real too if you're not very careful. > For snprintf(), how do you ensure that your format string and variadic arguments will not cause crash at runtime? The C++ version is compile-time type safe. Honestly I just don't ensure it perfectly -- beyond running them once as described. I write a lot of code that isn't fully proofed out from the beginning. Exploratory code. A few printfs are really not a concern in there, there are much bigger issues to work out. I also absolutely do have some printfs that were quickly banged out but that are hidden in branches that have never actually run and might never happen -- they were meant for some condition that I'm not even sure is possible (this happens frequently when checking return values from complicated APIs for example). The real "problem" isn't that there is a possibly wrong printf in that branch, but that the branch was never tested, and is likely to contain other, much worse bugs. But the fact that the branch was never run also means I don't care as much about it, pragmatically speaking. Likely there is an abort() or similar at the end of the branch anyway. It's always important to put things into perspective like that -- which is something that seems often missing from C++ and similar cultures. The more proofed out some code gets, the more scrutiny it should undergo obviously. Apart from that, compilers do check printfs, and I usually get a warning/error when I made a mistake. But I might not get one if I write my own formatting wrappers and am too lazy to explicitly enable the checking.
In C++23: The Next C++ Standard
iostreams are horrible to use, especially if you want to format your output and they blow up compilation to a mythical degree. People go to great lengths to avoid them and I agree with them. print/println are based on the fmt library (https://github.com/fmtlib/fmt), which had it's first release in 2015, so it's roughly as old as Rust afaik. It's mainly inspired by Python formatting. Having per-type formatters is just a logical conclusion of having type-safe formatting. iostreams are for all kinds of io (which includes stdin/stdout), while fmt is entirely dedicated to formatting strings. Those things are related, but not the same. cout and cerr and such will probably be entirely superseeded by print/println (I hope), but it doesn't make iostreams generally redundant. println adds a newline and you want to be able to choose, so there is pri
Read the rest
nt and println.
In C++23: The Next C++ Standard

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.