Pathway for learning OCaml?

I’ve decided to pick up learning OCaml. I would like to start improving my CS knowledge and eventually work on problems I find more interesting such as compilers, developer tooling, and database systems.

  1. What courses or books would you recommend? For now I’m starting off with CS3110 and Real World OCaml.
  2. What blogs, YouTube channels, Github profiles would you recommend that I follow?
  3. What pitfalls should I be aware of or difficulties you experienced when first learning OCaml?
  4. What resources would you recommend to for learning more about type theory and memory management? I have a lot of interest in refinement types, dependent types and linear types.

Some non-ocaml specific software I find incredibly interesting that I would love to to take a stab at prototyping in OCaml for my own learning in the distant future.

~Link work around since I'm a new user.~
1. https://github.com/dolthub/dolt
2. https://github.com/tree-sitter/tree-sitter
3. https://github.com/HaxeFoundation/haxe (How I first got exposed to OCaml)
4. https://github.com/LingDong-/wax
5. https://github.com/macroing/Dayflower
6. https://github.com/dosco/graphjin
7. https://github.com/PostgREST/postgrest
5 Likes

One of my own still going strong pitfalls is digging too deep into specific type-theory issues instead of focusing on the product I’m writing. :wink: The type-system is an easy rabbit hole to fall into.

Oh, and now I see your forth point, proving my point. :joy: If you hate life, check out F*, it’s cool. But don’t bend OCaml to something it’s not supposed to be, your code will become non-idiomatic.

Esp. with your #4 goal, maybe it’s worth thinking about following a somewhat standard first-year grad student PL semantics/types course? I’m old enough that the “recommended textbooks” have all changed, but I remember hearing good things about Benjamin Pierce’s types textbook. There are almost certainly other good ones.

I’ve also heard good things about The Little MLer.

I’m old enough that most of what I know about functional programming came from Henderson’s Functional Programming (really old, out-of-print). I learned a lot about denotational semantics from M.J.C. Gordon’s The Denotational Description of Programming Languages.

Last, I always recommend to people that they read and work thru Huet’s The Constructive Engine: a fantastic explanation of how to do induction on a complex datatype with a nontrivial equivalence relation.

2 Likes

OCaml seems to be pretty well-suited to the problems you’re interested in: compilers (obviously), developer tooling (can create pretty efficient tools with OCaml, e.g. Unison), and databases (e.g. Irmin).

  1. Are you watching the CS3110 YouTube videos?
  2. The OCaml blog seems to collect several others: OCaml Blog
  3. Watch out for the ‘dangling else’ syntax problem (nested if/match expressions), and reading module signatures can be a little daunting at first, but it pays off after a while
  4. Benjamin Pierce’s Types and Programming Languages (incidentally, he also wrote Unison)

Re: PostgREST–I find projects like this very interesting, e.g. GitHub - bradleyboy/tuql: Automatically create a GraphQL server from a SQLite database or a SQL file , because they can potentially solve the object-relational impedance mismatch problem and eliminate the need for ORMs. That would be a pretty big deal.

2 Likes

@olleharstedt
If you hate life, check out F*, it’s cool. But don’t bend OCaml to something it’s not supposed to be, your code will become non-idiomatic.

Fancy type systems are definitely a rabbit hole, but they’re just so interesting! As for F* I cannot seem to find this tool. I stumbled upon this if this is what you were referring to: GitHub - yallop/fomega: System Fω interpreter for use in Advanced Functional Programming course

@Chet_Murthy
I’ve also heard good things about The Little MLer

Last, I always recommend to people that they read and work thru Huet’s The Constructive Engine : a fantastic explanation of how to do induction on a complex datatype with a nontrivial equivalence relation.

I’ve heard a lot of good things about the various Little series books, thanks for reminding me. Also I haven’t heard of Huet’s The Constructive Engine before, I’ll give it a look, but currently it may be beyond my abilities. http://gallium.inria.fr/~huet/PUBLIC/siromoney.pdf

@yawaramin
1.Are you watching the CS3110 YouTube videos?
2.The OCaml blog seems to collect several others: OCaml Blog
3.Watch out for the ‘dangling else’ syntax problem (nested if/match expressions), and reading module signatures can be a little daunting at first, but it pays off after a while
4.Benjamin Pierce’s Types and Programming Languages (incidentally, he also wrote Unison)

  1. I am watching the CS3110 lectures and they’re very well done. I greatly enjoyed the Pokemon based ADTs lecture. :rofl:
  2. It looks like the OCaml blog is primarily filled with posts from a company called Tarides. They look like the core maintainers of OCaml or at least a large amount of the core ecosystem?
  3. That’s a really good tip I hadn’t considered that as an issue. Dangling else - Wikipedia
  4. I’ll take a look Benjamin Pierce’s writing, thank you!

I agree about PostgREST. I hope that in the future backend generation tools will become the norm. Irmin looks interesting and I bet it would pair well with Dolt, but the docs are bit hard to follow/non-existent(?).

I’ve noticed a lot of OCaml docs are really hard to follow and I wish docs similar to Dream — Tidy, feature-complete web framework were more common. I’m used to javadocs and haxe docs which in my opinion are much easier to grok.

I note that you list two, somewhat orthogonal, goals: learning OCaml and improving your CS knowledge. Regarding the latter, don’t ignore the plethora of SML books that are available. The syntax is close enough to OCaml that it’s easy enough to go back and forth and those texts are typically more academic and therefore have more CS theory. As someone who doesn’t have a CS background, I found Paulson’s ML for the Working Programmer really helpful when I first started with OCaml.

2 Likes

Hello and warm welcome! :slight_smile:

The reference there is to https://www.fstar-lang.org/

1 Like

A lot of things are interesting. Also make sure they relate to your goals in life.

http://fstar-lang.org/

Edit, oops, already linked. :slight_smile:

1 Like

Those seem like great projects just to try to rebuild yourself! Start today and you won’t regret it.

It’d be really exciting to see a port of postgrest to ocaml just for the heck of it. Try using ocaml5 / domainlibs / eio to spice things up.

Recently I’ve been having a lot of fun just rebuilding existing things without attaching any prospect of revenue: porting the etherjs lib to ocaml, and wrapping cohttp eio in an easy-to-use manner.

1 Like