Velocity vs. FreeMarker

JavaVelocityTemplate EngineFreemarker

Java Problem Overview


Velocity or FreeMarker?

They look pretty much the same, even the syntax?

What to use? Or when to use what?

Java Solutions


Solution 1 - Java

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.

Solution 2 - Java

When this quesiton was asked, velocity wasn't really under active development any more and Freemarker was.

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

Solution 3 - Java

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

Solution 4 - Java

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.

Solution 5 - Java

There are two published books about Velocity:

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionflybywireView Question on Stackoverflow
Solution 1 - JavajrbView Answer on Stackoverflow
Solution 2 - JavaskaffmanView Answer on Stackoverflow
Solution 3 - JavaJohn DoeView Answer on Stackoverflow
Solution 4 - JavaleonmView Answer on Stackoverflow
Solution 5 - JavaA. IonescuView Answer on Stackoverflow