There is a common perception that you should choose your type system based on the scale of your project. If you're writing a little program (i.e., a script), you should use a dynamically typed language like Python or Ruby. If you're building a large complicated piece of software, you're better off with a statically typed language like Java or (for the adventurous) OCaml.
I've always suspected that this is wrong; that static types improve your life even when writing small programs, although the advantage is clearly smaller. At least, this should be true for statically typed languages like OCaml and Haskell whose syntactic overhead is fairly low. But I've never been able to fully convince myself of this, because there has always been a set of practical barriers that prevented me from using my favorite language, OCaml, in this role. For one thing, the standard OCaml distribution is very much a "batteries not included" affair. OCaml's standard library is well implemented, but it is small and idiosyncratic. Our own internal standard library,
core, is much more complete, but we don't want to check out and compile within our massive source tree every time we write a one-off script. And we don't want to have to keep these scripts up-to-date as our libraries evolve. Languages like Python and Perl do a great job of providing a stable platform for little programs.
A few months ago, we addressed some of OCaml's limitations in this regard by periodically stamping out "ocaml scripting environments": custom OCaml toplevels with some of our standard libraries baked in. You can use these interpreters as you'd use a python executable, by stuffing it into a
#! declaration at the top of a script. And we don't uninstall old versions when we roll new ones, so scripts based on an older install can continue working indefinitely without modification.
Now that we have this at our disposal, it's confirmed my suspicion that typed scripting is a net win. We've started using this for more and more, for everything from auto-generation of config files to nagios checks to scripts for sending emails.
My conclusion is that OCaml with the right libraries can be very lightweight, and that the type system is a big time-saver. When I create a new ocaml script, the type errors that the compiler detects are almost universally real bugs, and as such reduce the amount of time it takes me to go from nothing to a working script.
And to boot, when our first version is in OCaml rather than Bash or Ruby, it's easier (for us, anyway) to scale that script up to a real program if the need arises.
Are you a sysadmin who's not afraid of closures? Then break out of your shell, and apply for a job at Jane Street.