3 ms·
There's no reason why, for instance, Java and C# require type annotations all over the place. Wouldn't their type systems be a big reason why? ML and Haskell
by stonemetal 13y ago
There's no reason why, for instance, Java and C# require type annotations all over the place.
Wouldn't their type systems be a big reason why? ML and Haskell have type systems very different from Java specifically because they went for systems that were inferable. F# has an iffy "just assume it is int" step to make it work with the C# type system. F#'s inference algorithm doesn't work as well, and it impacts how the language gets used. For example people tend to overuse the pipe operator because it helps the inference engine get the right type without annotations.
- MichaelGG 13y agoF#'s "assume it is int" is only for a few operators, such as +, as a convenience. It has nothing to do with interop with C# at all. F# inference is left-to-right, which is one reason to use the |> operator, yes. F# had additional type inference, for instance, accessing members on a binding would infer object types, but they removed that. Haskell has a more complete type inference system. I'm not seeing anything in C# that prohibits inference of types for fields, methods return types, or parameters. The type system C# has is essentially a subset of F#.