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.
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.
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.
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.
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.
I like baking. There are machines that can bake bread at an industrial scale that I cannot compete with. There are home kneaders that do much of the work very well. I use one of those more often than not.
I still think it worth my time kneading dough by hand. It teaches me the various properties of flour, how external factors like humidity or temperature impact the overall process, and I believe that it makes me a better baker, even when I use a machine, because I am better at controlling what the machine does. When I get a new brand of flour I will make sure to bake everything by hand first to "get a feel".
Kneading by hand is also very relaxing to me. This is probably the main reason I bake in the first place.
Programming, and other activities are not very different. We now have machines that can do it faster, at a fraction of the quality many people deem good enough. If you hate coding, that is probably all you need to use, and learning a new language might just be a frustrating experience not worth subjecting yourself to. But if you enjoy coding then it should make you better at it, even when you use the machines.
As always, it is good to be aware that many people are too anxious about more existential issues to comfortably an consistently expend effort on intellectually-taxing tasks that aren't perceived as directly related to their survival. If it's an issue with social values, it's less of one related to learning as it is to perpetuating artificial scarcity.
>to comfortably an consistently expend effort on intellectually-taxing tasks that aren't perceived as directly related to their survival.
the average person spends 6(!) hours a day on their smartphone, the average TikTok user spends 100 minutes on the app alone. This isn't about artificial scarcity, it's about the average person looking like the Wall-E people
Escapism and making a concentrated effort on something are two different things. Yes it would probably be good if you could flip a switch and use the small windows of time we look at our phone per day to study OCaml, but it's not really realistic..
People who are asking these questions are saying "will me spending my time learning OCaml help me land that job that pays six figures and has health insurance so I can not rot away living on the margin". They aren't saying "I only do things that will make me money".
>use the small windows of time we look at our phone
again, it's not a small window. It's six hours. That's almost half your waking day. People spend virtually their entire leisure time rotting away on low quality entertainment.
>will me spending my time learning OCaml help me land that job
that's a pointless question for one you never know if something will land you a job, new opportunities don't open up before you do something, secondly the relevant question is, should I stop doing X and start learning Ocaml, or Chinese, or take a welding class because all of that even if it doesn't work out beats scrolling through Instagram.
I don't even take offense with the idea that you engage in activity that makes you money, because pure selfishness on that front would be an improvement to what most people are doing now.
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.
My experience with lisp was exactly that: it completely changed how I think about programming, but much more, how I think about systems and engineering. (I learned it through SICP)
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].
I think it's helpful to have a deep understanding of one c-type language, one lisp, and one ML-type language. There are so many things influenced by these three language families that being comfortable with them makes it so much easier to understand a wide variety of languages and libraries.
Cultural inertia: until recently, you couldn't just press play and get even a wide selection of music: for most of history, if you wanted music, you had to make it or hire someone to do it for you.
More recently, you had to go to the store and buy it, which meant you didn't have much variety.
Today, learning an instrument is for social status, inheriting the shine of the past, where music was rare and costly. The reason to learn an instrument today is because the former situation was romanticized.
It'll probably take a generation before people ease into guilt-free enjoying infinite, fully generated music.
Sure, I guess. But today, something like 30% of people play music or sing regularly enough to say they do it (ie, not very much at all). Even a couple of generations ago, it was much higher. It's not going to die out, but I think a lot of people are asking themselves if they want to bother.
Seeing that you already know programming, I'd say it'd be less risky for you. But the only reason you're able to pilot an LLM to do programming for you, is because you understand programming and architecture.
But what about the future generations skipping the step of learning the OCaml's, the C's, the Python's...? It's quite concerning.
you are eventually going to have a very bad time if you do not have a solid mental model of the code the LLM is writing, and indeed if you cannot steer the LLM so that its code conforms to your mental models. learning ocaml is a great way to add some valuable tools to your toolkit when it comes to thinking about code and how it fits together.
I would not make that dependent on LLMs. If OCaml covers a use case you have, why not.
Personally I try to stick within my own niche though - ruby, java and also python (ruby is unfortunately losing grounds really hard now, the writing was on the well in the last some years though, and people such as DHH are now indeed a liability rather than an asset to be had, but that's a side topic).
I think what LLMs will force in the long run is to make programming languages used by real humans in a traditional way, more effective. That is, writing code by humans will have to become a lot more efficient, both time-wise and speed-wise. And for that there is always a use case IMO since LLMs are, despite the promo, incredibly stupid.
1. Compile times. OCaml compiles very quickly (think Go) and this gives you a fast feedback loop. It lets the LLM rip through the implementation.
2. OCaml has an idiomatic approach of using interface files for all modules that can be accessed outside their libraries, and interface files give LLMs a great précis of exactly what is wanted. They then just have to follow the types and fill in the blanks to get the implementation. It's nearly the perfect use case.
Both force the model to reason about types too much. The more constrained type system plus global inference merely holds them to what they already wrote, with very fast feedback.
Rust is fine if you need it but most things don’t and ocaml has more convenient abstractions for “regular” work. If you need rust you need rust but ocaml isn’t that far off in perf.
Haskell type system is too expressive, it itself becomes a place for the agent to make mistakes and get bogged down.
Yes I contributed code to a paper on it this spring. It’s hard to measure and “studying” it just means feeding money into frontier models. If anyone has a few billion tokens for a couple masters students hmu so they can get it published.
I'm interested too - besides the paper, is it your personal experience that working with llms on ocaml is superior to other languages? I thought with the sheer amount of training data languages like python and java would be "ideal"
[1] https://www.youtube.com/watch?v=9Cswiqrq6So
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.
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.
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.
Also OCaml lets you write imperative code if you wish so. So you can learn the different paradigms within the same language.
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?
I still think it worth my time kneading dough by hand. It teaches me the various properties of flour, how external factors like humidity or temperature impact the overall process, and I believe that it makes me a better baker, even when I use a machine, because I am better at controlling what the machine does. When I get a new brand of flour I will make sure to bake everything by hand first to "get a feel".
Kneading by hand is also very relaxing to me. This is probably the main reason I bake in the first place.
Programming, and other activities are not very different. We now have machines that can do it faster, at a fraction of the quality many people deem good enough. If you hate coding, that is probably all you need to use, and learning a new language might just be a frustrating experience not worth subjecting yourself to. But if you enjoy coding then it should make you better at it, even when you use the machines.
the average person spends 6(!) hours a day on their smartphone, the average TikTok user spends 100 minutes on the app alone. This isn't about artificial scarcity, it's about the average person looking like the Wall-E people
People who are asking these questions are saying "will me spending my time learning OCaml help me land that job that pays six figures and has health insurance so I can not rot away living on the margin". They aren't saying "I only do things that will make me money".
again, it's not a small window. It's six hours. That's almost half your waking day. People spend virtually their entire leisure time rotting away on low quality entertainment.
>will me spending my time learning OCaml help me land that job
that's a pointless question for one you never know if something will land you a job, new opportunities don't open up before you do something, secondly the relevant question is, should I stop doing X and start learning Ocaml, or Chinese, or take a welding class because all of that even if it doesn't work out beats scrolling through Instagram.
I don't even take offense with the idea that you engage in activity that makes you money, because pure selfishness on that front would be an improvement to what most people are doing now.
Also, it may very well be the decade of formal verification - if so, OCaml is a good place to be.
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.
[1] https://www.cs.cornell.edu/courses/cs3110/2025sp/
[2] https://pragprog.com/titles/tpp20/the-pragmatic-programmer-2...
An oblique explanation: https://croissanthology.com/earring
More recently, you had to go to the store and buy it, which meant you didn't have much variety.
Today, learning an instrument is for social status, inheriting the shine of the past, where music was rare and costly. The reason to learn an instrument today is because the former situation was romanticized.
It'll probably take a generation before people ease into guilt-free enjoying infinite, fully generated music.
I would rate them as about 5% true and 95% false, as explanation of the past and prediction of the future.
The satisfaction of learning to do something difficult isn't going away, and the social status associated with it won't either.
But what about the future generations skipping the step of learning the OCaml's, the C's, the Python's...? It's quite concerning.
Oh by the way, yes. Learn OCaml!
That being said, you may as well use Rust. The extra complexity of manual memory management and Rust idiosyncracies are easily dealt with by the LLM.
Personally I try to stick within my own niche though - ruby, java and also python (ruby is unfortunately losing grounds really hard now, the writing was on the well in the last some years though, and people such as DHH are now indeed a liability rather than an asset to be had, but that's a side topic).
I think what LLMs will force in the long run is to make programming languages used by real humans in a traditional way, more effective. That is, writing code by humans will have to become a lot more efficient, both time-wise and speed-wise. And for that there is always a use case IMO since LLMs are, despite the promo, incredibly stupid.
Hhhmmmmm
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.
I looked for Qt bindings but they appeared to be abandoned last time I checked.
For Linux UI.
The PDF on the other hand gets to use zlib for streaming all the objects. It gets half decent compression.
* Other “pure” hindley-milner languages are tied but among them ocaml has some particular strengths that I’m sure others will discuss.
(I have my own answers, but I'd love to hear yours, too.)
2. OCaml has an idiomatic approach of using interface files for all modules that can be accessed outside their libraries, and interface files give LLMs a great précis of exactly what is wanted. They then just have to follow the types and fill in the blanks to get the implementation. It's nearly the perfect use case.
Rust is fine if you need it but most things don’t and ocaml has more convenient abstractions for “regular” work. If you need rust you need rust but ocaml isn’t that far off in perf.
Haskell type system is too expressive, it itself becomes a place for the agent to make mistakes and get bogged down.
(2) performance
They had originally planned on june and my part is in so…. Me too.