3 ms·
Other than satisfying curiosity, why should I learn OCaml?
by jklein11 8y ago
Other than satisfying curiosity, why should I learn OCaml?
- jnordwick 8y agoThere is none. OCaml is a kitchen sink of a language that has grown by accretion. I remember playing with it years ago, but today there are many more modern and better designed languages that cover the same ground, such as rust - and I'm not even a rust fanboy to say this. Unless you're into historic languages for their own sake, I wouldn't waste my time. It would be like learning BASIC.
- wadkar 8y agoCould you please tell us how rust is better at functional programming than OCaml? Your comment appears unsubstantiated to me. I am not sure how you reached the conclusion of equating learning OCaml with learning BASIC, but I would be happy to know your reasoning.
- gaius 8y agoIt would be like learning BASIC. If I had an opportunity to do Real Work in BBC BASIC I would jump on it
- fsloth 8y agoPrograms written in ML dialects tend to have the astounding property that once they compile, they are correct. And this is only a slight exaggeration. This property alone is worthwhile to learn one, if for nothing else then to be able to apply the same succesfull patterns in other languages. I didn't know how to write proper strongly typed code until I learnt Ocaml - I had several years of experience in C++ and knew Java, but, they really don't go out of their way to expose the patterns that allow write the best code possible. With the lens of Ocaml under my belt I could better discern the shiny patterns that were buried all that ugly dirt of multiple inheritance and such bollocks. Which ML language should you learn? Any of them is good as the next if it's for education - a modern tooling, support and community is a nice bonus. ML languages in production nowadays include Ocaml, F# and, to some extent given it has so much isomorphism with its kin, Scala. Scala can be considered an ML dialect, although with the weirdest syntax of them all. Unless you are quite certain Ocaml is the exact language you want to learn, F# is a good alternative.
- owl57 8y agoI'd say Elm is a plausible alternative, though maybe not right now: there are a lot of small rough edges in the ecosystem after 0.19 release. On the other hand, a lot of the 0.x breakage comes from the very high priority of the unusual long-term plan, which I'd formulate as something like following: distill that essential property of ML while shaving all the bells and whistles that just happen to be in other dialects.
- fsloth 8y agoAre there any plans to bring Elm to any non-javascript runtime?
- owl57 8y agoLong term: yes, the controversial banning of "native" code [1] is in part motivated by the idea that JS should be an interchangeable implementation detail. Short term, officially: hell no, Evan declares a sharp focus on one use-case and discourages experiments with other platforms, even server-side node.js [2]. Short term, unofficially: I heard of a compiler to Elixir [3]. Elm's stance on "native code" (see above) seems to make such projects feasible. [1] https://discourse.elm-lang.org/t/native-code-in-0-19/826 https://discourse.elm-lang.org/t/native-code-in-0-19/826 [2] https://github.com/elm/projects/blob/master/roadmap.md#can-i-use-elm-on-servers https://github.com/elm/projects/blob/master/roadmap.md#can-i... [3] https://github.com/wende/elchemy https://github.com/wende/elchemy
- winter_blue 8y agoOcaml has an amazing type systems that’s been designed well from the ground up. There’s excellent pattern matching, no null/nil, immutability of values, higher-order functions, etc. The type systems of a lot of new languages have gotten their inspiration from OCaml. For example, the Flow type checker for JavaScript is heavily Ocaml-inspired and itself written in Ocaml. On practical grounds, there’s ReasonML: https://reasonml.github.io https://reasonml.github.io ReasonML, a dialect of Ocaml is great for web development. Especially if you use React, due to: https://reasonml.github.io/reason-react/ https://reasonml.github.io/reason-react/ ReasonML & ReasonReact are both officially supported & developed by Facebook. The creator of React is also strongly behind ReasonML. Alternatively, there’s also BuckleScript (whose compiler is shared with ReasonML), which lets you use Ocaml with its standard syntax on the web. BuckleScript is officially supported & developed by Bloomberg.