Sunday, August 29, 2010

Towards a Statically Typed Universe? Fun with ocaml

When I was younger, i was a zealot of static types. Today, I admit that I have more fun working in dynamically typed languages (namely JavaScript).

Now I'm older, I find that using the right tool for the job is the best way to ensure professional happiness. The type system is just a tool to be utilized to gain either a sense of correctness or performance.

While in my heart, JavaScript wins these days for my hobby coding, I'm diving into OCaml for fun.

It seems to me that statically typed languages are converging (or, trying to converge) in terms of happiness towards dynamically typed languages. It is as if the promoters of statically typed languages are actively working towards "programmer happiness". Well, with languages like Ruby and JavaScript, there is a massive debt to be paid.

Paying off a bit of the debt

I remember when compile time was a big black mark on statically typed languages. Back in the day, when CPU power was limited, this was a talking point against compiled languages since compiling was a major interruption to the flow of work. Now, the issue seems to be a matter of productivity. For instance, working in C# with KayakHTTP is a huge PITA. I have to close the running server, compile, start it back up again, switch to my browser, and finally I need to hit refresh. This takes too freaking long.

Well, I discovered an awesome *nix tool that really helps in streamlining the process for my new (unannounced) project.

inotify-tools

I recommend checking it out (in your flavor of *nix).

For me (your mileage may vary), this enables me to work with node.js and ocaml very efficiently. I can treat server side development the same as I do web based development. That is, i save my file and refresh my browser. Now, I just need a Firefox plug in to listen for refresh events on some socket (or other mechanism).

How?

Here is how I use it for developing new project. The general pattern is
  • wait for file changes
  • kill
  • compile
  • launch
I hope you find this technique useful because it makes my life better.

1 comment:

  1. Let me suggest that you look into http://omake.metaprl.org which has a -P option to scan your disk for changes. That and http://ocsigen.org make a very nice combination for web development in OCaml. :-)

    ReplyDelete