9/3/08

Riding the camel - OCaml opinion (i)

I have started just a few weeks ago using OCaml. My only serious experience with a functional programming language was with Erlang, but I really liked it. I liked the shift of paradigm (although I am such an OO progammer (learned to program with Ruby), it was not difficult at all). Here are some of my thoughts about it.

Being a strong typed language for being functional at first sight seems cool. You can have all the benefits of typedness without actually the blot of the extra typing. Actually, it is, but it has its cons.

I really have nothing to complain (yet) about OCaml except for it's output libraries. I really miss my [puts | print | Console.Print | even the fugly System.out.println]. Debugging is a pain not as easy as another languages, just because of the printing. Not debugging itself, but unit testing, as part of test driven development (TDD), something relatively new to my and which I'm falling in love with.

I don't know whose fault it is, if the language itself for not being flexible with the types (at least the very basic ones) or the libraries. I know about some external libraries (MetaOCAML, Sexp, extlib) that try to handle this, but having to rely on external libraries leaves much to desire of the language.

The other thing I find annoying is that the compiler just points the first error it encounters. It's trivial for small files, but I'm scared of what can happen with larger files. Fortunately, TDD helps you not to commit those mistakes, at least not catastrophically.

Maybe the OO part of OCaml has it's advantages, and I want to think it has because pure functional programming in OCaml is not the way one would like, at least not me. But I have not explored that yet. My next goal: functors.

CC by shamiska

Well, all of this is because we are developing a Web framework on school, which had to be done in a functional language. It seemed like the perfect opportunity to learn another language, so I decided to give it a shot. I don't post the link of the project (although it's GPL3), because I don't know if I am able to do it given it is a school project, but once I can I would share the result with you.

No comments: