Announcement Announcement Module
Collapse
No announcement yet.
FreeMarker vs Velocity Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • FreeMarker vs Velocity

    I am currently considering FreeMarker, but saidly FreeMarker was staying very low on my radar up to now. - More exactly speaking, FreeMarker wasn't on my radar, so I am not quite familiar with it.

    Since I am enjoying using Velocity to the extend, it wasn't that hard to familiarize with FreeMaker as enough needed to understand that FreeMarker seams to provide all the features, I love about Velocity. Also I have learned that FreeMarker offers quite some additional nice features.

    Never the less the FreeMarker main pages doesn't read like being that serious about journalistic fairness. It is always good to be proud of your own products, but it leaves the reader quite puzzled. And I am puzzled at the moment.

    Since I have the freedom of being able to switch from the planned Velocity rendering engine to a FreeMarker one without much afford (early stage), I would like to hear some of your oppinions about the Velocity vs FreeMarker story.

    I think, I know the technical differences - as far as I am concerned of - but I am quite unsure about the non-technical part.

    Is it as easy to use as Velocity? (the FreeMarker folks claim to be far more easier than Velocity in certain areas)

    What differences can I expect between a Velocity and a FreeMarker solution from a gain vs afford ratio view?

    What are the trade offs?


    I have read some resources on the net and the article 'FreeMarker vs Velocity' at TheServerSide.com was quite interesting. The following comment of one of the readers seams to be a good explaination of a reason for switching to FreeMarker.

    I have to say that velocity doesn't look too good compared to Freemarker. I've been using velocity on all of my projects as of late and for one very good reason - it's fast. I don't have to wait and sit around for compile times and all that. I can get immediate results and that's something every programmer who is mucking around with the view wants. I can also make macros in about a 20th the speed as making a jsp tag too. Granted I think page views are just naturally not supported very well at all in any programming language at the moment, but this is a step forward.

    However, I've been doing some pretty complex stuff in the view. Now, I don't mean I'm putting business logic in there - that's not it. I've just been making massive amounts of investment in macro libraries and I build higher-level marcos for all sorts of application-specific presentation reuse. However, Velocity just isn't any good at doing this - and I'm not even talking about large scale applications, I'm talking about a small to medium-sized but featureful project a competent developer can write in a few weeks.

    I think I've hit the capabilities of Velocity and I've been stretching it quite a bit. Without named/optional parameters or even basic macro overloading, I just can't build complex views and avoid duplication at the same time very easily. It's like a pain in the ass just to add an option column, button or sub-screen for a specific listing that uses the general listing macro and so on. I have all kinds of cases where I have to do functional-oriented type checking and it's inexcusable.

    Freemarker seems like the way to go. While it's probably more difficult, the end result looks to be more like html. When I saw features for unordered named, optional parameters and nested content, I realized that these features alone make it better than Velocity because they just aren't "nice" features, the are just down-right required. (http://www.jroller.com/page/raible?a...er_vs_velocity)
    So I would like to ask, what you guys think about it? Who is favouring Velocity over FreeMarker or vise versa, and why...


    Thanks and Cheers,

    Martin (Kersten)

    (Edit) PS: I already searched the Springforum of cause... .

  • #2
    Hi Martin

    I prefer FreeMarker for its macro capabilities. I certainly am not an expert in Velocity's current strengths in this regard, but they were comparatively limited when I last looked. I agree with the quoted post regarding the lower develop time for FreeMarker macros vs JSP taglibs. I actually have FreeMaker macros that do everything from rendering links (to include access keys and help text) through to creating form input controls and associated labels. I also found writing a custom FreeMarker resource loader quite easy, as I need to pull templates from the classpath and fallback to various file system locations that vary based on the subscriber (ASP style deployment).

    Comment


    • #3
      Hi Ben,

      I actually have FreeMaker macros that do everything from rendering links (to include access keys and help text) through to creating form input controls and associated labels.
      That's nice to hear. I have something similar for Velocity but the possibilities of velocity are a bit limited when it comes to macro definition. Are you using any public macro libs? Are your macros available somewhere? I would like to give it a head start for testing etc.


      Thanks and cheers,

      Martin (Kersten)

      Comment


      • #4
        We use Velocity with much pleasure (everything is better than the XSLT/XML Hell), but if you need something more, there are a lot of templates engines. You could have a look at Jamon

        Comment


        • #5
          Thanks for the post Alarmnummer!

          But the problem also increased. Check out this page: http://java-source.net/open-source/template-engines. And they even forgot to mention WebMacro. I think template engines was a big issue in 2000-2002. Most of the frameworks seam to be founded or getting massive attention during this periode.

          Beside this, I guess, FreeMarker and Velocity are taking the lead by popularity (at least that is what my feeling is, but don't nail me on this one since this isn't statistical waterproof nor is it backed by a pack of honoric sientists).

          Never the less, Jamon seams very interesting for its compiling and precompiling option but makes me afraid to bleed for the same reasons as JSP does.

          I currently looking for a template engine processing templates stored in a DB and so I am not that eager to mess with files at all. Velocity will do it, but I don't like the macro limitations and FreeMarker looks like the next available option... .


          Hopefully I can make up my mind. Seams like my weekend will be totally occupied by investigating template engines and decision making... . Poor Martin, wuff, wuff... :-(


          Cheers,

          Martin (Kersten)

          Comment


          • #6
            Originally posted by Martin Kersten
            Are you using any public macro libs? Are your macros available somewhere? I would like to give it a head start for testing etc.
            I started with the spring.ftl and refactored it like crazy. I'd love to share it, but the code is so heavily specific to our app I am uncertain it would prove too valuable to you. If you like I would be happy to send it to you off-list just to see how the macros are assembled. When I have more time I would like to tidy it up and place it in the "Domain" subproject we've created in the Acegi Security CVS space. There's a lot of goodies in there already, like validation AOP, DAO abstraction and yesterday I added a reusable services layer (it all uses generics, to maximise reuse and provide type safety).

            Comment


            • #7
              I'd love to share it, but the code is so heavily specific to our app I am uncertain it would prove too valuable to you.
              Please share your macros, I would die inorder to take a look ;-). You can send me an email.

              There's a lot of goodies in there already, like validation AOP, DAO abstraction and yesterday I added a reusable services layer (it all uses generics, to maximise reuse and provide type safety).
              I need to take a look, thanks for the hint!


              Cheers,

              Martin (Kersten)

              Comment


              • #8
                Originally posted by Martin Kersten
                I have something similar for Velocity but the possibilities of velocity are a bit limited when it comes to macro definition.
                Velocity macros are more limited than their FreeMarker counterparts, but you can use custom Velocity directives instead which are more akin to taglibs and therefore far less limited in potential. Not much doco for them though!

                http://jakarta.apache.org/velocity/d...uide.html#FAQ3

                Regards,

                Comment


                • #9
                  Here's a good link :

                  http://www.jroller.com/page/raible/h...ocity?catname=

                  Ben,
                  Are you using a pure Freemarker solution or do you include JSP tags in Freemarker? Also are you using displaytag or any other tag lib for tables?

                  Thanks,
                  Sanjiv

                  Comment

                  Working...
                  X