Re: Long-Awaited FreeMarker 3 Preview Available

2023-11-13 Thread Jacques Le Roux

Thanks Jonathan for all the details.

I'll have a deeper look...

Jacques

Le 12/11/2023 à 22:03, Jonathan Revusky a écrit :

On Fri, Nov 10, 2023 at 8:02 AM Jacques Le Roux <
jacques.le.r...@les7arts.com> wrote:


Hi Jonathan,


Salut, Jacques.



What about existing projects using the Apache version ?


Well, what about them? The basic problem is here not very different from
the decision to upgrade to a newer, not 100% backward compatible version of
whatever, like moving from Python 2.x to Python 3.x.

Now, one thing to be clear about is that in its out-of-the-box
configuration, practical NO existing Apache FreeMarker template will work
with the newer version. That's because, by default, directives like
<#assign..> and <#local...> don't work. But if you put <#ftl legacy_syntax>
up top in your template, then they do work.

But anyway, the thing is that there are different levels of user. If you
have a very basic usage pattern, like you just build up some data model
that is a tree of hashes and maps ending in scalars (strings and numbers)
and you expose that data model to your templates... well, the truth of the
matter would surely be that there is very little difference between
FreeMarker 2 and FreeMarker 3. Now, there are massive differences under the
hood and this is now very largely a rewrite, but what I mean is that a user
with a very simplistic usage pattern, (which actually could well be the
majority of users!) just would likely not notice much difference. Though,
again, they would have to use the legacy_syntax configuration or just about
nothing will work!

Since my announcement, I put up a new page which tries to gather together
all the new features in one spot. That is here:
https://github.com/freemarker/freemarker3/wiki/Summary-of-New-Features



I mean the move from 2.3 version to 2.4. Like:

  1. Would it be an easy move?


Well, again, this is a very nuanced question because there are different
kinds of users. As I say, if you have a very basic vanilla usage pattern it
probably is an easy move. In fact, most likely your templates will continue
to work with no changes (or close to none) in the legacy_syntax mode, but
even getting them to work without that is probably not so hard.

But, of course, the flip side to that is that, yes, it would probably be
quite easy to upgrade, but if your usage of the thing is that simple, then
there may not be much benefit either! That's true enough.

Now, on the other hand, if you are what is popularly called a "power user",
really pushing the limits in terms of what the tool can do, then I would
say that almost certainly you should try to move to the newer version.
(Even if it will be harder initially.) That is for a variety of reasons. If
you're a power user, and you are hitting limits in what the tool can do,
and you suggest a new feature, well, let's face it. The likelihood of that
new feature being implemented in "Apache FreeMarker" is extremely low. The
version that is now being actively developed is FreeMarker 3, and if
somebody has an idea that seems well motivated it is very likely that I'll
implement it. But the other aspect is that the codebase is so much cleaner
that it is easy now. I don't know what your level of familiarity with the
code is, but you would likely know that the grammar/parser part was written
using this rather old tool called JavaCC. FreeMarker 3 is written using
CongoCC, which is a vastly more advanced version of JavaCC. CongoCC started
as a fork of JavaCC but is now a total rewrite. But, to give you an example
of what I'm talking about, that page I linked mentions various new
features. Let's take the ternary operator as an example. Here is where it
is implemented:
https://github.com/freemarker/freemarker3/blob/master/src/parser/Expressions.inc.ccc#L95
or here, for example, is where the #assert and #exec directives are
implemented:
https://github.com/freemarker/freemarker3/blob/master/src/parser/Directives.inc.ccc#L417-L459

So, the point is that, what with using a much more powerful parser
generator tool, and the codebase being so cleaned up, it is extremely easy
to implement new features, certainly compared to trying to do it against
the 2.3 codebase. So, in particular, for anybody who really aspires to
develop more of a relationship with the code, the FreeMarker 3 codebase is
really where it's at. That's clear enough. Again, I don't know what your
understanding level of the code is, but there were things that were really
a bear to deal with in the legacy codebase, like all this
wrapping/unwrapping of variables. That's all gone. It also means that a lot
of things do actually just work more simply because you're just working
with Java objects, not all this wrapped TemplateXXXModel nonsense. So, when
write:

#var myList = [1, 2, 3]

the object constructed is not some weird wrapper object. It's just a plain
old java.util.List (an ArrayList to be precise) you can just write:

 #exec myList::add(1, "foo") #-- Look, m

