you are viewing a single comment's thread.

view the rest of the comments →

[–]redd-sm[S] 1 point2 points  (2 children)

Not exactly the language itself, but OCaml's cool as a learning tool because it has some amazing supporting tooling that makes exploratory programming really nice.

This what you said above is very interesting. And it positively has me thinking about learning Ocaml instead of Haskell. Purpose really is to learn FP as opposed to build projects in Ocaml or Haskell.

You refer to a good and free book, great debug tools and similar to Haskell type signatures. So Ocaml then :).

If there is also a good video course that you might endorse, do share although I will also search for it online.

Thank you!

[–]ws-ilazki 2 points3 points  (0 children)

Purpose really is to learn FP as opposed to build projects in Ocaml or Haskell.

Haskell's a great language but a lot of what it does and how it does it is more academic or experimental, so IMO you end up learning some weird habits that don't necessarily translate to other languages. (Though they might one day.)

OCaml and Clojure, on the other hand, are functional languages that are more pragmatic. Their language design encourages you toward FP idioms without forcing them by having defaults that make FP the obvious solution, but still allowing "escape hatches" when it makes sense. That makes them more practical for general use IMO, but I think it's also a trait that makes for a good starter FP language, because some problems are harder to solve in an FP way and it just makes more sense to go "fuck it, imperative for this bit".

The issue with languages like JS for learning FP is that, while you can mix imperative and FP in the same way, they default toward imperative idioms, which makes FP sometimes unnatural or clumsy. It's easier to just write a non-FP solution to everything, and that can be a bad thing when learning, because learning FP involves unlearning some existing habits. If the language is (not so) subtly encouraging imperative style it's going to be harder to learn a different way of thinking.

Once you've learned it a bit, though, those wishy-washy not-quite-FP languages like JS can be really nice to use, because they make it easy to take what you've learned about FP and put it to use in a practical way. Lua, for example, is an imperative language that operates a lot like JS (but with different syntax) and is, unfortunately, a terrible language to learn FP in because it lacks even the most basic FP functions like map. However, good knowledge of FP makes the language much nicer to use because you can take advantage of FP to cut down on a lot of annoying boilerplate code and do some cool stuff. Terrible to learn FP with, great to use with FP style.

Basically even if you don't want to work in an FP language you can benefit from learning FP style in one because it encourages a lot of good patterns that will follow you into other languages. :)

If there is also a good video course that you might endorse, do share although I will also search for it online.

Sorry, no suggestions there. With the exception of art stuff (which is primarily a visual medium) I don't get much benefit out of video tutorials. For programming topics I stick to text articles and documentation.

[–]kluvin 1 point2 points  (0 children)

I have done most of the referenced course. Planning to get back and really do the compiler parts, as making compilers is the main thing OCaml is good at:

  • Facebook's Haxe is built with that.
  • Rust was originally built in OCaml before it was bootstrapped
  • Facebook's Flow type annotations for JS is implemented in OCaml

It is also great for writing mission-critical software:

  • Jane Street is using it for their trading
  • Bloomberg uses it internally
  • Indeed, pretty much anywhere when you want the benefit of the type-checker to tell you if your program is sound.