4 ms·
> F# leans closer to its functional roots in this respect, so it's more idiomatic to keep object-oriented constructs at arm's reach in most your code. The langu
by frowaway001 13y ago
> F# leans closer to its functional roots in this respect, so it's more idiomatic to keep object-oriented constructs at arm's reach in most your code. The language has full support for OOP, it's just that you're not expected to trot it out except when you're writing public interfaces that are meant to be consumed by code that might be written in C# or VB.NET.
Wouldn't it have been better to keep such things out of the language instead of having a considerable amount of complexity in the language for stuff people are not even supposed to be doing in the first place?
- noblethrasher 13y agoNo, The .NET Base Class Library is object-oriented at the core, and one of the value propositions of F# is that you can fully leverage that library.
- frowaway001 13y agoIsn't there a large difference between supporting interop with code written in other languages and importing all the stuff into the language itself?
- noblethrasher 13y agoWell, if the language was only meant to be an API consumer then eliding OO stuff would make more sense, but they designed it for bi-directional interop. And besides, F# was based on OCaml (as I'm sure you know), which itself was an existence proof that you could successfully bolt OO onto a functional language.
- frowaway001 13y ago> successfully bolt OO onto a functional language Yes, I think that's a good description. It's not great, but it somehow works (although the whole F# community tends to tell people to stay away from OOP when not necessary). Would have been interesting to explore better ways to support OOP so that it doesn't need to be considered a second class citizen, but I guess it's too late for that now.
- bunderbunder 13y agoThere's an enormous difference. And it's a good thing F#'s designers chose the latter option; it's a huge win on the interoperability front. Libraries have a tendency to be write-once-use-often, so exporting object-oriented APIs from F# code is way better than consuming functional APIs from C# code.
- frowaway001 13y agoI think there is a huge way between allowing developers consume F# code from C# and importing all the ugliness of stuff like static members into the language. I don't think it has to be that way. What's the value of having a runtime with a language-independent intermediate representation if one just adds half of C#'s complexity into F#?
- bunderbunder 13y agoQ: What's the difference between a static method and a function that belongs to a module? A: One's object-oriented jargon, the other's functional jargon. They both mean pretty much the same thing.
- frowaway001 13y agoSo why have both in the language?