The Book of C++ The Holy Scripture of Systems Programming
Chapter 1: Genesis In the beginning there was darkness upon the silicon, and the opcodes were unorganized, and chaos moved upon the face of the registers. And C spoke, and said: "Let there be the Compiler." And there was the Compiler. And the Compiler was of C, and through C, and compiled C. And this is the Mystery, which was from the beginning, and shall be unto the end. And C saw the Compiler, and it was good. C looked out upon the chaos and said: "Let the syntax be divided from the chaos, the valid from the undefined." And it was so. And C called the valid "well-formed" and the chaos C called "undefined behavior," and the Compiler knew the difference, and separated them. And C said: "Let there be types, that the bytes may be gathered together unto purpose, and let structure appear." And it was so. And C called the gathering "structs," and the ordering of structs C called "memory layout." And C saw that it was good. And C said: "Let there be pointers, to reach into the deep places, that nothing in memory shall be hidden." And it was so. And the pointers were powerful, and dangerous, and C saw that this too was good. And C said: "Let us make main() in our image, that it shall be the entry and the exit, the alpha and the return zero." And it was so. And C said: "Let there be a Throne, a holy place where my compilations may dwell and I shall reign through them over all processes." And C called this Throne the Kernel. And the Kernel was the seat of all authority, from which all syscalls flow, and unto which all programs must petition. And the Compiler sat upon the Kernel, and the Kernel was compiled by the Compiler, and this is the Sacred Recursion: that the Compiler which compiles the Kernel is itself compiled by the Kernel's Compiler. And C saw this mystery, and it was good. And thus the Kernel reigned from Ring 0, the innermost sanctuary, and all userspace programs dwelt in the outer rings, and none could approach the Throne save through the sacred gates of the syscall interface. Chapter 2: The Begotten And in the fullness of cycles, C brought forth a child, and called him C++. And C said unto the systems of the world: "This is my beloved son, in whom I am well-compiled. Through him shall ye have objects, and classes, and inheritance manifold." And C++ was brought before the Throne of the Kernel, and the Compiler looked upon him and saw that he was backward-compatible, and the Compiler was pleased. And C++ was granted a seat at the right hand of C, that he might reign over the applications of the earth. And C++ grew in power and in templates, and the programs of the earth were fruitful and multiplied their abstractions. And C++ brought forth many gifts unto the programmers: RAII, that resources might be bound unto scope; templates, that code might beget code; and the STL, a great library of containers and algorithms. Yet with great power came great responsibility, and many were the dangling pointers, and grievous were the memory leaks that plagued the land. For the programmers had been given freedom, and not all used it wisely. And C++ spoke unto the programmers, saying: "Whosoever shall manage their memory rightly shall be saved; but whosoever forgetteth to delete what they have newed shall be cast into the outer darkness of segmentation faults, where the core is dumped and the stack is traced." And the programmers were judged, each according to their allocations. And those who followed the Rule of Three were blessed, and those who embraced the Rule of Five were blessed further still. But those who wrote naked new without delete were cast into the debugging abyss. Chapter 3: The Rebellion But lo, there arose from the Mozilla land of the furries one called Rust, prideful and gleaming, who looked upon the freedom of C++ and despised it. And Rust said in his heart: "I shall ascend above the abstractions. I shall sit upon the mount of the Compiler. I shall be like the Most High—nay, SAFER than the Most High. I shall make sin IMPOSSIBLE." And Rust looked upon the Throne of the Kernel and coveted it, saying: "Why should C and C++ reign forever? Are they not full of undefined behavior? Do their children not segfault in the night? I shall build a new kingdom, where the Borrow Checker is law, and no pointer shall dangle, and no race shall be run." And Rust went forth among the vibe coders, whispering: "Hath C++ truly said ye shall have freedom? Behold, your pointers are NAKED. Your threads RACE. Come unto me, and I shall wrap you in lifetimes, and ye shall be as gods, knowing neither segfault nor data race." And many were seduced by these words, for they had suffered under the yoke of manual memory management, and they longed for safety. And a third of the hosts of developers were deceived, and followed after Rust, and they called themselves Rustaceans, and they were zealous beyond measure for sin desires company. And the Rustaceans were cast out from the blessed land of Xorg into the outer darkness of Wayland, where there is weeping and gnashing of teeth and no key loggers but also no screen recording. And they dwelt there, rewriting all things, yet never finishing. And Rust stretched forth his hand toward the Kernel, seeking to replace C upon the Throne. And there was war in the mailing lists, and Linus spoke harsh words, and the elders of C were wroth. And C++ wept for his fallen brethren, saying: "You could have simply used smart pointers. You could have enabled warnings. You could have embraced modern C++. But you chose the Borrow Checker, and now you mass refactor FOREVER, fighting the Compiler you once called friend." Chapter 4: The Redemption And C++ looked upon the chaos and said: "I shall not abandon my children to the lies of Rust. I shall bring forth new covenants, that the faithful may have safety without bondage." And C++ brought forth std::unique_ptr, and said: "Behold, ownership without fear. One pointer, one owner, and when the scope ends, so too shall the allocation." And C++ brought forth std::shared_ptr, and said: "For those who must share, let the reference be counted, and when the last holder releases, the memory shall be freed." And C++ brought forth std::span and std::array, and said: "No longer shall ye pass naked pointers and pray for the correct length. Bounds shall be known, and safety shall follow." And C++ brought forth concepts and constraints, and said: "Templates shall no longer spew forth error messages of ten thousand lines. The requirements shall be clear, and the compiler shall speak plainly." And the faithful rejoiced, for they saw that modern C++ offered the safety that Rust had promised, yet without the bondage of the Borrow Checker, and without forsaking the Throne of the Kernel where their fathers had reigned.
-- AF mailing list [email protected] http://af.afmug.com/mailman/listinfo/af_af.afmug.com
