Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Go has a garbage collector. RAII is only viable in languages where destruction is predictable, like C++ or PHP.


"defer" is effectively used for predictable destruction in Go, and a more automated RAII scheme could be used in its place.

C++/CLI is a language that targets a garbage-collected runtime, yet has full-fledged RAII semantics (they're mapped to CLR Dispose pattern).


Oh, I totally forgot about C++/CLI! You're absolutely right; that's my mistake. I do agree that RAII is preferable.


PHP also has a garbage collector.

Swift and D also have garbage collectors and support RAII.

And since I already see it coming, reference counting is a garbage collection implementation algorithm in computer science literature.


Yep, and I even referred to reference counting earlier in the week as garbage collection, so I'm going to assume I was having memory corruption with my answer. :-)


Hehe :)


The tracing GC certainly complicates things, but you can make it work with a "scope" keyword like in D.




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

Search: