Re:Java String compare
Posted: Sat Aug 05, 2006 7:39 pm
Incidentally, this is pretty much how C++/CLI does things. For managed types, the destructor syntax is translated into an implementation of the IDisposable .NET interface, which is something that seems so obvious to me that it's amazing that none of the other current breed of GC languages has done it before. The using statement in C# is certainly useful but is somewhat lacking in that you can basically only use it in local scopes, whereas the destructor syntax can do automatic clean-up on an object-lifetime basis.a) You've touched on the one thing about most GC systems that I am vehemently opposed to -- finalizers. Finalizers suck. They cause overhead, they make no guarantees about when your resources will be freed, etc. They are just a Bad Idea. I think the best mix is GC for memory only, and a scoped RAII-like idiom (or ref-counting) for managing non-memory resources (files, network connections, etc.). Java totally lacks this alternative -- at least C# has the using statement, and of course C++ has destructors and smart pointers.
I am not sure I'd preach in favor of C++/CLI in general, though. I want to like the language, but there are certain things that just seem to be harder than they need to be, and to be perfectly honest Visual C++ produces some horrendous code for .NET applications (putting all the code in the header file, putting a public label in front of every single public method that the code generator adds, etc.).
There's also a serious lack of documentation (most Microsoft docs for .NET target VB and C#), and the Visual C++ team seems to be lagging behind the Visual C# team in supporting the features of .NET.
At this point, I think it's still an unfinished product, but it does seem like it satisfies Solar's a and b criteria.