Re: Long-Awaited FreeMarker 3 Preview Available

2023-11-13 Thread Taher Alkhateeb

Hello Jonathan and All,
Please excuse my limited knowledge of the project's history. If we assume the 
software is indeed improved as stated, it seems logical to consider integrating 
this work back into Apache Freemarker. Perhaps it could be done through a 
distinct branch or versioning strategy. This approach could capitalize on 
Apache's infrastructure and community, thereby extending these improvements to 
a wider audience and allowing greater adoption. It also addresses potential 
confusion regarding naming and versioning.
Should there be some reservations in the community about merging these changes, 
then we can start a discussion. This dialogue could be more constructive than 
maintaining two pieces of code. Those are my thoughts and I'd love to hear 
yours and the rest of the fine folks here.
Best,

Taher AlkhateebOn Monday, November 13, 2023 01:18 +03, Jonathan Revusky 
 wrote:
 On Fri, Nov 10, 2023 at 8:29 PM Benjamin Marwell 
wrote:

> >> It can never be on Maven central, because the namespace (groupid)
> >> "freemarker" is already claimed by Apache Freemarker.
> >>
>
> > Well, Ben... it is kind of disrespectful to talk > such blatant nonsense
> to
> > somebody. This is supposed to be some serious technical forum, isn't it?
>
> Interesting how you contradict yourself in the next paragraph. You can
> chose another groupid, of course.
>

Well, I can't figure out what you're talking about. If the groupid is a
unique identifier, and org.freemarker is taken, then we have to use a
different one. So what

But really, I'm actually just totally bemused. I have been trying to figure
out what your point is. One would think that you sincerely believe that
people out there should saddle themselves with something that is obsolete
and inferior simply because the people in question control "freemarker.org"
or whatever such reason that is entirely non-technical!

On the one hand, it's hard to believe that you seriously believe this, but
then I started thinking about the history of this whole project. In the
early days, our main competitor was this thing called "Jakarta Velocity",
now called "Apache Velocity", I guess. I mean, it's not a secret that I had
something of a chip on my shoulder about that, because that Velocity thing
was so horrendously inferior that it was just kind of infuriating to be
competing with it. But anyway, now that I think about all that again, it
really does seem that these Velocity people seriously believed that people
should use their inferior dreck because it was on apache.org or something.
It was utterly inferior but it just got increasingly inferior because the
people there did not do any work at all to try to compete with us
technically. Absolutely nothing. Month after month. Year after year.

But that's all ancient history, I guess. But the whole idea that people
should use "Apache FreeMarker" because Apache FreeMarker is in possession
of the freemarker.org domain and thus the org.freemarker groupid I mean
that's just so crazy, of course...

Well, I guess the thing that is especially infuriating about it is that
there really are all these people out there who do seem to reason like
this! For whatever reason, they won't consider using something unless it
comes from what they perceive as an "approved channel". Something like
that... That's a real phenomenon, but there's nothing I can do about that
anyway, so... Well, in this case, I do have to make a best effort to get
people to understand that Apache FreeMarker is just an older, inferior
version of work by the same person. ME!

But when you start talking this stuff about the "Apache FreeMarker" project
having the "org.freemarker" groupid and that is somehow something so
important... well, it's one of these "WTF" moments, as in: WTF is wrong
with this guy?

I mean, it's about such a level of bizarre cynicism. "Oh, they should use
this because it's the real thing to use because we have the freemarker.org
domain and..."

Well, I beg to differ. But look, what do I know? I just wrote the damned
thing basically. LOL.

I mean, this guy Taher asked me why I am not doing this work on FreeMarker
3 inside of apache.org. Well, certainly somebody who didn't know the
history of this whole thing would naturally ask me that. That's
understandable. So I tried to fill him in. But anyway, it's such an
exercise in masochism, dealing with certain personality types. And you,
Ben, are not the worst by any means. This other guy who came out of the
woodwork, Lenny, really seems to have escaped from the pages of a comic
book!

But, okay, fine. I can't do the work I'm doing because I don't own the
freemarker.org domain or the org.freemarker groupid because that's really
important. And regardless, people should use some totally inferior version
of the thing (that it so happens I myself wrote as well!) because...


> But you presented your project as "freemarker", and the current root
> package is "freemarker" in your project. And I think I spotted th