You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Gonzalo Diethelm <go...@diethelm.org> on 2002/07/08 20:52:38 UTC

Velocity under non-Java environments

Hello,

The company I work for develops web apps using several different
languages, such as Java, PHP and Perl (and supports old CGI-based
apps, incidentally!). I am totally sold on the templating language
idea implemented in Velocity, and have been looking for an embodiment
of this idea in the other programming environments, specifically
with Perl and PHP. I found Smarty for PHP, but I really find it
difficult after the simplicity of Velocity.

This got me thinking: both PHP and Perl support (to a certain extent)
an object model; how hard would it be to come up with Velocity versions
that work with PHP and Perl?

I even envision a grandiose future where a given VM template can be used
UNCHANGED on a Java, Perl or PHP environment! Now that would be cool!
You would need to abstract somehow the way Velocity templates interact
with the underlying object system, but at least in theory it look doable.

How hard would this be? Is this even one of the stated Velocity goals?
Any comments are welcome.


-- 
Gonzalo A. Diethelm
gonzalo.diethelm@aditiva.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Velocity under non-Java environments

Posted by Gonzalo Diethelm <go...@diethelm.org>.
> > This got me thinking: both PHP and Perl support (to a certain extent)
> > an object model; how hard would it be to come up with Velocity versions
> > that work with PHP and Perl?
> >
> > I even envision a grandiose future where a given VM template can be used
> > UNCHANGED on a Java, Perl or PHP environment! Now that would be cool!
> > You would need to abstract somehow the way Velocity templates interact
> > with the underlying object system, but at least in theory it look
doable.
> >
> > How hard would this be? Is this even one of the stated Velocity goals?
> > Any comments are welcome.
>
> I was talking with the cheetah developers (python) about this a while
ago -
> I thought it would be great to have portable templates.

Yes!

> The problems, I think, come in when people want to implement idioms from
> their favorite language into the templating system.  I think we've done a
> good job (or the WM guys did a good job :) of keeping Java-ish things out
of
> Velocity/WM.  I would think that if you *started* with velocity, it would
be
> straightforward as long as you could get around some of the problems you
> have in languages w/o reflection/introspection (like C++)...

Forget about any language that does not provide reflection. I think that
still leaves several interesting languages: PHP, Perl and Python (and, of
course, Java). I think it would be great to have something like:

                       +--------------------+
                       |   VM Template      |
                       +--------------------+
                                 |
                       +--------------------+
                       |Velocity Interpreter|
                       +--------------------+
                                 |
+--------------------+ +--------------------+ +--------------------+
|    Java Gateway    | |    PHP Gateway     | |    Perl Gateway    | ...
+--------------------+ +--------------------+ +--------------------+

> Geir Magnusson Jr.


--
Gonzalo A. Diethelm
gonzalo.diethelm@aditiva.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocity under non-Java environments

Posted by Attila Szegedi <sz...@freemail.hu>.
----- Original Message -----
From: "Jeff Duska" <Je...@noaa.gov>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: 2002. jĂșlius 8. 23:22
Subject: Re: Velocity under non-Java environments


> One option that I don't think anyone has
> mentioned is to try to compile the current codebase using gcc into a
> native library.

I assume you mean gcj. Well, maybe it'd work. Given the fact that Vel relies
heavily on reflection, that'd at least serve as an extremely deep test of
the gcj introspection support... Altough I'm a little bit pessimistic
regarding the results. Oh, just speculating.

Attila.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocity under non-Java environments

Posted by Jeff Duska <Je...@noaa.gov>.
Gonzalo Diethelm wrote:


>whether it is a Perl, PHP, Java or Python object. To do this, it is
>not necessary to reimplement Velocity in a different language.
>
>
>  
>
I think problem is that most ISPs that provide PHP or Perl support do 
not provide a JVM. If you have the JVM, then you implement the gateways, 
otherwise you'll be stuck. One option that I don't think anyone has 
mentioned is to try to compile the current codebase using gcc into a 
native library. I'm not sure that this would work, but it would nice if 
it did. Then there is the question on how to intereface to the system, 
but I think gcc has something called CNI that is designed to do this. It 
has been a while since I looked at gcc's Java support, but it worth a look.

