Apparently, the internet also has a "Getting started with OCaml" guide. My guide will remain competitive by being much more concise (and therefore, incomplete).
Steps to getting started:
- Download an OCaml compiler from somewhere. Other useful things to have are ocamlfind (which finds your OCaml libraries), ocamllex (for lexing), and ocamlyacc (for parsing). Another useful thing is OCamlMakefile, which helps you manage builds with Make.
- Read a tutorial or two. This is a good thing to read. Also, bookmark the Index of modules.
- Write some programs while compiling frequently. (Compiling too late in the game may cause death of the Ocaml experience.)
- If you want to lex and parse, look into ocamllex and ocamlyacc.
- OCaml is very similar to SML. The only different parts are loops and things like that. I try to stay away from those because they are creepy.
- The file extension is .ml; the file extension for interfaces is .mli. You don't need an interface file; without one you export everything by default.
- The contents of file somefile.ml are in the Somefile namespace, which you can open with "open Somefile." By default all of these little guys are exposed. You can hide things by creating modules and writing module interfaces. Read more about that here.
Some important things to know:
- OCaml is the future because (arguably) a lot of people are using it. It is the new big thing for scientific computing because you can actually get good performance out of it!!
- OCaml is more practical than Haskell for some things and also yields better performance more easily.
- One thing OCaml is not great for is backwards compatibility. Each new release of OCaml supposedly breaks a lot of things. From my understanding a lot of libraries change/break, causing everyone to experience organ failure.
- In fall of 2006, I spent a long time struggling with the MLton SMLNJ compiler. It gave me lots of obscure errors and I cried.
- From fall of 2006 to spring of 2007, I came to not only be master* of the MLton compiler but also the Moscow ML compiler. These compilers are not only difficult to use but also often difficult to install, so you should be very impressed.
- After learning SMLNJ was not really being maintained anymore, I said "screw this shit" and moved on to Haskell.
- In January of 2009, I realized** that OCaml is the future. For my next project I decided to use OCaml, which I picked up in an ad hoc ways throgh the steps above, skipping step 2 (but compiling very frequently). I am still in this step.
** Through a combination of talking to people about what people used for different things, trying to do 3D arrays in Haskell, and meeting myself at Xavier Leroy.