Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Velocity vs. FreeMarker [closed]

People also ask

What is velocity and FreeMarker?

Velocity and FreeMarker are two templating languages that can both be used as view technologies within Spring MVC applications. The languages are quite similar and serve similar needs and so are considered together in this section.

Which is better Thymeleaf or FreeMarker?

In the pursuit of comparison between FreeMarker , Thymeleaf, Groovy and Mustache, FreeMarker has the upper hand in performance. However, Thymeleaf wins the battle overall.

Is velocity deprecated?

Well, the reason is that the Velocity Engine has been deprecated for a while, and a lot of developers around the world need to find well-fitting alternatives.

What is FreeMarker?

Apache FreeMarker is a free Java-based template engine, originally focusing on dynamic web page generation with MVC software architecture. However, it is a general purpose template engine, with no dependency on servlets or HTTP or HTML, and is thus often used for generating source code, configuration files or e-mails.


The goals for the projects are different.

Velocity's goal is to keep templates as simple as possible, to help maintain a segregation between logic and presentation, so you don't slide down the slippery slope of sticking code in templates. Sometimes this is the right thing. Of course, sometimes being able to wire complicated logic directly into templates is the right thing.

Velocity doesn't get frequently rev'd, but that doesn't mean it's not under active development. The user community is large, the code is fast and stable, the syntax is basically fixed. Over the last several years Freemarker has undergone churn on the template syntax and api side. Sometimes it's nice to leave well enough alone. Again, depends on what you're looking for.

Freemarker's documentation is much more extensive- and it's a much more complicated piece of software.

Many of the use cases for Freemarker boil down to wanting a complex templating workflow and not wanting a compilation step. In recent years, rather than struggle through this with Java I've just been using Python or Ruby instead.


Velocity isn't really under active development any more. Freemarker is.

Freemarker is also a lot more flexible, in my experience.


Use Freemarker if you can :

  • Still in active development like @skaffman said
  • Good documentation, better than Velocity IMHO
  • Provided as alternative templating language in many web frameworks
  • Less dependencies than Velocity
  • More complete than the raw Velocity without extensions.
  • Also see the link provided by @leonm

They try to differentiate themselves from time to time (example).

I've worked extensively with both and from my perspective they're very similar. There are just so many features that you can build into a templating language, the rest is just fluff.


There are two published books about Velocity:

  • Pro Jakarta Velocity: From Professional to Expert

  • Mastering Apache Velocity

and other books that have chapters about it too. So, that much about FreeMarker having more or better docs :).