by melling · 9y ago · 0 comments
Java couldn't do generics right, for example, because they didn't want to break compatibility. C# seems to be adding a lot of improvements, but would it be better if they could break compatibility?
[1] https://gist.github.com/olmobrutall/31d2abafe0b21b017d56
Seems to go against null propagation operator though :)
The only two warts that strike me off-hand are covariant arrays and System.Nullable being value-type only.
Overall Microsoft has done a great job of building on earlier decisions. Including functions as first-class types (System.Delegate) in V1 is probably the biggest and was a deliberate break with Java's approach. It has enabled a ton of features: lambdas, LINQ, Expression, etc. The fact that LINQ can be turned into an AST with Expression<T> means you can also construct code dynamically at a much higher level than IL.Emit() while delegates mean you can get the JIT to provide the equivalent of a function pointer to the native code.
https://blogs.msdn.microsoft.com/dsyme/2011/03/15/netc-gener...
The reason is that C# had a chance to learn from the experience of others and is still a relatively new language.
There is a little bit of cruft here and there. For example, ,NET had good threading support from the start, but the idioms that are used nowadays for concurrent and parallel programming have evolved, and while the old APIs are still there, developers now use APIs that are more up to date.