4 ms·
Doesn't the "O" in OCaml stand for "Object", though? I think you could pick up either F# or OCaml just as easily. The nuances of OOP in F# can be ignored by be
by munchler 2y ago
Doesn't the "O" in OCaml stand for "Object", though? I think you could pick up either F# or OCaml just as easily.
The nuances of OOP in F# can be ignored by beginners, so I really wouldn’t let yourself be intimidated coming from Clojure.
[0] https://ocaml.org/docs/objects https://ocaml.org/docs/objects
- armchairhacker 2y agoOCaml classes and objects are (ironically) rarely used and generally discouraged. There are some cases where they’re practically required, such as GUI and FFI (js_of_ocaml). But otherwise, most code does encapsulation and abstraction using modules and functor modules (which are more like Haskell and Rust typeclasses than traditional OOP classes). I don’t know much about F#, but last time I used it most of its standard library was in C# and .NET, so F# code would interact with objects and classes a lot. AFAIK F# also doesn’t have functor modules, so even without the dependence on C# code, you still can’t avoid classes and objects like you can with OCaml (e.g. you can’t write a generic collection module like `List` or `Set` without functors, it would have to be a collection of a specific type or a class).
- neonsunset 2y agoF# uses .NET's generics, so the statement regarding List/Set is completely incorrect (all base collections are generic).
- penteract 2y agoI think you misread their claim - they said that generic list/set would have to be classes, not modules (generic modules are a specific thing in OCaml and aren't the same as a module of generic classes).
- mrkeen 2y agoF# has "generics" just like Python and PHP now "have types". It's not a yes/no feature.
- neonsunset 2y agoGive F# a try. It has, and always had, true generics. https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/generics/ https://learn.microsoft.com/en-us/dotnet/fsharp/language-ref...
- mrkeen 2y ago> It's not a yes/no feature. FTFM: It's not a true/false feature.
- neonsunset 2y agoAlright. Humor me, what is the issue with F# generics as compared to other languages with generics? Which implementation (that is productively useful) is a "true" one?