3 ms·
How similar is OCaml to F#?
by xupybd 4y ago
How similar is OCaml to F#?
- superlopuh 4y agoVery
- lf-non 4y agoDisclaimer: I have more exposure to F#, and am very early in OCaml journey. They are similar because F# pretty much completely borrowed the OCaml syntax when it was created. There have been many syntactic enhancements since and F# that most people write nowadays (the light syntax) is a quite bit different from OCaml though they remain similar. The bigger differences are around the type system & modules. The F# team doesn't seem to have enough power to sway the direction of CLR, so OCaml features that didn't cleanly map to C# constructs or hinder interop with other dotnet languages (like parameterized modules, structural typing etc.) were not adopted in F#. Also from my early exploration OCaml binaries seem to be a lot smaller and the compiler a lot faster. This is not a criticism of F#, I have found that the combination of lightweight syntax, computation expression syntax, access to both dotnet and javascript ecosystems (fable) and the great tooling (ionide) to result in a very productive experience for day to day work, though FP enthusiasts tend to scoff at lack of higher level abstractions. Looking forward to exploring OCaml more over the next few months.
- stonemetal12 4y ago2nd Cousins? When F# first came out it was OCaml syntax on dot net runtime. But much like C# starting as MS's Java, it quickly grew away from that starting point. Haskell had a bout of popularity when F# was young so it picked up a Haskellish syntax and workflows. These days there is an obvious ancestry with OCaml but not that close.
- bmitc 4y agoVery similar. Initially, F# was an attempt to port Haskell to .NET. This was part of the so-called Iron project to port many languages to .NET to test out the ability of the CLR to host different languages. Haskell was too difficult of a match for .NET, so they switched to OCaml. At the beginning, F# was actually compatible with OCaml, but it has since diverged becoming its own language. I don't have much experience with OCaml, but I suspect F# is the easier one to setup and get going in. It's my understanding that OCaml has issues being setup on Windows. (This may be an out of date understanding.) Since F# is installed with .NET now, all it takes is for one to install the .NET SDK and then you have F#. This makes it very easy to install F# on basically anything. Here is The Early History of F# by Don Syme, the creator of F#. https://fsharp.org/history/hopl-final/hopl-fsharp.pdf https://fsharp.org/history/hopl-final/hopl-fsharp.pdf While the ecosystem isn't as great as it could be, F# is by far my favorite language. I do not know of a language that hits better sweet spots.