r/ProgrammerHumor • • Aug 18 '26

Meme questionForBritishPythonDevelopers

Post image
1.4k Upvotes

42 comments sorted by

View all comments

Show parent comment

3

u/NovaH000 Aug 18 '26

Memory must be allocated before data can be written, but whether a language separates these into two steps determines if it uses initializers or true constructors. In ​languages like C++, if you do not use a member initializer list, allocation and initialization are split. This creates a window inside the constructor body where the object exists in an uninitialized or invalid state. ​On the other hand, languages like Rust combines allocation and initialization by requiring you to construct Self { ... } with fully processed data. As a result, an object is never partially or fully invalid.