4 ms·
I know Clojure, looking to learn a statically typed functional language. Narrowed it down to Haskell and OCaml (are there others I should know about?). I still
by quantumtremor 11y ago
I know Clojure, looking to learn a statically typed functional language. Narrowed it down to Haskell and OCaml (are there others I should know about?).
I still am unsure what OCaml is good for. Ex., Ruby is good for webdev with Rails, Python is good as a general purpose language, Clojure is good for async and quick iteration/integrating with Java code, C is good for OS work, C++ is good for native applications.
Is OCaml general purpose? Can I use it for NLP? Statistics? Numpy-like n-d array math? Writing a compiler?
- nv-vn 11y agoOCaml is super general purpose. You can write low-ish level code (there have been 2 kernels partially written in it) as well as higher level stuff (web servers/scripts on the pages using tools like js_of_ocaml, Coq, etc.). Where it really stands out it compilers and static analyzers (+ other similar things). Facebook uses it for a few of their compilers and static analyzers, the Rust compiler was originally written in OCaml before being ported to Rust, the Haxe compiler and VM are in OCaml as well. The OCaml compiler comes with lexer and parser generators and a lot of other libraries exist for it too (such as an official LLVM binding). I'm not sure how great it is for NLP, but I'd assume it's not bad for it. Here is a list of companies that use it: https://ocaml.org/learn/companies.html https://ocaml.org/learn/companies.html.
- lobster_johnson 11y agoNot currently an OCaml user, but it's definitely general-purpose. I don't think OCaml fits into a specific broad niche, although one of the areas where it sees more use is in computer language development/research. A whole bunch of compilers are implemented in OCaml (Hack and Flow by Facebook, for example), and then there are tools like Coq, and some static analysis tools (Flow is one, I guess) are also in OCaml. What I think you'll find is that the standard library is quite lacking, as is the availability of third-party libraries. The ecosystem is nowhere close to what it is for languages like Node.js, Ruby — or even Haskell.
- technomancy 11y agoI can't think of a better language to complement Clojure than OCaml. It hits all of Clojure's weak points dead-on, and its own weak points are covered really well by Clojure. In terms of "general purpose", I think of Clojure as being a better choice for long-running server processes and OCaml as being a better fit for code you run on your own machine or programs that don't stay running forever, due to the varying memory/performance/concurrency characteristics of their respective runtimes. I wrote in more detail about my experiences coming from Clojure to OCaml here: http://technomancy.us/170 http://technomancy.us/170 I found it very easy to pick up with some FP background. Not having to think about nil in particular was a huge breath of air after Clojure. I also had good luck accepting contributions from others with a Clojure background who wanted to make some changes to my code and learned OCaml just for that.
- rwmj 11y agoOCaml is super-practical for writing simple command line tools. It interfaces easily with C and compiles to binaries with no dependencies. See: all the tools written in OCaml here: https://github.com/libguestfs/libguestfs https://github.com/libguestfs/libguestfs
- gaius 11y agoI got into OCaml because I wanted something that was like Python but with strong typing. Type inference is amazingly productive once you get into it - very nearly to the level of, if you program even compiles, it will probably work first time.