More than a year ago I decided to dismiss my Wordpress blog, and to write a new one from scratch in OCaml. Unfortunately my spare time for programming projects is getting less and less, so this simple work took a lot of time to reach an usable state.
I put online a preliminary release a month ago and immediately several bugs and little problems have arose, so I had to pass through the usual karma of recurring corrections. Now it seems stable.
Software design (strong words, actually!)
Ocamlnet is an excellent network framework, but it offers a low level interface, if compared with Ocsigen, which is web specific. Ocsigen (Eliom, actually) is a complete, modern and mature web framework, and I was afraid I couldn't use it, but AFAIK it lacks the possibility to create a FastCGI executable. I need this kind of setup because the blog runs on a production server of mine, where Apache is already installed and many virtual hosts are configured to run several sites and web apps, written in Django (Python) or even PHP.
To write the blog
I stole many ideas I was inspired by many ideas taken here and there. It's fair to list them, and to thank the authors:
- from Eliom I took the idea of a way to create the parameters of the web page in a type safe way, using some combinators that describe the expected type of the parameter and rebuild it from the CGI string from the browser. The implementation present in Eliom is of course outstanding, while my piece of code just solves a small subset of the problem of parameters reconstruction;
- the blog of Mauricio Fernández is written with Ocsigen (source here) and contains a simple markdown-like language processor used to format comments. I wrote something like that, but I'm learning to write parsers combinators so my implementation only processes a subset of the language recognized by Mauricio's parser;
- Jake Donham wrote lwt-equeue as part of the orpc project. It's a module providing the same interface of Lwt, but runs on equeue, the low level event loop engine of Ocamlnet, and I used it to write a simple SMTP client in a monadic way without having to drop Ocamlnet and FastCGI;
- Batteries is of course used almost everywhere;
- as a template engine to render HTML I used CamlTemplate by Benjamin Geer (maintained by Dmitry Grebeniuk).
The resulting software is far from being well structured and designed, but I wrote yet another blog exactly to have the opportunity to test many libraries and programming paradigms in OCaml and, with respect to this goal, the result is a success :-)
While the code is a mess, the blog itself has many useful features: a very simple administration to edit posts, RSS feeds, comments, antispam, and a completely useless URL shortening service available at http://www.donadeo.net/u.
What about the performance of the whole object? I don't know how to realistically test the blog, because using the classical
ab is rather pointless, since it is generally used with static resources that, in my case, are served by Apache. If someone has some good ideas about 1) how to make a stress test and 2) have some good reference in term of expected hit per second, please don't hesitate and contact me, of course to blame me about how the blog is slow.
The blog is up and running and I don't see any particular bug. In the next months I'll probably add some features, like the possibility to follow comments via email, or a decent XML site map.