|
|
|
|
| Departments > DLDC > Programming > Programming Languages | ||
The OCaml programming language is used extensively at the DLDC to write many back-end data processing tools, utilities and one-shot programs.
OCaml is in the FreeBSD ports and the pkgsrc; it comes pre-installed on some Linux distributions, and RPMs are readily available; it's also available via Darwin Ports and Fink on Mac OS X. However, I prefer to install OCaml via GODI, a platform-independent OCaml-specific package manager, which provides an easy way to install OCaml from source. The GODI distribution includes dozens of essential third-party libraries and makes it easy to install them, upgrade them, and keep them all in sync. I install GODI under /usr/app/godi/; to use the compilers, add /usr/app/godi/bin/ to your PATH.
I like to statically-link OCaml native-code apps to get single-file executables that can be installed on a new box with a single cp command (with no prerequisites like an interpreter or run-time system). But, since OCaml doesn't have a cross-compiler, in order to build such executables, we need one compilation box for each OS / CPU "platform"1. Here's the official list of compilation boxes; some OS's (the BSD's) are very good at running binaries compiled on older versions of the OS, and some less so (Linux); problems usually have to do with missing old shared libraries, which is another reason static linking is nice.
Most of my OCaml apps rely heavily on my personal OCaml library, Kw. I install it on every OCaml build box. You can link with it (using ocamlfind) like so:
ocamlfind ocamlopt -linkpkg -package kw foo.ml -o foo
Documentation is available.
For more information about OCaml, including history, rationale, and pointers to books, tutorials, and documentation, see OCaml for the Skeptical; the slides from my course on functional programming also contain a lot of OCaml.
OCaml apps can also be compiled to a portable byte-code, which requires the OCaml run-time system to be installed. This might be considered an "easier" way to get an OCaml app running on an exotic platform, since you can install the run-time system any way you want (e.g. via a native package manager, rather than via GODI).