5 ms·
Learn Programming with OCaml
- throwaw12 3mo ago> 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?
- ivolimmen 3mo agoKeep using your brain or you will forget stuff. Doing puzzles is great, programming in new languages is also great.
- adalacelove 3mo agoShould you learn history if it is already written in a book? Should you live if others are already living?
- xiaoyu2006 3mo agoYou 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.
- f1shy 3mo agoThis. The question can be seen like “should I learn to solve sodoku, if a computer can do it better?”
- _HMCB_ 3mo agoThis ^
- underlipton 3mo agoAs 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.
- deleted 3mo ago[deleted]
- Barrin92 3mo ago>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
- Avicebron 3mo agoEscapism 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".
- dadoum 3mo agoMy 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.
- f1shy 3mo agoMy 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)
- ahoka 3mo agoWhy learn an instrument when you can just press play?
- a2ff6eeb0 3mo agoCultural 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.
- toolslive 3mo agoyour body needs exercise or you end up an obese couch potato. Your mind is similar: it needs exercise or you end up a dunce.
- deleted 3mo ago[deleted]
- jonahx 3mo agoThese theories sound vaguely plausible. 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.
- a2ff6eeb0 3mo agoSure, 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.
- sublinear 3mo agoWhat the hell else do you have to do?!
- monsieurbanana 3mo agoYou 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.
- sgt 3mo agoSeeing 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. Oh by the way, yes. Learn OCaml!
- nine_k 3mo agoOutsourcing all the thinking to machines may have consequences you might not like. An oblique explanation: https://croissanthology.com/earring https://croissanthology.com/earring
- doc_ick 3mo agoI mean if you want to let llms do everything for you go ahead. Wall-e implications aside, it seems like a great self centric life.
- henryrobbins00 3mo agoMichael 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/ https://www.cs.cornell.edu/courses/cs3110/2025sp/ [2] https://pragprog.com/titles/tpp20/the-pragmatic-programmer-20th-anniversary-edition/ https://pragprog.com/titles/tpp20/the-pragmatic-programmer-2...
- andsoitis 3mo agoI would sharpen my software engineering skills rather than coding / programming skills.
- RobRivera 3mo agoLLMs know it anyways? Hhhmmmmm
- yodsanklai 3mo agoLLM + static types is a winning combo. And if you want to be serious with what you do with your LLM, you need to understand the output to some extent. 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.
- fuldeka 3mo ago[dead]
- yawaramin 3mo agoPosting 'why should we learn' a programming language on Hacker News is top-quality ragebait :-D
- zem 3mo agoyou 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.
- sroerick 3mo agoLLMs are better at OCaml than any other language, and being able to read and think in OCaml is very helpful to understanding LLM generated OCaml code. Also, it may very well be the decade of formal verification - if so, OCaml is a good place to be.
- shevy-java 3mo agoI 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.
- debo_ 3mo agoI 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.
- bigstrat2003 3mo agoYes. LLMs do not know anything, and they will make mistakes as a result. You have to be able to check their work if you wish to do a good job.
- lenkite 3mo ago> So (asking genuinely), should we learn these things? I wanted to learn a functional programming language with powerful type capabilities and I chose the Lean Language for that and not OCamel or Haskell. Reason being: Better type system (dependent types!), applicable in formal domains and can use it to learn math too. For your bread and butter programming, there is already JS/Go anyways. So don't see much point in learning OCamel.
- rramadass 3mo agoThis mindset (i.e. LLMs are available so why do i need to learn anything?) is highly insidious and will destroy your brain/mind/future if you let it. Humans are the ones who Understand, while LLMs only Know. So inter-disciplinary/cross-disciplinary insights, new modes of thinking/reasoning, flashes of insight etc. are still in the purview of Humans only. AI/LLMs can help focus and short-circuit the study of various subjects but their understanding can only happen within a human "Mind". If you do not even have basic domain knowledge (i.e. unknown unknowns) how can you even prompt/query an LLM for answers? A few illustrative examples; a) Newton came up with limits/calculus out of a need to measure continuous motion with varying speeds b) Kekule came up with the benzene ring from a dream where he saw a snake grab its own tail c) Descartes came up with the cartesian coordinates in an attempt to solve geometry via algebra etc. Each of these was a novel leap of insight bringing together various concepts to create entirely new knowledge domains. So one should learn/study the core concepts/ideas in various domains and then push the tedious mechanical labour onto the machines. In this regard see also the concept of "Active Learning" - https://en.wikipedia.org/wiki/Active_learning https://en.wikipedia.org/wiki/Active_learning
- andai 3mo agoShould I continue to walk, when technology can move me from place to place? https://tenor.com/view/tf2-wall-e-team-fortress-2-autobalance-tf2-autobalance-gif-15817843004496366015 https://tenor.com/view/tf2-wall-e-team-fortress-2-autobalanc...
- zvmaz 3mo agoTangentially, a great interview with the creator of OCaml, Xavier Leroy [1]. [1] https://www.youtube.com/watch?v=9Cswiqrq6So https://www.youtube.com/watch?v=9Cswiqrq6So
- rramadass 3mo agoThe entire series of interviews with various language designers by Ryan Peterman is really great and a highly recommended watch. It gives an insight into how they thought/think and what we can learn from them. While watching the series i was stuck by the fact that they often only focused/reiterated the conceptual basics and building on top of them in a step-by-step manner. Whereas if you watch interviews with programmers (even famous ones) you will often see a lot of fancy talk about the complicated features of the language etc. I believe "Experts" have a way of modeling domain knowledge in their mind in such a way that they intuitively know what is the "wheat" and what is the "chaff". This is what we need to learn. Scheme can do a lot with a minimal language and so can C++ on the other end of the spectrum. So then what constitutes "Programming"? It is simply an expression of Intent via syntax supporting abstraction of state/behaviour.
- giraffe_lady 3mo agoOCaml is the LLM secret weapon right now. They are better at writing it than they are any other language.* That’s all I have to say about it. * Other “pure” hindley-milner languages are tied but among them ocaml has some particular strengths that I’m sure others will discuss.
- nine_k 3mo agoTwo genuine questions. (1) Why not Rust? (2) Why not Haskell? (I have my own answers, but I'd love to hear yours, too.)
- throwrioawfo 3mo ago(1) complexity (2) performance
- giraffe_lady 3mo agoBoth 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.
- yawaramin 3mo ago1. 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.
- phtrivier 3mo agoFlamebait aside, has this been studied for real ? Curious how you would rate that...
- veqq 3mo agoWhy is the PDF smaller than the Epub file?
- deleted 3mo ago[deleted]
- tangus 3mo agoProbably vector-drawn diagrams are rendered into bitmap images for the EPUB version.
- shakna 3mo agoThe ePub contains both SVGs and PNGs, the latter of which doesn't compress all that well for "plain zip", which an ePub is. The PDF on the other hand gets to use zlib for streaming all the objects. It gets half decent compression.
- sweetjuly 3mo agoI 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.
- nestorD 3mo agoI 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.
- rahimnathwani 3mo agoHow old were you?
- nestorD 3mo agoI started programming at 18 right after highschool (which, I guess, is late by HN standards: a number of my peers had played with Python first and hated Ocaml).
- fat-chunk 3mo agoWhen 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.
- amelius 3mo agoWhat is the recommended GUI framework for OCaml? (Please don't say HTML)
- foretop_yardarm 3mo agoCamlkit-gui for macOS
- amelius 3mo agoAnything for Linux? Or cross-platform? I looked for Qt bindings but they appeared to be abandoned last time I checked.
- e12e 3mo agoI see that unison (file sync tool) seems to use: https://garrigue.github.io/lablgtk/ https://garrigue.github.io/lablgtk/ For Linux UI.
- lambda_foo 3mo agoGTK4 bindings https://github.com/chris-armstrong/ocgtk https://github.com/chris-armstrong/ocgtk
- yawaramin 3mo agoWhat language and framework do you use for GUI programming?
- 3mo ago
- Fervicus 3mo agoOCaml programmers, what learning resource would you recommend starting out with? I know there's https://cs3110.github.io/textbook/chapters/basics/intro.html https://cs3110.github.io/textbook/chapters/basics/intro.html. How does this book compare? Anything else you would recommend?
- shevy-java 3mo agoI 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.
- debo_ 3mo agoOcaml is ancient at this point. It's never going to be python, but I doubt it's going to disappear.
- htl 3mo ago[dead]
- tialaramex 3mo agoI believe that an ML should be the First Language for Computer Scientists. It's much less clear which language we should teach people for whom it will likely be their Only Language, today Python is common, and for fields which care about stats often R is used, I've also seen Java used in this role. But for a First Language specifically I am in no doubt that an ML should be chosen, and this is despite the fact that the University where I work has taught Java for decades and Python most recently as First Language. I'm an old man, I learned the Standard ML of New Jersey when I was an undergraduate many years ago, but I'm pretty sure that experience though it isn't irrelevant, did not overly colour my belief in what we [speaking broadly of humanity] ought to teach.
- MeetingsBrowser 3mo agoAn ML is great for the theory or abstraction side of programming, but C is also hands down the best language to get a sense of how the computer is running your program. It’s still an abstraction, but at least being aware of memory management, copying vs referencing, etc are hugely important concepts that ML languages can hide.
- xiaoyu2006 3mo ago> It’s still an abstraction C is still heavily abstracted. Modern OS evolved in conjunction with C s.t. it behaves like a C runtime simulating a PDP11 (I remember reading a nice article on that). To learn system, what you need is an OS course, not C. I'd say the current C-based stack is in a quite embarrassing state.
- siev 3mo agoProbably thinking of this article: "C Is Not a Low-level Language: Your computer is not a fast PDP-11." https://queue.acm.org/doi/10.1145/3212477.3212479 https://queue.acm.org/doi/10.1145/3212477.3212479
- hnfong 3mo agoSure, you need an OS course, but that's when students should learn C as well.
- jan_m_savage 3mo agoThis 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.
- ratorx 3mo agoYeah, 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.
- jan_m_savage 3mo agoIndeed--so the title is somewhat misleading. Agree with you wrt to REPL, though sooner or later the programmer-wanna-be has to embrace technical sophistication. :)
- netfortius 3mo agoThe 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?
- lngnmn2 3mo ago[dead]
- __rito__ 3mo agoThis 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. [0]: https://cs3110.github.io/textbook/cover.html https://cs3110.github.io/textbook/cover.html
- iLoveOncall 3mo agoDon't learn programming with OCaml, it's horrible.
- lefessan 3mo agoThis 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...
- rramadass 3mo agoA 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.
- jiehong 2mo agoThe standard library could be better, though.