Start Hacking in OCaml in 5 Steps
August 3, 2007 | 5 Comments
We love OCaml at Skydeck, as Jake has written about before, and we often hear from programmers with questions and comments about it. Some love OCaml, some don’t know anything about it, but many have it on their list of languages to try yet haven’t gotten around to it. Well, it’s pretty simple to get up and running — just download, build, and start hacking!
Really, it’s that simple. If you want to get there as quickly as possible, follow these five steps:
1. Download OCaml and unpack it
Get the “Source distribution for Windows and Unix systems”. You could download the binaries directly, but OCaml is really easy to build and you’ll appreciate having the source later. I also like having the PDF version of the User’s manual. If you’re running Windows, you’ll need to install Cygwin.
2. Build and install
The instructions to build are detailed in the INSTALL file that comes with the distribution. Here’s what we do (note all paths are relative to the directory where you unpacked OCaml):
- Configure your system. Fortunately, the distribution comes with a script to help you figure out whether you have the proper tools installed. If you’re missing anything, you’ll need to install it. That’s outside the scope of this post, but most Linux distributions come with package managers to make this easy (e.g. on Fedora, you use yum).
$ ./configure
- Build the distribution. OCaml can build bytecode and native code targets, and we build the compilers necessary for both by running:
$ make world.opt
- Install OCaml. The previous two steps can be run as a regular user, but the install step must be run as root (or via sudo). If you’re running with Cygwin under Windows, don’t worry about it.
# make install
3. Setup emacs
It’s well worth taking a couple minutes to get syntax highlighting and a slew of other features running in emacs. The simplest thing is to install the extensions that come with OCaml. As root, run:
# sudo make -C emacs install
At Skydeck, we use Tuareg. It comes with instructions for installing. It’s a little more of a manual process and needs to be tailored to your specific setup, so if you’re interested, just follow the instructions in the README that comes with it.
4. Work through the tutorial
Now that you’re ready to write code, the OCaml Tutorial is a great place to start. It will walk you through the language and get you going as quickly as possible.
5. Sign up for the mail lists
Sign up for both the and the ocaml_beginners and the caml-list.
That’s it! You’ll be writing tight code in no time.
Posted by: Mike
5 Responses to “Start Hacking in OCaml in 5 Steps”
mind on August 4th, 2007 2:39 pm
what a completely useless post.
steps 1 and 2 are outdated, and ocaml is probably already installed due to having said at one time ‘i should learn ocaml, so apt-get install ocaml’
step 3 is just a political statement. most likely if someone is a programmer, they already _have_ an editor they prefer working in.
step 4 is kind of the real step here. but your post could have simply been a link to the tutorial, then.
step 5 is going to help you stay in touch with the language, not actually do simple things to learn it, so in the absence of any other usefulness to this list, it doesn’t stand on it’s own
Samuel on August 6th, 2007 11:55 am
hmm…
> steps 1 and 2 are outdated . . . so apt-get install ocaml
I can’t resist. You mean, there are still people who use Debian?
> step 3 is just a political statement.
No, sorry, nothing in the instructions implies the user must use emacs. The make target is for installing the requisite elisp modules for getting Emacs to grok OCaml source for syntax highlighting purposes.
If you use vim, you’re more than likely familiar with the existance (and the religious war against) emacs. Ergo, any vim-using baffoon will have even that slight amount of experience to say, “Hmm…I can just GOOGLE for VIM scripts for use with OCaml.” Or just grab VIM 7, which has scripts bundled with it already, IIRC (at least mine does).
The rest of your comment just degenerates into useless blather. I suppose, a useless comment by a useless “mind”, for a “useless” article. I’m not even going to dignify its presence beyond this paragraph.
Samuel on August 6th, 2007 11:57 am
For the record, I’m a vim user. And I didn’t find this blog post useless at all. These folks are trying to get programmers who are fluent in OCaml. OCaml is not widely known as a language. It is in the company’s best interest to widen their pool of developers.
I do not work for SkyDeck. I work for another company, though, the products of which most people use every day of their lives without realizing it.
Tor on September 7th, 2007 12:34 am
Huh? Debian? Me!
I also use Ubuntu, so, again: “apt-get”.
Wait, I use Mac OS X too! With Fink! So, once more: apt-get.
But wait - there’s more! I am writing this on my Nokia N800 Internet Tablet. One more time — apt-get (though no “aptitude” on this one…)
Back to the point - let’s not forget that both Debian and its more sexy offspring Ubuntu both are continuosly growing their “market” share even on desktop Linux systems, at the expense of the various RedHat derived distributions (RedHat, Mandrake, Fedora, etc).
# apt-get install world-order
Reading package lists… Done
Building dependency tree… Done
The following NEW packages will be installed:
debian gnu gsm umts wimax frequency-standard
The following packages will be removed:
qualcom cdma microsoft whitehouse fcc
Need to get 713kB of archives.
After unpacking 25652356325kB of disk space will be freed.
Install these packages [Y/n]? _
mind on November 11th, 2007 12:56 pm
i don’t particularly care about steps 1-3. that’s not my point. my point is that this “tutorial” might as well read:
HOW TO LEARN OCAML:
1. learn ocaml
2. ….
3. PROFIT!!!
it’s the equivalent of a linkjacked blog post.