
Journal Journal: Ocaml for scripting
I've been finding myself using Ocaml more and more recently, mainly as a scripting language.
While I've been impressed with Python as a development environment, and find it excellent for expressing and playing with ideas, I do hate the fact that for an application of any size, delivery to others becomes a problem, especially if the application makes use of other libraries. I was bitten badly when it came to distributing an application based on WxPython, Numeric and Matplotlib, as the install requirements became a bit unmanagable.
Ocaml compiles to (lightning fast) executables, which solves the distribution problem, and has proven remarkably pleasant to come to grips with.
The combination of XEmacs and the Ocaml Tuareg mode is a dream interactive development environment, and I rarely feel the need for a debugger (Ocaml's doesn't work on WIndows, and unfortunately, this is what I have to use in my work), as the combination of a functional approach to design, coupled with the Ocaml type system, finds most bugs during interactive development.
If I could take one thing from Ocaml to other languages I use (especially C or C++), the type system is the one. It's almost magic!
Conventional wisdom is that functional languages are not well suited for scripting tasks. All I can say is that this is rubbish, in my recent experience.
By the way, I'd love to write a protocol stack in Ocaml. I reckon it would provide the performance of a native C version, in a quarter the number of lines of code, and with fewer bugs. Sometimes I dispair of my industry: this is the way to go, if anyone would take the chance...