Evolution of printf

C:
printf("%d %d\n", x, y);
C++98: “don’t use printf, use type-safe, extensible i/o streams!”
std::cout << x << " " << y << '\n';
C++20: “all right all right, you can format as before”
#include <format>
std::cout << std::format("{} {}", x, y);
C++23: ”ok fine, you can have your printf back”
#include <print>
std::println("{} {}", x, y);
Published at
2026-07-01 13:59:39 UTCEvent JSON
{
"id": "0a7b884ac17af34be4e8a77849c688e15ac0a820757c0bc6901e5beae60cbc0e",
"pubkey": "d4dba46e95b5a924f957132a8fbb0072edd3c14709cdadd70d69bfbe6e2d3cef",
"created_at": 1782914379,
"kind": 30023,
"tags": [
[
"client",
"Yakihonne",
"31990:20986fb83e775d96d188ca5c9df10ce6d613e0eb7e5768a0f0b12b37cdac21b3:1700732875747"
],
[
"published_at",
"1782914379"
],
[
"d",
"eQ5d-j5igI2SDtRl_m0cv"
],
[
"image",
"https://image.nostr.build/0efd3afe48a896ae2a5076e43529c999e678bc8576f9fc43aca1cedf0828b1b5.png"
],
[
"title",
"Evolution of printf"
],
[
"summary",
"printf over the years"
],
[
"t",
"C++"
]
],
"content": "C:\n\n```c\nprintf(\"%d %d\\n\", x, y);\n```\n\nC++98: “don’t use printf, use type-safe, extensible i/o streams!”\n\n\n```cpp\nstd::cout \u003c\u003c x \u003c\u003c \" \" \u003c\u003c y \u003c\u003c '\\n';\n```\n\nC++20: “all right all right, you can format as before”\n\n```cpp\n#include \u003cformat\u003e\n\nstd::cout \u003c\u003c std::format(\"{} {}\", x, y);\n```\n\nC++23: ”ok fine, you can have your printf back”\n\n```cpp\n#include \u003cprint\u003e\n\nstd::println(\"{} {}\", x, y);\n```\n",
"sig": "1ab28a5205d7e1e7d1b3c4d2cfab629e61eb1b485a28c433a37cd203a69feeac38d456612e58398458811188b03ba084f87049a951ea338a67421e583b532635"
}