4 ms·
I'm not familiar with OCaml, so maybe I'm missing something. But why does no one gush over Erlang and Javascript when the FP hat gets passed around? Is OCaml
by IsaacSchlueter 18y ago
I'm not familiar with OCaml, so maybe I'm missing something.
But why does no one gush over Erlang and Javascript when the FP hat gets passed around? Is OCaml really much better than either of these?
(Javascript, granted, has no shortage of warts. But it's the browser language we have, so it's worth learning to love it.)
- raganwald 18y agoLearning to love the one you're with is fine, however that does not necessarily lead to the type of "mind warp" he's describing. I like JS enough to blog about it, but I confess I haven't found in it that marvelous thing that makes me see programming in a new light. So it may be that although Javascript is where you want to use your FP chops, Lisp or Ocaml is where you want to acquire them.
- ajross 18y agoA lot of that has to do with Javascript's environment. While it is a functional language, it's living in a decidedly procedural world. The DOM is defined in IDL, for goodness sake, and even the really cool libraries like jQuery don't make much use of the functional paradigm. So there's not a lot of clever code to study that doesn't look like C, basically. Nonetheless, there are all sorts of clever things you can do with closures in Javascript to avoid big declarations of global variables, etc... You just have to dig really hard to find the sample code that appears in the tutorials for lisp, haskell, ML, etc...
- jon_dahl 18y agoWithout being an expert, I'm pretty sure that OCaml is more strictly functional than Erlang and Javascript, though they all support functional programming to one extent or another. With languages like Javascript and Ruby, you can program for years without really learning functional concepts. I think OCaml is the opposite; the paradigm of least resistance is functional, even though you can program in other styles (OO, imperative). In terms of functional purity, Haskell > Lisp/Scheme/OCaml/ML > Erlang > Ruby/Javascript > Python > Java > etc.
- lg 18y agoI'd say Erlang enforces functional style more than Lisp does... there's no Erlang object system.
- IsaacSchlueter 18y agoTrue, it is virtually impossible to do much of anything in Erlang without using a bunch of little functions. Immutability is a harsh mistress, but one that I've already fallen in love with.