Anyhow, just a thought.

Regards,

Jeff



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Velocity under non-Java environments

Posted by Gonzalo Diethelm <go...@diethelm.org>.
> > how hard would it be to come up with
> > Velocity versions that work with PHP and Perl?
> Heh heh... if you could find a chap as fast as Geir, I'm sure they could
> have something in the sandbox near end of the week. ;-)

Geir? Do you have time to talk about this? Can I provide any help?

> ...but if I were trying to this in Perl (which would be cool, albeit
> there are a bunch of good templating solutions available) I'd imagine
> starting here would be a good idea:
>
> http://search.cpan.org/search?dist=Parse-RecDescent
>
http://search.cpan.org/doc/DCONWAY/Parse-RecDescent-1.80/lib/Parse/RecDescen
t.pod

This is not what I have in mind. I would like to see THE EXACT SAME
Velocity language we have today, with #if, #for, etc., but with the
ability to parse things like

#if ($session.getStatus() == "A")

and call the appropriate underlying object represented by $session,
whether it is a Perl, PHP, Java or Python object. To do this, it is
not necessary to reimplement Velocity in a different language.

A different project, that maybe interesting in itself, would be to
port the Velocity parser/interpreter/engine to another language, maybe
C (for portability).

> Say - how are things going for the brave chap that's porting Velocity to
> C#?

I guess this falls under the second initiative I mentioned.

> Cheers,
> Tim

Thanks,


--
Gonzalo A. Diethelm
gonzalo.diethelm@aditiva.com


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Velocity under non-Java environments

Posted by Tim Colson <tc...@cisco.com>.
> how hard would it be to come up with 
> Velocity versions that work with PHP and Perl?
Heh heh... if you could find a chap as fast as Geir, I'm sure they could
have something in the sandbox near end of the week. ;-)

I'm not that guy... (Geir's performance constantly makes me realize just
how much I suck at this. <grin>)

...but if I were trying to this in Perl (which would be cool, albeit
there are a bunch of good templating solutions available) I'd imagine
starting here would be a good idea:

http://search.cpan.org/search?dist=Parse-RecDescent
http://search.cpan.org/doc/DCONWAY/Parse-RecDescent-1.80/lib/Parse/RecDe
scent.pod

Say - how are things going for the brave chap that's porting Velocity to
C#?

Cheers,
Tim


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Velocity under non-Java environments

Posted by "Geir Magnusson Jr." <ge...@adeptra.com>.
On 7/8/02 2:52 PM, "Gonzalo Diethelm" <go...@diethelm.org> wrote:

> Hello,
> 
> The company I work for develops web apps using several different
> languages, such as Java, PHP and Perl (and supports old CGI-based
> apps, incidentally!). I am totally sold on the templating language
> idea implemented in Velocity, and have been looking for an embodiment
> of this idea in the other programming environments, specifically
> with Perl and PHP. I found Smarty for PHP, but I really find it
> difficult after the simplicity of Velocity.
> 
> This got me thinking: both PHP and Perl support (to a certain extent)
> an object model; how hard would it be to come up with Velocity versions
> that work with PHP and Perl?
> 
> I even envision a grandiose future where a given VM template can be used
> UNCHANGED on a Java, Perl or PHP environment! Now that would be cool!
> You would need to abstract somehow the way Velocity templates interact
> with the underlying object system, but at least in theory it look doable.
> 
> How hard would this be? Is this even one of the stated Velocity goals?
> Any comments are welcome.

I was talking with the cheetah developers (python) about this a while ago -
I thought it would be great to have portable templates.

The problems, I think, come in when people want to implement idioms from
their favorite language into the templating system.  I think we've done a
good job (or the WM guys did a good job :) of keeping Java-ish things out of
Velocity/WM.  I would think that if you *started* with velocity, it would be
straightforward as long as you could get around some of the problems you
have in languages w/o reflection/introspection (like C++)...

-- 
Geir Magnusson Jr. 
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>