Alternatives to Freemarker when using Spring/Hibernate?

egervari picture egervari · Sep 15, 2012 · Viewed 11.4k times · Source

What are some modern, more-productive alternatives to Freemarker as view technology for rich web-applications using Spring? Is Spring MVC/Freemarker still one of the best combinations, or are there others?

The application I have to build is small, but complex that will likely require a lot of custom javascript as all of the controls and ui is very non-standard (it's not really a business application). Blizzard's gaming websites like for Diablo 3 is an example of what I'm trying to do.

Is this combination still the best to suite my needs, or are there other technologies I should take a look at?

Thanks

Answer

Łukasz Rżanek picture Łukasz Rżanek · Sep 15, 2012

There are several good and well established template engines on the market. Most of them play nice with Spring.

  • Velocity - a classic and one of the most popular template engines out there. Quite good, quite flexible, ugly syntax but good Eclipse plugin.
  • Thymeleaf - one of the most feature rich and flexible template engine on the market. Performance is good, although not ground breaking. My personal choice for most of the projects.
  • String Template - really good performance, quite hard to use. Very flexible, thought...
  • MVEL - seems to be really, really fast and quite feature-rich. For me it was to complex and quite hard to use in a project with junior devs.
  • Rhythm - from a Play framework to Java, nice and very flexible. Razor syntax is great. Rhythm is really fast, very flexible and nice to use. Another personal choice for my projects, next to Thymeleaf. There is a nice article on how to use this engine in Java.
  • httl - small, easy to use, not that fast but still good enough. Quite flexible but not that feature rich.
  • Trimou - another fairly new kid on the block. Looks decent, uses Mustache templating syntax and is fairly easy to use. But for my taste a bit too simplistic and missing some features.
  • Rocker - apparently a fairly new development, actively maintained and extended at this time. I like it, it has a nice idea for the syntax but it is nothing that resembles other syntaxes. A lot of simple features, missing some advanced ones IMHO. Very performant according to a test we just made.
  • Pebble - we used it for a couple of different purposes and it proved rather simple to use with a decent syntax inspired by Twig from PHP world. Performance is really good, one of the fastest we tried.

Performance wise, according to our tests, in order from the slowest:

  1. Thymeleaf
  2. Freemarker
  3. Velocity
  4. Trimou
  5. Mustache
  6. Pebble
  7. Rocker

Your mileage may vary!...


There is a nice comparison of few of those (quite old article). Also a nice tutorial on how to use some of them by Baeldung

There are plenty of template engines out there. Check this directory if you need more...