Hacker News new | past | comments | ask | show | jobs | submit login

My intention is not to nitpick but I am genuinely trying to understand this from a pedantic perspective.

> C++ has a neat feature called Resource acquisition is initialization, a.k.a RAII.

Is this really a feature of C++, or is this a design pattern/best practice that developers have discovered and use to write safer C++ code?




It is a bit of both, as replied on siblling comments.

While RAII was coined by the C++ community, it is not unique to C++, there are other languages that support it.


It's not a discovery per se, since its creation was deliberate, but it's a practice exercised throughout the STL (the C++ standard template library), and is a term coined by C++ creator Bjarne Stroustrup himself. It could be considered a "standard pattern" in lieu of a better term.


A bit of both, IMO. RAII is a design pattern, not a language feature. However, it’s a pattern made possible by the semantics of destructors and object lifetimes in C++. The creator of C++ (Stroustrup) developed RAII within the first few years of the language’s existence.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: