Howardism Musings from my Awakening Dementia
My collected thoughts flamed by hubris
Home PageSend Comment

Freemarker vs. Velocity

Once upon a time, in an earlier age, we web geeks were individually writing our own web frameworks and template engines to solve our immediate needs. I did one and you probably did as well. When our projects were done, we felt it a shame that the rest of the world couldn't bask in our wonderful frameworks, and so many of us donated them.

Velocity was one of those that was donated into Apache's Jakarta project. It had a lot of merit in that it was just a template engine and could be used for more than just web pages (however, it was used as the basis for other web frameworks, such as Turbine).

Velocity is simple … perhaps a bit too simple, and development on it seemed to wane at times. So, a couple of guys, Benjamin Geer and Mike Bayer, started work on a successor called Freemarker. They defined the basics and architecturethat was reworked by a larger group.

The idea of Freemarker is similar-- it is just a template engine that can be used for more than just web frameworks and could be embedded in any engine. It is still quite small and about as easy to use (for a full comparison between the two, see this page).

Velocity, due to its position under the Apache umbrella, enjoys greater third-party access, and I wanted to build a new project with Spring, and at that time, it had better integration with Velocity than with Freemarker. So even though I had already used Freemarker on a couple of previous projects, I figured Velocity would be fine.

And at first, Velocity was fine. I got it up and running and working with Spring quickly, and started designing the pages and got a prototype up in short order. However, as I tried to finish the application, I started to run into snags. I didn't want to re-hit my database just to change the sorting order of a table, but Velocity doesn't support such things.

I finally got frustrated, and by this time, support for Freemarker in Spring was better, so I made the switch. There are still a couple of frustrations with Freemarker, but it seems to walk the balance between complexity and features and gets my vote as my favorite template engine.

BTW: Did I mention the fabulous Eclipse plugin for Freemarker? To install it, just add the following Eclipse Update Site URL:

http://www.freemarker.org/eclipse/update

Tell others about this article:
Click here to submit this page to Stumble It