I'm a little confused. Why aren't we joining efforts on the apache version? Why 
make it "a pity if a wider group of
people never get the benefit of this work"? Am I missing something too obvious 
or too old or something? Is this code base completely incompatible? Is this a 
technical issue?

Taher Alkhateeb

On Wednesday, November 08, 2023 04:03 +03, Jonathan Revusky <revu...@gmail.com> 
wrote:
 Greetings,

I thought to let people know that there is a vastly more advanced version
of FreeMarker available here: https://github.com/freemarker/freemarker3

You can build it via:

git clone https://github.com/freemarker/freemarker3.git
cd freemarker3
ant

Or, if you want, there is a prebuilt jarfile you can grab here:
https://parsers.org/download/freemarker.jar

Though it is actually a rather superficial new feature, I think that one
thing that people will enjoy is the new terser syntax. Basically, if a
directive starts a line (aside from whitespace) there is no need for any
pointy (or square) brackets. So you can just write:

#if foo == bar
blah blah
/#if

You can look here for a more complete description:
https://github.com/freemarker/freemarker3/wiki/Terse-Syntax and here is an
example of a template from the old test suite rewritten using the terser
syntax:
https://github.com/freemarker/freemarker3/blob/master/src/freemarker/testcase/template/test-switch.html

In this version of FreeMarker, the #assign and #local directives (though
they still work in a backward-compatible mode) were replaced with the newer
#var and #set. This is (IMHO) a significant improvement and is described
here: https://github.com/freemarker/freemarker3/wiki/Strict-Vars

Just generally speaking though, the biggest changes are really under the
hood and would not be so visible to the casual user. This FreeMarker
codebase has been refactored so that it largely does away with all of those
TemplateXXXModel wrappers and mostly just directly uses POJOs. (Plain Old
Java Objects.) This is described here:
https://github.com/freemarker/freemarker3/wiki/Under-the-Hood

Various longstanding annoyances, like not being able to directly use a map
with non-string keys, have been addressed.

Oh, it suddenly occurs to me that many (perhaps most) people on this
mailing list do not know who I am. I am effectively the original author of
FreeMarker. I say "effectively" because there was a FreeMarker 1.x, which
was really little more than a weekend hack. The version that 99% of
FreeMarker users have used, which is 2.x, was a complete rewrite and is
largely my work.

As for other questions about what is going on with this, for example, why I
have put some renewed effort into FreeMarker after all years... well, my
main open source efforts have been going into my rewrite of that old JavaCC
parser generator that FreeMarker 2.x was originally built with. The new
version of JavaCC was originally called FreeCC, then when I resuscitated it
a few years ago, I called it JavaCC 21, but it is now rebranded as CongoCC.
So, since FreeMarker is a key part of CongoCC, I found myself adding the
occasional new feature to FreeMarker (my own version, not Apache
FreeMarker). For example, the feature described here
https://github.com/freemarker/freemarker3/wiki/Macros-as-Functions was
added to support CongoCC development back in 2020, but probably a lot of
FreeMarker users would appreciate this.

So, at some point, I did rework FreeMarker to use CongoCC instead of the
legacy JavaCC. CongoCC is a much, much more powerful parser generator than
the original JavaCC, so it makes FreeMarker development comparatively a
breeze. For example, I quite recently implemented assertions in FreeMarker
and this is where it is implemented:
https://github.com/freemarker/freemarker3/blob/master/src/parser/Directives.inc.ccc#L417-L445

Or here is where ternary expressions are implemented:
https://github.com/freemarker/freemarker3/blob/master/src/parser/Expressions.inc.ccc#L98-L118
You really should compare the FreeMarker grammar expressed with CongoCC to
the one that was written with legacy JavaCC, that is here:
https://github.com/apache/freemarker/blob/2.3-gae/src/main/javacc/FTL.jj

So I rewrote FreeMarker (it is largely a rewrite at this point) to: (a)
have a better tool for CongoCC development and (b) to provide a showcase
for CongoCC's capabilities.

As for my plans, well, I do think it would be a pity if a wider group of
people never get the benefit of this work. Whether I intend to call this
version of FreeMarker "FreeMarker 3" or rename it to "Congo Templates", I
still haven't decided about that. I really only put some serious effort
into the FreeMarker codebase starting this summer and the work kind of took
on a life of its own.

In any case, anybody who is interested in getting involved, by all means.
Maybe start a discussion here:
https://github.com/freemarker/freemarker3/discussions

Best Regards and Greetings from Spain,

Jonathan Revusky

Reply via email to