As someone interested in learning OCaml, this felt like a pretty inaccessible introduction.
Having seen "A tour of Elm,"[0] I really prefer that style. The left-hand side (what English readers read first) is an explanation of the concept, then the right side is the code, and the explanation gives you enough details to complete the code.
This introduction doesn't really explain anything, as I guess it assumes you've learned OCaml elsewhere and are just here to practice.
I tried the first exercise, and it felt more like a math problem than an exercise to teach a programming concept:
>Suppose that a variable x exists and is an integer.
>Define a variable x_power_8 that uses three multiplications to calculate x to the power of 8. The only function you are allowed to call is the (*) operator.
>Hint: use auxiliary variables.
So, at first I thought I was supposed to just call multiply eight times, and then I realized that they said you can only call multiply three times. So, you're supposed to do let a = x * x; let b = a * a; let x_power_8 = b * b. But that feels really contrived to me and not like anything I'd write in a real application, even a toy one. If the idea is teaching variables, why not just ask me to declare a variable that represents x plus 1?
Loved using OCaml for a compiler course at uni when I was a student. But I've always felt that the tooling side is pretty rough, especially on Windows. Opam recently added Windows support, but it involves installing MinGW, and when following the official docs https://ocaml.org/docs/installing-ocaml#install-platform-too... the process breaks down with an error when trying to install utop due to a path separator error, which one has to fix manually (at least that was the case last time I tried). By comparison, installing Python or Rust on Windows is a breeze.
Dune is a very powerful and good build system — it can do some very magical and useful things. The only problem is most of these useful features are very poorly documented…
picked up ocaml back when prepping for some interview round, didn’t expect much just wanted the functional knowledge. but later used it for advent of code and it just worked so clean. pattern matching, recursion, immutabilitty.. fits those problems naturally. ended up liking the language way more than planned.
OCaml is like nim, not many ppl knows about, but it is one those tech once over the learning curve it just gives developer an extra edge.
It is a very good alternative to memory safe language such as Rust and Swift. It is just NOT backed by big corporations. Which some might see it as a disadvantage, IMHO it is an advantage. Look at Perl, Linux, Hono all initially made by one guy.
With out a big group, golden handcuffs and corporate politics, things might actually gets done.
Probably the biggest sectors where functional programming is used are finance and crypto (which is arguably finance). Some companies use OCaml itself, other companies might use other languages like Haskell where OCaml knowledge would be valuable.
The trading firm Jane Street is the big OCaml shop, they have a great podcast about all their tech. Each episode is someone from a team talking about the tool they've built, and their whole ecosystem is pretty much bespoke OCaml tooling.
As someone interested in learning OCaml, this felt like a pretty inaccessible introduction.
Having seen "A tour of Elm,"[0] I really prefer that style. The left-hand side (what English readers read first) is an explanation of the concept, then the right side is the code, and the explanation gives you enough details to complete the code.
This introduction doesn't really explain anything, as I guess it assumes you've learned OCaml elsewhere and are just here to practice.
I tried the first exercise, and it felt more like a math problem than an exercise to teach a programming concept:
>Suppose that a variable x exists and is an integer.
>Define a variable x_power_8 that uses three multiplications to calculate x to the power of 8. The only function you are allowed to call is the (*) operator.
>Hint: use auxiliary variables.
So, at first I thought I was supposed to just call multiply eight times, and then I realized that they said you can only call multiply three times. So, you're supposed to do let a = x * x; let b = a * a; let x_power_8 = b * b. But that feels really contrived to me and not like anything I'd write in a real application, even a toy one. If the idea is teaching variables, why not just ask me to declare a variable that represents x plus 1?
[0] https://a-tour-of-elm.axelerator.de/#JSFunctions
Loved using OCaml for a compiler course at uni when I was a student. But I've always felt that the tooling side is pretty rough, especially on Windows. Opam recently added Windows support, but it involves installing MinGW, and when following the official docs https://ocaml.org/docs/installing-ocaml#install-platform-too... the process breaks down with an error when trying to install utop due to a path separator error, which one has to fix manually (at least that was the case last time I tried). By comparison, installing Python or Rust on Windows is a breeze.
Even in Linux, I'd say the tooling is a bit rough, dune and the new lsp are going in the right direction though.
Dune is a very powerful and good build system — it can do some very magical and useful things. The only problem is most of these useful features are very poorly documented…
The sluggishness of setting up new opam switches is definitely limiting in my experience
picked up ocaml back when prepping for some interview round, didn’t expect much just wanted the functional knowledge. but later used it for advent of code and it just worked so clean. pattern matching, recursion, immutabilitty.. fits those problems naturally. ended up liking the language way more than planned.
If I learned OCaml, what type of prospects would I have?
Fairly seasoned generalist, mostly writing Go these days. Lots of plumbing with LLMs etc.
Would love to learn something new but am driven by a goal in mind (ie OCaml exposes me to "X industry")
Is that a thing?
OCaml is like nim, not many ppl knows about, but it is one those tech once over the learning curve it just gives developer an extra edge.
It is a very good alternative to memory safe language such as Rust and Swift. It is just NOT backed by big corporations. Which some might see it as a disadvantage, IMHO it is an advantage. Look at Perl, Linux, Hono all initially made by one guy.
With out a big group, golden handcuffs and corporate politics, things might actually gets done.
Lots of cool stuff does seep out of Jane Street, though. See for example https://oxcaml.org/ as probably the most recent very public example
Probably the biggest sectors where functional programming is used are finance and crypto (which is arguably finance). Some companies use OCaml itself, other companies might use other languages like Haskell where OCaml knowledge would be valuable.
You can see a list on the OCaml website of companies using it, or read some success stories (https://ocaml.org/industrial-users).
The trading firm Jane Street is the big OCaml shop, they have a great podcast about all their tech. Each episode is someone from a team talking about the tool they've built, and their whole ecosystem is pretty much bespoke OCaml tooling.
- https://signalsandthreads.com/
(It's one of three programming podcasts I consistently listen to these days, the others being On The Metal and Developer Voices.)
Learning OCaml exposes you to the sadomasochist industry, that's about it.