3 ms·
Could someone briefly sum up the differences between F# and OCaml? Are there any reasons to switch from OCaml to F# in a Unix environment?
by yodsanklai 12y ago
Could someone briefly sum up the differences between F# and OCaml? Are there any reasons to switch from OCaml to F# in a Unix environment?
- ignoramous 12y agoOCaml can compile to native. That makes it faster than F# running in a VM. OCaml can compile to bytecode as well. Also, if you ever need interfacing with C/CPP, OCaml is better suited (faster) to the task than, say, Ruby or JVM based languages. Apart from that, multithreading in OCaml is a bit like on its on Python, IIRC, with GIL taking the sting out of it. But I am sure the researchers in France and elsewhere would bring true multithreading / multicore support to OCaml sooner rather than later. More on what OCaml gets right: https://realworldocaml.org/ https://realworldocaml.org/ (which seems to be down right now).
- mercurial 12y agoThere is a multicore runtime in the works, with an ETA of "when it's done". That said, you have a couple of full-featured monadic concurrency libraries (Lwt and Async). It also has functors (they let you parametrize a module over other modules), which F# doesn't, and you can do AST rewriting at compile-time via PPX (don't know if F# has anything like that). On the other hand, F# has access to the .NET ecosystem (which is admittedly larger than the OCaml one, though it suffers from enterprisitis), and has some nice goodies like type providers.
- VesaKarvonen 12y agoFYI, my Hopac library (https://github.com/Hopac/Hopac https://github.com/Hopac/Hopac) is also a full-featured monadic concurrency library, inspired by Concurrent ML, for F# that is optimized for parallel programming.
- pjmlp 12y ago> OCaml can compile to native. F# as well, via mono -aot, NGEN and the upcoming .NET Native toolchain. > But I am sure the researchers in France and elsewhere would bring true multithreading / multicore support to OCaml sooner rather than later. This is being worked on. "OCaml 2014: Multicore OCaml" https://www.youtube.com/watch?v=FzmQTC_X5R4 https://www.youtube.com/watch?v=FzmQTC_X5R4 https://ocaml.org/meetings/ocaml/2014/ocaml2014_1.pdf https://ocaml.org/meetings/ocaml/2014/ocaml2014_1.pdf
- DanRosenwasser 12y agoAt the very least, true multithreading and compatibility with .NET libraries. It's a great language with its own merits, and worth learning.
- enricosada 12y agosome differences: - consume and produce .net libraries (everything c# can do except NullReferenceException) - type providers, explore and use an api, strogly typed but easier than dynamic (example http://blogs.msdn.com/b/dsyme/archive/2013/01/30/twelve-type-providers-in-pictures.aspx http://blogs.msdn.com/b/dsyme/archive/2013/01/30/twelve-type... or http://fsharp.github.io/FSharp.Data/library/Freebase.html http://fsharp.github.io/FSharp.Data/library/Freebase.html or http://fsharp.github.io/FSharp.Data/library/CsvProvider.html http://fsharp.github.io/FSharp.Data/library/CsvProvider.html) - computation expression, easier to create like attempt/maybe and some builtin like async/query - concurrency and async (battle tested multicore/threading/async using .net runtime) - light syntax as default, like python (whitespace). ocaml like syntax can be used but is not idiomatic - .net runtime and mono, really good vm - overloading operators (operators are function), so + instead of multiple function like + and +. try it - user groups list http://c4fsharp.net/groups.html http://c4fsharp.net/groups.html - browser http://www.tryfsharp.org/ http://www.tryfsharp.org/ - more info fsharp.org - open source http://github.com/Microsoft/visualfsharp http://github.com/Microsoft/visualfsharp (vs stuff) or http://github.com/fsharp/fsharp http://github.com/fsharp/fsharp (cross plat)