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

When mentioning C# (not sure about any other language), I would have mentioned the using statement and IDesposable objects.

This way each object's needed cleanup is encapsulated in each objects dispose method(s).

Granted using compiles down to a try-catch-finally with the Dispose method called in the finally, but there is an elegance to it.

https://docs.microsoft.com/en-us/dotnet/csharp/language-refe...




Looks similar to Python's "with" statements in the first form, and RAII-ish in the second form.


Thanks for the pointer, adding it to the article (with credits)




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: