RAII Resource Management

The cluster focuses on discussions of RAII (Resource Acquisition Is Initialization), its role in C++ for automatic resource cleanup via destructors, comparisons to alternatives like try-finally, defer, or finally clauses in other languages such as Rust, Go, Java, and debates on its effectiveness and implementations.

➡️ Stable 0.6x Programming Languages
4,171
Comments
19
Years Active
5
Top Authors
#838
Topic ID

Activity Over Time

2008
9
2009
22
2010
42
2011
90
2012
155
2013
132
2014
201
2015
196
2016
195
2017
232
2018
277
2019
247
2020
396
2021
324
2022
422
2023
381
2024
352
2025
481
2026
17

Keywords

MS GoingNative e.g GC DOS ffi.gc RAII luajit.org LambdaType ffi.C raii resource object scope cleanup defer gc objects called function

Sample Comments

kqr Jun 3, 2018 View on HN

Because RAII isn't amazing?

jcelerier Jan 7, 2023 View on HN

but.. with RAII you don't either, that's the whole point

delian66 Apr 11, 2014 View on HN

Perhaps you meant RAII [1] ?[1] http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initial...

sramsay Sep 21, 2019 View on HN

Is RAII in C a serious suggestion being made anywhere?

waynecochran Mar 18, 2020 View on HN

How does this compare to using RAII in C++ in terms of generated code?

johncolanduoni Apr 28, 2017 View on HN

You can do RAII without constructors (e.g. Rust)

AnimalMuppet Feb 24, 2022 View on HN

In what possible way can RAII be said to do those things?

MereInterest Dec 14, 2020 View on HN

I would strongly disagree on RAII being a kludge in C++. The language feature that enables it is deterministic destructors, whose primary purpose is to ensure that allocated resources are deallocated. RAII is one particular use of destructors. The primary goal is to have the object be the thing that owns a resource, not the calling scope.In terms of usability, destructors allow for resource management that is far easier at the call site than any other language. "with" blocks suc

enriquto May 11, 2018 View on HN

sure, it's just a small, but non-negligeable, part of RAII that you can do in C

devnullbrain Feb 3, 2023 View on HN

It sounds like you simply don't know RAII.