Parse, don't validate through the years with C++
Summary
This piece revisits the parse, don't validate paradigm using a C++ date parser as a running example, showing how enforcing invariants with types across the evolution from C++98 to C++23 can prevent downstream validation bugs. It presents four rounds of implementations: a minimal C++98 approach with hand-parsing; a C++11 version introducing safer API design; C++17 using string_view and optional to eliminate exceptions; and C++23 leveraging std::expected for explicit error information. The article also discusses memory management, exception handling, the tradeoffs between safety, readability, and performance, including a benchmarking section comparing compilation times across standards. It closes with observations on the role of strong typing, language features, and AI-assisted code drafting in building robust parsers for small and medium businesses.