Join the discussion
Write your take first — we'll ask for email only when you're ready to publish.
- Hacker News
- The French original version of the book appears to be 12 years old (2014). Is the English translation linked here a somehow more up to date book?by netfortius
- > Learn Programming with OCaml
Lately, I keep asking myself, do I need to learn this new thing, should I force myself to learn this thing, LLMs know it anyways and so on.
So (asking genuinely), should we learn these things?
by throwaw12 - Why learn an instrument when you can just press play?by ahoka
- Should you learn history if it is already written in a book? Should you live if others are already living?by adalacelove
- Posting 'why should we learn' a programming language on Hacker News is top-quality ragebait :-Dby yawaramin
- Outsourcing all the thinking to machines may have consequences you might not like.
An oblique explanation: https://croissanthology.com/earring
by nine_k - You could have asked this question 10 years ago, long before llms. It's not like you'd realistically would get an ocaml job back then when there's so few of them, so why bother?
The answer is still the same as well, people learn ocaml either because they enjoy it, or because learning a functional language makes them a better programmer overall and teaches your brain to approach a problem in a different way.
- Michael Clarkson teaches OCaml at Cornell. I highly recommend his free course materials [1]. He’s an excellent educator. Learning functional programming paradigms had a major influence on how I design programs. Clarkson also taught snippets from the Pragmatic Programmer, which was equally influential (as it has been for many many others) [2].
[1] https://www.cs.cornell.edu/courses/cs3110/2025sp/
[2] https://pragprog.com/titles/tpp20/the-pragmatic-programmer-2...
- My experience with OCaml has transformed how I think about programming and complex system design. This may also be true if you learn any other functional programming language, but OCaml is easy and flexible which makes it good imo as a door towards the more formal part of comp sci. Even for steering an LLM I think this might help.by dadoum
- You can also learn for your own amusement, and solely for the fun of comprehension; a lot of mathematician were driven by this. It's a shame current social value places so much utilitariaism on learning.by xiaoyu2006
- I know a few programs written in OCaml such as weidu.
OCaml is a very strange programming language. I don't think it will be able to sustain e. g. success stories of other languages, such as python.
by shevy-java - Ocaml is ancient at this point. It's never going to be python, but I doubt it's going to disappear.by debo_
- What is the recommended GUI framework for OCaml? (Please don't say HTML)by amelius
- Camlkit-gui for macOS
- What language and framework do you use for GUI programming?by yawaramin
- by osener
- OCaml programmers, what learning resource would you recommend starting out with? I know there's https://cs3110.github.io/textbook/chapters/basics/intro.html. How does this book compare? Anything else you would recommend?by Fervicus
- This book, while excellent otherwise, is much too harder for beginners, IMO. The pace is too brisk, and it's far from pedagogically useful if you don't already know how to program.by jan_m_savage
- Yeah, I don’t think it assumes zero knowledge, which is what I’d expect from a “first programming language” book.
But it does say it’s targeted more for an “algorithms” course in the introduction.
As a side note, I think a REPL is the best environment for learning to program for absolute beginners. You get instant feedback and can focus entirely on just short snippets of real code, without having to worry about compilers, build systems, and “the OS” as a whole. Especially if it comes with a GUI wrapper, you can skip the terminal entirely.
by ratorx - The standard library could be better, though.by jiehong
- I do really wonder what it would be like to learn to program for the first time with OCaml.
I remember learning to use OCaml in a properly functional way after so long writing code in C and it was really miserably painful trying to change how I thought about algorithms. I eventually got over the hill and it changed how I write code in C (for the better?), but I do wonder if it would have been easier to have learned OCaml as a first language instead.
by sweetjuly - Ooooh, the memories...
Caml was how I was taught computer science in prépa and first few years of engineering school, a mere 25 years ago.
(Ok, I had done bits of BASIC before, but I had time to recover.)
To be honest, the learning path was
1. Lots of maths. Then add some more.
2. Algos in pseudo code. (In "French", pseudo code, of course, because, why not ?)
3. Caml as "executable pseudo code". With all the warnings and a hints of disgust as the use of mutation and side effect. (And of course ":=" his completely different from "=", what are we, beasts ?)
4. Lots of exams where you have to write properly indented programs on paper on the first try to submit all sorts of recursive trees to all sorts of horrendous manipulations - and you can imagine the grader doing the mother of all code reviews
5. Re do that again in engineering school, because a third of the class had done zero computer science, and the other third had learn in Pascal
6. Then learn C and assembler, and get your mind blown in the exact opposite direction
7. See your teachers reluctantly say that "you should just learn java", because "that's what used in the industry", and "no one will ever get a job writing caml anyway"
...
25 years later : yup, some people managed to get jobs writing a dialect of caml for this small startup in a garage serving cat pictures and racist memes to billions of people
26 years later: "you should just learn to prompt LLMs anyway", because "that's what the industry needs, and no one will get a job programming any more"
by phtrivier - Being a functional programmer in a group of imperative programmers is miserableby sghiassy
- It's a good language to learn programming. Very simple semantics. But ultimately, you need to learn different paradigms, I think the order doesn't matter, they'll still be an element of surprise.
Also OCaml lets you write imperative code if you wish so. So you can learn the different paradigms within the same language.
by yodsanklai - When I first learned to program at university we were taught Haskell. That was 15 years ago and I've not really programmed anything in Haskell since, instead I've racked up years coding professionally in pretty much all the major imperative languages.
I'm aware of why Haskell is not practical as a production language for most companies, but I have to say I've never really coded in anything else that feels as "neat" and it's a shame. Every other language feels like it has some idiosyncratic scaffolding one has to learn, reminding you that you're constrained by how computer hardware works, rather than just expressing an algorithm in terms of inputs and outputs.
I would say it has made me a better coder, I've still kept a preference for keeping data immutable, copyable and abstracting complexity into easily testable functions over classes with unobservable mutable state.
by fat-chunk - I did so! (quirks of the path I took in the French educational system)
I went through a book similar to the one above, with no internet connection. The first few weeks were rough: I did not quite know what a type was and the compiler error messages were unforgiving and hard to understand without that context. But, once I grokked the core ideas (a proper idea of what could be done with recursion took much longer), things went surprisingly smooth. I definitely credit it with making me a better programmer.
by nestorD - This book is a great.
A common misunderstanding around OCaml is to classify it as a functional programming language, it is actually a multi-paradigm language. In short, in OCaml, you can write in any paradigm you want, imperative, object, or functional.
Typically, I write in a mix of OCaml and stubs in C (for bindings to Linux libraries), for everything, to replace shell scripts, Python scripts, Javascript/Typescript, but also for big applications (I wrote a clone of Emacs in OCaml, a long time ago, before writing MLdonkey).
Once you have started using it, it does not replace your main programming languages, it replaces all the languages you needed...
by lefessan - A good comment to motivate myself to learn the language; particularly the last line ;-)
I personally detest the babel of languages involved in "modern ways of programming" and have settled on C/C++ for everything since they are available everywhere. The only other languages i am willing to seriously consider adding to my repertoire are Erlang (functional/concurrent/distributed/fault-tolerant/hot-reload) and Prolog (knowledge representation and derivation using predicate logic) along with a formal verification language like Lean4/TLA+ etc. due to LLMs usage.
by rramadass - This is the best OCaml resource I know, and I have gone through it in full, and highly recommend:
CS3110: OCaml Programming: Correct + Efficient + Beautiful [0]
It is one of the best programming resources that I know of.
by __rito__ - Tangentially, a great interview with the creator of OCaml, Xavier Leroy [1].by zvmaz