Linked by Thom Holwerda on Mon 20th Jul 2009 15:54 UTC, submitted by Brandon L
Permalink for comment 374255
To read all comments associated with this story, please click here.
To read all comments associated with this story, please click here.




Member since:
2006-03-01
I am not sure about your predicate issue (Filter is not a member of List), but something like this works fine, even though the Find method signature has Predicate and not a Func.
var strings = new List(new[] { "Foo", "Bar" });
var result = strings.Find(s => s == "Foo"); // result will equal "Foo"
That is not what I meant. If you have a delegate of type Predicate but need a delegate of type Func or vice versa, you have to write an adapter. That can be as simple as a small lambda expression like the one above, but it comes with considerable performance cost and is also quite ugly.
By the way: that the list handling functions are called differently than in all other languages is another bad design decision: ConvertAll instead of Map, FindAll instead of Filter etc.
Lastly, if you want pain, work with java for a bit. All these "enterprisey" languages accumulate amazing mounts of cruft, because they have promise support for a bajillion years for anyone to think of using it. Your options are keep bolting things on as nicely as you can (C#), or just don't add anything to the language, even when it gets horribly out of date (java)
At least most language features of java work well with other language features. Half of C#'s language features are no longer usable if you for example use generic types: no operators, no static methods etc.
And at least the java class library contains some decent collections. The .net framework does not even provide an interface for a set. And there is not even a default implementation of the most basic concurrency data structure: a blocking queue.
The few interfaces they do provide in .net (e.g. IEquatable<T>) are not even consistently used by the basic language constructs (e.g. enums do not implement IEquatable).
If you compare C# to a modern JVM language like scala it looks like a toy. And C++ allows a much higher level of abstraction than C# ever will because of template metaprogramming.
Every single language feature of C# looks pretty neat in small examples. But whenever you dig a bit deeper you see that that is all just a facade. To every rule there are hundreds of exceptions. Properties look just like fields, but you can not use ref parameters with properties. Every abstraction is leaky.
Edited 2009-07-20 21:48 UTC