Live data from Hacker News

Learn Programming with OCaml

usr.lmf.cnrs.fr

41–50 of 147 posts

Re: Learn Programming with OCaml

#41

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 O…

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.

Re: Learn Programming with OCaml

#42

Earlier quoted context omitted.

Flamebait aside, has this been studied for real ? Curious how you would rate that...

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'd be very interested to read this paper when it comes out.

Re: Learn Programming with OCaml

#43
post #22

OCaml 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.

Two genuine questions. (1) Why not Rust? (2) Why not Haskell? (I have my own answers, but I'd love to hear yours, too.)

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.

Re: Learn Programming with OCaml

#44

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 O…

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.

Re: Learn Programming with OCaml

#45

Earlier quoted context omitted.

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".

Re: Learn Programming with OCaml

#46

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 O…

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.

Re: Learn Programming with OCaml

#47

Earlier quoted context omitted.

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'd be very interested to read this paper when it comes out.

I will add you to the list, I’ll definitely post it on HN also.

They had originally planned on june and my part is in so…. Me too.

Re: Learn Programming with OCaml

#48

> 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?

LLM + 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.

Re: Learn Programming with OCaml

#50

Earlier quoted context omitted.

I'd be very interested to read this paper when it comes out.

I will add you to the list, I’ll definitely post it on HN also. They had originally planned on june and my part is in so…. Me too.

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"
Post reply on HN