4 ms·
How does Ocaml compare to F# in expressing functional paradigm?
by philonoist 8y ago
How does Ocaml compare to F# in expressing functional paradigm?
- badfrog 8y agoFrom Wikipedia: > F# is a member of the ML language family and originated as a .NET Framework implementation of a core of the programming language OCaml So F# is based on OCaml and is very similar.
- philonoist 8y agoI apologize for not being clear. Which one is more expressive of functional paradigm?
- 4thaccount 8y agoF# uses a lot of OCaml syntax and is quite similar in many regards. Where they differ is F# is written on top of .NET, so users probably drop into the OO paradigm more often than they might in OCaml.
- philonoist 8y agoI apologize for not being clear. Which one expresses functional paradigm more?
- 4thaccount 8y agoI'm a novice in both, but my general impression is that they are so close in this regard as to not matter a whole lot as far as practical matters go. An expert can of course get detailed on the minutiae. Put another way, OCaml only works on Windows via MinGW if I recall correctly. While that isn't a problem for most folks, I prefer to steer clear and only use a language on a platform with a significant number of users. Python is used extensively on Windows, Mac, Linux, ARM...etc, so I'll use it on any of those machines. I would guess nearly all OCaml use is done via Linux and next to zero on Windows, so I avoid it on Windows (not worth the effort). F# on the other hand has some support from Microsoft (not a ton, but enough) and a decent amount from the community with some neat innovations (at least I think they are) like type providers. It has full .NET interop when you need it. Most of the syntax and method of using pattern matching everywhere is the same between them. The difference with F# that I find annoying is that I'm not super familiar with C#, so the times when you need to call .NET (Ex: iterating through a directory) directly, it is super obvious for someone with C# experience, but involves lots of digging through horrid Microsoft doc for me where only C# and VB.NET is covered 80% (I just made up that number, but F# is the least documented of the three official Lang's) of the time.
- ernst_klim 8y ago>OCaml only works on Windows via MinGW if I recall correctly. Afaik OCaml could be built with MSVC. Lexifi use OCaml on windows only and even have a .NET layer https://github.com/LexiFi/csml https://github.com/LexiFi/csml
- yawaramin 8y agoHere's a mail from Don Syme, F# creator, to the OCaml mailing list telling them how much influence they had on him and the entire .NET platform: http://caml.inria.fr/pub/ml-archives/caml-list/2006/11/d921ca59f12d434a3f005dfd07256d91.en.html http://caml.inria.fr/pub/ml-archives/caml-list/2006/11/d921c...
- jasim 8y agoThis was good to read! "FWIW if you're interested I'd also like to mention the huge impact OCaml had on the design of .NET generics and C# 2.0, which I've never properly described on this list. It was seeing and experiencing polymorphic programming in OCaml and SML that made us persevere with the long and torturous process of convincing Microsoft that they should add such an "experimental and academic" feature as generics to their flagship runtime and languages. Of course we were in reality just making 1970s ideas work in practice, but at least now even Visual Basic has generics."
- agumonkey 8y agohad no idea they resisted Generics.. I thought Java 5 was the main reason C# got them.
- yawaramin 8y agoI think the one thing we can take away from the history of every mainstream language is they will all fight tooth-and-nail against generics because they are 'too complex', before coming up with some 'innovative approach to generics'.
- philonoist 8y agoI apologize for not being clear. Which one expresses functional paradigm more?
- Paradigma11 8y agoOCaml since it has functors.
- ms013 8y agoF# is extremely similar. To put it in perspective how similar, I just ported a project for work over from F# to ocaml in a few days - mostly adding "in" for let blocks and parenthesizing nested match blocks where necessary, and replacing data structures with their ocaml equivalent. Large chunks of that code base didn't require any modification - I'd drop a 500 line source file in, run it through the ocaml compiler and have to deal with a handful of syntax tweaks to make it go through.
- philonoist 8y agoI apologize for not being clear. Which one expresses functional paradigm more?
- laurentl 8y agoWhich would you recommend from an ecosystem/performance perspective? I’m thinking hard about picking up a new language and I think it’ll be oCaml, but F# does have the .net ecosystem behind it... how is ocaml’s stdlib? Is it easy to find what you need in 3rd-party modules?
- ms013 8y agoF# for ecosystem. Most stuff you’d need is available via nuget. Plus, interop with C# is trivial, so all of that ecosystem is there too. Ocaml has opam for package finding, but it’s a bit sparser. That said, I don’t tend to use a huge number of 3rd-party modules, so it’s not a big differentiator for me. Too much of a liability to have dependencies on some rando from the internet: for work, we tend to stick to modules from trusted sources in the rare chance we use them (eg, Jane street).