7 ms·
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” hi
by giraffe_lady 11d ago
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.
- nine_k 11d 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 11d ago(1) complexity (2) performance
- giraffe_lady 11d 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 11d 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 11d agoFlamebait aside, has this been studied for real ? Curious how you would rate that...
- giraffe_lady 11d agoYes 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.
- yawaramin 11d agoI'd be very interested to read this paper when it comes out.
- giraffe_lady 11d agoI 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.
- Fiodel 11d agoI'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"
- giraffe_lady 11d agoNo it’s more about speed and quality of the feedback loop. So you want the compiler that catches the most stuff when given the least information.
- rybosome 11d agoCan it not be studied with open weight models? This is a genuinely curious question, not an attempt at scoring a point.
- steve1977 11d agoDid you also compare F#?
- sroerick 11d agoCouldn't agree more. Even when the models could barely write it, the compiler was so good
- mchaver 11d agoFor web frontend, it's derivative programming language, rescript, is also a secret weapon because of types, fast compilation times and first class support of React. Using React in rescript is much nicer than TypeScript.