3 ms·
C# has had type inference for a long while. It's a pain using Java, which doesn't. C# also sort of implements type classes. For your example, there's IComparab
by cmircea 13y ago
C# has had type inference for a long while. It's a pain using Java, which doesn't.
C# also sort of implements type classes. For your example, there's IComparable in C#; implement it and a List<SomeObject> can be directly sorted.
For pure functions, there's the [Pure] attribute, but it isn't enforced by the compiler, it's just a contract, a promise.
- quchen 13y agoYes, there are languages that also have these features, the puzzling part is why not all of them do (except those that may have good design reasons not to).
- ufo 13y agoIts hard to implement type inference and type classes unless you carefully design the language to accommodate it from day 1. For example, return-type polymorphism (functions like `read` or `return`) is particularly tricky, specially in the more dynamic languages.