7 ms·
Should I Haskell or OCaml?
I am growing dissatisfied with Python, and looking to learn a new language. I’m interested in functional programming, so I think this will be one of Haskell or OCaml.
If anyone can weigh in with some thoughts, it’d be appreciated. I don’t have particularly clear-cut requirements here, but here are some things I have been working on, as well as other thoughts I have been having about this choice, that may influence someone’s advice.
Although I am not motivated primarily by a dislike for Python (I like Python most of the time), here 2 things that genuinely bother me about it:
* Getting tired of the lack of real static typing. I suppose I could/should set up a MyPy daemon for everything I do that’s more than a simple script, or try Pyre? I’m not sure how much of a pain that would be.
In any event, it’s still kind of annoying for the language to not actually include this concept. The type annotations feel tacked on (because they are) and at the end of the day, it’s still possible to get runtime errors that should have been checked at compile-time.
* The import and PYTHONPATH stuff is crazy. In particular, I feel like I am constrained to structure projects in a way that makes sense. I’ve just found a way that works for Flask web applications and I am sticking with it because fiddling with the structure too much leads to import errors.
Maybe I would have more gripes if I were smarter. Things I do like about Python:
Standard library seems pretty good (?), especially in terms of DSA (I’ve been joking lately that solving Leetcode problems is where Python really shines)
The code tends to be readable (or at least, it is possible for someone to write very clean, very readable code).
The main things I have been working on lately have involved PDF/document processing in the context of web apps. I also have some designs to do some ML/NLP stuff in a domain/industry where I have domain expertise.
My current thoughts:
Haskell has a lot of learning materials, and stuff like HaskTorch exists for my ML/NLP interests. Primary downside is that it’s purely functional, which means it can be less flexible and makes it less likely it can replace Python as my go-to language. Of course, that might be a plus from a learning perspective, as it would force me to learn to accomplish things in a purely functional way.
OCaml is more flexible in terms of paradigm, which has pluses and minuses from a learning perspective. Seems more likely to be a practical choice.
I would not say employment prospects are top-of-mind here. I don't think either are widely-used enough for it to matter; C++ would be a better thing to add to my resume for a lot of the jobs I am interested in; and I am of the general opinion and belief that I should prioritize foremost what I enjoy and have genuine interest in, both for QOL and because money will then follow.
- rajandatta 3y agoI would suggest neither in your position. I suggest trying a language like F#. F# started as with the idea of developing a language with OCaml like syntax and semantics for the .NET platform. Since then its evolved to being a mature, elegant and robust language. It can run on Windows and Linux. Advantages over OCaml is I suspect a much larger footprint and the ability to tap into all of .NET (huge ecosystem). Plus your skills will be more portable than Haskell or OCaml. Both Haskell and OCaml are exceptional languages but the ecosystem and market footprint is not great for either. Jane Street has done a lot to evangelize OCaml but it hasn't really moved the needle. Haskell is probably the most different being a lazy functional language. Definitely learn it but using it in real life will be harder.
- catlover76 3y ago> Advantages over OCaml is I suspect a much larger footprint and the ability to tap into all of .NET (huge ecosystem). Plus your skills will be more portable than Haskell or OCaml. Although job prospects are not the primary factor, I would like to hear more about this. Is F# widely-used? Are there a bunch of F# jobs and not quite enough people to fill them? Thanks edit: also, if you can recommend any physical books on F#, I would appreciate it
- staunton 3y agoIf you're not so much interested in using the language you learn in a job, I would recommend learning a proof assistant like Coq (basically Ocaml on steroids) or Lean (newer toy originally by Microsoft). The functional programming is fully there and you can even formally prove things about your program. The type systems these languages use are the richest out there (enough to encode basically any mathematical statement as a type)
- catlover76 3y agoI've heard of those, but I don't think I quite know what they are for. Formally proving things about a program sounds cool, but what are some practical applications of that? Thanks