76

Velocity or FreeMarker?

They look pretty much the same, even the syntax?

What to use? Or when to use what?

flybywire
  • 261,858
  • 191
  • 397
  • 503

5 Answers5

71

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.

jrb
  • 1
  • 2
  • 2
  • 1
    I totally agree with this point. When a choice arises I will often choose Velocity as the features of Freemaker are unnecessary. – Brett Ryan Jan 24 '17 at 00:52
47

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.

NealeU
  • 1,264
  • 11
  • 23
skaffman
  • 398,947
  • 96
  • 818
  • 769
  • 30
    There have been certain people in the Freemarker community spreading the myth of Velocity inactivity for nearly 7 years now. In that time, Velocity has made nigh on a dozen releases (including point releases and VelocityTools releases). – Nathan Bubna Oct 06 '11 at 16:59
  • 11
    While it does look like Velocity seems to have lost steam development-wise (I'm going with FTL on the basis of this response), the last stable release date of something isn't always the best measure of it's value. HTTP never left 2.0 and MIME never left 1.0. Granted, those are specs, not software, but I think there's likely some valuable tools out there that simply became mature. – Jherico May 08 '14 at 17:51
  • 9
    Velocity is alive again. New [version 2.0 stable](http://velocity.apache.org/news.html) released in August 2017. – Dherik Nov 07 '17 at 19:59
  • 7
    This answer is completely false. – Koshinae Feb 20 '18 at 13:12
  • 5
    https://velocity.apache.org/news.html#engine21 Velocity Engine 2.1 released (Sunday, 31 March 2019) Velocity Tools 3.0 released (Tuesday, 9 October 2018) – Ariel Apr 21 '19 at 10:28
  • 3
    They just released a new version on February 2. 2020:https://velocity.apache.org/news.html#engine22 This comment should be removed. – jfrohn Feb 28 '20 at 07:14
20

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
John Doe
  • 869
  • 5
  • 10
  • 19
    If a template system is still under active development 10+ years in, you might want to look for something a bit more stable. – fijiaaron Feb 28 '12 at 14:56
  • 9
    The fact that something is under constant "development" is really not a positive thing. – Jay Mar 26 '12 at 05:55
  • and everybody is changing. :) – Rudy May 10 '12 at 06:33
  • 10
    I'm the current maintainer of FreeMarker (I'm not the original author, BTW). Before 2.3.0 (mid 2004), it's the dark ages, chaos. Since mid 2004 (2.3.0) the releases are backward compatible, and in 2016 FreeMarker is at 2.3.23. Some new features were added that deprecated old ones, especially in the last years, but after so many years, thing come up, expectations change, and the initial interception was far from perfect. It's only now, after 12 years after 2.3.0, that a new generation FreeMarker is considered (in a different package). If you don't get wiser after 12 years, you know... – ddekany Feb 02 '16 at 19:38
7

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.

starwarswii
  • 2,187
  • 1
  • 16
  • 19
leonm
  • 6,454
  • 30
  • 38
  • 1
    Some of those are obsolete right now(See : This list is originally based on a comparison with Velocity 1.2) since Velocity reached 1.6. In terms of performance, I didn't see a valid test to see which one performs better. – adrian.tarau Dec 31 '09 at 21:19
  • 1
    Considering that the list is based on a Velocity version nearing a decade in the past, it's a disgrace to the freemarker community that they have not updated it. Velocity is at 1.7 now and most of that list is false. – Nathan Bubna Oct 06 '11 at 16:56
4

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 :).

A. Ionescu
  • 2,138
  • 16
  • 11