2010-08-27, 04:12 PM
C#
No C++-style const-correctness. Let's say I have a class that internally has some sort of container object and I would like clients of the class to have read-only access to that object. In C++, you could simply return a const object. In C#, your options are: 1) Return the object and document that the caller should not call any methods on the object that change it. 2) Make a (deep) copy of the object and return that. 3) Make a "ConstFoo" class that wraps a Foo and exposes only the "const" methods and properties of the Foo class.
None of those approaches are particularly satisfying.
No support for automatic release of resources other than the using statement. In C++, when an object goes out of scope, its destructor automatically runs and releases any resources the object may have held. For objects on the heap, you have things like shared_ptr that can reference-count the object and have the destructor run when there are no more references to it. In C#, you need to use() any local IDisposable objects and make a class IDisposable if it owns any IDisposable members (or if it *might* own any IDisposable members if it's an abstract class or interface).
.NET framework (or Mono) needs to be installed on user's machines.
@AngelSL: Mono is fairly mature. Any .NET 3.5 or lower program that doesn't use P/Invoke or Windows-specific libraries like WPF will run on Mono. However, I did run into some performance issues recently when developing a program on Windows that would be deployed on Linux with Mono. Mono's string.StartsWith() method is ridiculously slow, even when using StringComparison.Ordinal. I got a 25% speed increase of my entire program just by replacing all calls to string.StartsWith() with my own implementation. The program started out ~8 times slower on Mono than .NET and I was able to get that down to ~3 times slower with some optimization. The program is mostly string processing.
No C++-style const-correctness. Let's say I have a class that internally has some sort of container object and I would like clients of the class to have read-only access to that object. In C++, you could simply return a const object. In C#, your options are: 1) Return the object and document that the caller should not call any methods on the object that change it. 2) Make a (deep) copy of the object and return that. 3) Make a "ConstFoo" class that wraps a Foo and exposes only the "const" methods and properties of the Foo class.
None of those approaches are particularly satisfying.
No support for automatic release of resources other than the using statement. In C++, when an object goes out of scope, its destructor automatically runs and releases any resources the object may have held. For objects on the heap, you have things like shared_ptr that can reference-count the object and have the destructor run when there are no more references to it. In C#, you need to use() any local IDisposable objects and make a class IDisposable if it owns any IDisposable members (or if it *might* own any IDisposable members if it's an abstract class or interface).
.NET framework (or Mono) needs to be installed on user's machines.
@AngelSL: Mono is fairly mature. Any .NET 3.5 or lower program that doesn't use P/Invoke or Windows-specific libraries like WPF will run on Mono. However, I did run into some performance issues recently when developing a program on Windows that would be deployed on Linux with Mono. Mono's string.StartsWith() method is ridiculously slow, even when using StringComparison.Ordinal. I got a 25% speed increase of my entire program just by replacing all calls to string.StartsWith() with my own implementation. The program started out ~8 times slower on Mono than .NET and I was able to get that down to ~3 times slower with some optimization. The program is mostly string processing.

