Thursday, October 2, 2014

Learning OCAML: OcaIDE

OCAML has a growing and loyal community behind it, OCAML.org is a great place to get in touch and contribute.
Nevertheless, in my journey I found in difficult to find much material that is tailored for a total noobie.  This is why I decided to document my journey towards functional-language enlightenment, namely by learning and using OCAML language for  developing the MoanaML  project. Your feedback, guidance and contributions are most welcomed.

So here were are, let's start exploring...our glory awaits! :) By the way, I am running Ubuntu 14.04, so most of my tips will be related to it.

I tend to learn most by doing and to do something useful you need the right tools.

Therefore I think the first post about my journey should be on finding and using the right IDE 1. There are not many options around, but there are a few. Your main trade off is on how much time you spend fiddling with them.

I tried a few in all the cases I had to tweak the settings and configuration to get reasonable performance. In the end, I started using OcaIDE, which is a plugin for Eclipse. It is far from perfect, but gives you the initial support a noobie might need to get started.

  • Source editor for modules (ml files), interfaces (mli files), parsers (mly files) and lexers (mll files)
  • Syntax coloring (colors and styles are configurable)
  • Automatic indentation while typing in the editor (configurable in the preferences)
  • A customizable integrated code formatter, and an interface to the camlp4 formatter (through an AST printer)
  • Completion
  • Library browser, both for the standard library and user libraries

    . . . and much more.

Out of all the Eclipse plugins OcaIDE works pretty much out of the box. However you need to make sure you specify your build command in the Project preferences. This is also the right place to specify all the libraries and/or external packages the you are planning to use in your project.

In any case, the OcaIDE project offers Flash-based tutorials on how to set-up and best utilised your developing environment.

You can find step-by-step instructions for it here from guys in UPenn, which include info on how to install OCAML, Eclipse and finally OcaIDE.
A nice summary of how to install OCAML on different enviroment is also presented by the OCAML.org here.

There is plenty of discussion online about a suitable IDE, here are the links to some of it:







1 I am not a big fan of Vim and Emacs, so I wanted to find and IDE that gives me slightly more than just syntax highlight and indentation - just kidding :)  This  is a very gross underestimation of the true power behind Vim and Emacs editors, they are truly powerful tools once you master them. I guess in my case, I preferred to minimize my effort on fiddling with the developing environment and remembering key combinations and rather focus on the OCAML language itself. Nevertheless, as it turned out, choosing an IDE introduced plenty of fiddling with configuration as well. You can find numerous Stack Overflow discussions about it online.

No comments:

Post a Comment