Re: Apache::SimpleTemplate (don't do it!)
On Mon, Jul 09, 2001 at 02:07:21PM -0400, Perrin Harkins took time to write: I think that CGI::FastTemplate does all of that. Please have a look at it, and see if everything you need is not already in it. It's a good module for CGI, since it doesn't rely on caching/compiling techniques, just simple regex stuff. It will use a lot less RAM than tools that compile in-line perl, because it doesn't eval anything or cache anything. The only real downside of this module is that coding repeated sections (loops) can't be done in-line, i.e. you have to use multiple files. That's a bit of a pain. Yes and no. It is a simple template thing. The original poster wanted : it's either code or it's not. no added tags, etc. In CGI::FastTemplate there is no embedded code, no added tags, so it suits that need perfectly. If you want more advanced stuff (loops, code, etc...) then probably Mason, AxKit or things like that will be more of your taste. Personnally, since 2 years, CGI::FastTemplate was always enough for me. Needs are different. CGI::FastTemplate is very good for very basic needs (that is no HTML code in mod_perl handlers, but in separate files). For more advanced needs there are other solutions. -- Patrick. ``C'est un monde qui n'a pas les moyens de ne plus avoir mal.'' PGP signature
Re: Apache::SimpleTemplate (don't do it!)
At 20:19 09.07.01 +0200, you wrote: It's your decision, but I think you waste your time while you make all the experiences the other had made during the last 3-5 years. I think it would more helpfull if you help to improve the other modules (for example makeing them easier to install etc.) ...but I know that's useless to say, mostly everybody has to write his own templating solution... Gerald P.S. I guess we would have much better ones, if we don't have hundreds of them all doing nearly the same ! The reason is IMHO that it is easy to write a simple template engine. It is nearly as easy as understanding one by reading docs and sources. And it is easier than understandig 3 or 4 of them to find one that matches several needs. And contributing to an existing one is the hardest. Joachim -- ... ein Geschlecht erfinderischer Zwerge, die fuer alles gemietet werden koennen.- Bertolt Brecht - Leben des Galilei
Re: ePerl (fragment of Re: Apache::SimpleTemplate)
Yea, I tried that, but it was still unhappy. There are apparently a couple of other tweaks that needed to be done. I didn't think too much about it; after the first error, I went looking for information and found the patch. http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/textproc/eperl/Makefile cheers, Todd At 01:21 AM 7/9/01, Mithun Bhattacharya wrote: The only thing I had to fix was that the Makefile didnt know about version 5.6 otherwise it compiled cleanly... Ofcourse there is a issue with a function declaration which gcc didnt like but it got fixed when I commented it out. There's a patch to make it work with 5.6 floating around, but I haven't seen anything else new in some time.
Re: Apache::SimpleTemplate (don't do it!)
hi, i'm sure many of us have had situations like this, but that doesn't mean that everyone who wants to do some templating is going to fall into the same trap every time. to clarify what i mean by 'simple': - trivial to install and to use - small disk footprint 10 modules total. preferably 1 - small memory footprint this is usually the first bottleneck i see with mod_perl. i don't know how big these others systems get, but with the high numbers of modules... - fast, with little overhead to begin with. just because they're mod_perl, does not mean they're fast enough. - very basic non-syntax it's either code or it's not. no added tags, etc. - extensibility via sub-classing. i really think these criteria are reasonable, and that there should be such a minimal approach available. (i just did some quick tests against Embperl, and my memory and speed concerns are justified.) most projects may still be better off using Embperl, Mason, ASP, TT from the beginning. But all should not be forced to just because others had bad experiences when they started out with a basic templating scheme. i am still waiting for some direct positive feedback, though. :) peter
Re: Apache::SimpleTemplate (don't do it!)
hi, i'm sure many of us have had situations like this, but that doesn't mean that everyone who wants to do some templating is going to fall into the same trap every time. The problem is that not every feature comes off looking like a trap. - trivial to install and to use It's rare that I need to do anything more than 'perl Makefile.PL make make install' when I install modules. If I use CPAN.pm, it's even easier. Installation of any perl module trivial (under Un*x, at least). - small disk footprint I can't remember the last time I had a disk space problem because of a perl module. It's not like we're talking about Megs of disk space (TT might come close). 2 gigs will hold all of RH 7.0 (including X) and any perl modules you could possibly want. - small memory footprint At current memory prices (128 MB for $25), I consider this point very weak. I use about 300 modules within my system, and the total size of the httpd is 30 MB. On a system with 1 GB of RAM, I can run about 200 processes easily. Most people don't have 300 modules, so I suspect httpd to be much smaller. - fast, with little overhead to begin with. You don't use a templating system because it's fast. You use it because it's faster to develop. It's the same reason people choose to use Perl instead of C. - very basic non-syntax I'm a little confused by this one There are templating system like Mason that have their own tags ([+ +]) and systems like Text::Template that use HTML style tags. Both are pretty easy for programmers to understand, but designers (the people using the templating system) will probably find Text::Template simpler and easier to learn and use. - extensibility via sub-classing. This is notably where many templating systems come up short. I think TemplateToolkit provides the most flexibility in this area. Text::Template, while not sub-classable, is easily wrapped. I'm not trying to suggest that what you've written isn't worthy. I'm only making a point about templating systems. If your goal is to write a templating system, you shouldn't just look at what already exists and strip out the stuff you feel isn't important. If you really want to help, you should consider contributing to existing templating systems to find the happy medium you're looking for. Robert Landrum -- A good magician never reveals his secret; the unbelievable trick becomes simple and obvious once it is explained. So too with UNIX.
Re: Apache::SimpleTemplate (don't do it!)
On Mon, Jul 09, 2001 at 12:00:58PM -0400, [EMAIL PROTECTED] took time to write: to clarify what i mean by 'simple': - trivial to install and to use - small disk footprint 10 modules total. preferably 1 - small memory footprint this is usually the first bottleneck i see with mod_perl. i don't know how big these others systems get, but with the high numbers of modules... - fast, with little overhead to begin with. just because they're mod_perl, does not mean they're fast enough. - very basic non-syntax it's either code or it's not. no added tags, etc. - extensibility via sub-classing. I think that CGI::FastTemplate does all of that. Please have a look at it, and see if everything you need is not already in it. CGI::FastTemplate 1 module, very fast, no syntax (no loop, etc...), should be subclassable but what for ? I am just using it for years with CGI first and now with mod_perl without any problems whatsoever. My two euro cents. -- Patrick. ``C'est un monde qui n'a pas les moyens de ne plus avoir mal.''
Re: Apache::SimpleTemplate (don't do it!)
I think that CGI::FastTemplate does all of that. Please have a look at it, and see if everything you need is not already in it. It's a good module for CGI, since it doesn't rely on caching/compiling techniques, just simple regex stuff. It will use a lot less RAM than tools that compile in-line perl, because it doesn't eval anything or cache anything. The only real downside of this module is that coding repeated sections (loops) can't be done in-line, i.e. you have to use multiple files. That's a bit of a pain. - Perrin
Re: Apache::SimpleTemplate (don't do it!)
to clarify what i mean by 'simple': - trivial to install and to use That's important - small disk footprint 10 modules total. preferably 1 disks are cheap, so it doesn't matter if you take one or two MB - small memory footprint this is usually the first bottleneck i see with mod_perl. i don't know how big these others systems get, but with the high numbers of modules... As soon as you start to precompile the Perl code inside your template, your memory footprint will increase and will be much more than what your module takes. If you don't precompile the Perl code you will never get a good performance for bigger pages. - fast, with little overhead to begin with. just because they're mod_perl, does not mean they're fast enough. see above. - very basic non-syntax it's either code or it's not. no added tags, etc. That's a matter of taste - extensibility via sub-classing. This makes sense, but Perl methods are not the fasted solution, so you may decide, do you want a good design are a fast one... i really think these criteria are reasonable, and that there should be such a minimal approach available. (i just did some quick tests against Embperl, and my memory and speed concerns are justified.) Before you don't have a real application that does more the Hello World , nothing is justified. (and I can't imagine how you have tested it with a real application, when it is a quick test) (If you want to test against Embperl you should use 2.0b3 which is much faster then 1.3.x!) Of course I can be fast, when I do nearly nothing, but if you want to create applications, that do more then just mailing a form, you have to do a lot of things more and all those things will take time and memory, regardless if your template system does them for you, or if you reinvent them again for every web application you write. most projects may still be better off using Embperl, Mason, ASP, TT from the beginning. But all should not be forced to just because others had bad experiences when they started out with a basic templating scheme. i am still waiting for some direct positive feedback, though. :) It's your decision, but I think you waste your time while you make all the experiences the other had made during the last 3-5 years. I think it would more helpfull if you help to improve the other modules (for example makeing them easier to install etc.) ...but I know that's useless to say, mostly everybody has to write his own templating solution... Gerald P.S. I guess we would have much better ones, if we don't have hundreds of them all doing nearly the same ! - Gerald Richterecos electronic communication services gmbh Internetconnect * Webserver/-design/-datenbanken * Consulting Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz E-Mail: [EMAIL PROTECTED] Voice:+49 6133 925131 WWW:http://www.ecos.de Fax: +49 6133 925152 -
Re: Apache::SimpleTemplate (don't do it!)
On Monday 09 July 2001 20:19, Gerald Richter wrote: to clarify what i mean by 'simple': - trivial to install and to use That's important Tough some are easy to use and hard to install :) The latter is less important imho, when a module is hard to install it's usually justified somehow, and most of the time the community revolving around it will be prepared to help. - small disk footprint 10 modules total. preferably 1 disks are cheap, so it doesn't matter if you take one or two MB To go further, I certainly wouldn't mind an app taking 500mb if it does everything I want it to do fast and well. - small memory footprint this is usually the first bottleneck i see with mod_perl. i don't know how big these others systems get, but with the high numbers of modules... As soon as you start to precompile the Perl code inside your template, your memory footprint will increase and will be much more than what your module takes. If you don't precompile the Perl code you will never get a good performance for bigger pages. Which is why imho for anything non-trivial things must be pre-compiled, and after that one can start discussing the ways in which different modules can unload some templates to save some memory, or do various things to increase their caching. dreamIt would be great if this was handled consistently accross all templating systems so that improvements there would benefit everyone. It doesn't seem impossible given that all that's stored is some Perl code and perhaps some metadata./dream - extensibility via sub-classing. This makes sense, but Perl methods are not the fasted solution, so you may decide, do you want a good design are a fast one... extensibility yes, but sub-classing is only one way to do that, and not always the best. ...but I know that's useless to say, mostly everybody has to write his own templating solution... Until you've written your own you can't understand just how hard it is. I'm slow so I had to write three half-baked ones before I got it, and I'm very glad I didn't release them... There are times when release often doesn't apply all that well :) P.S. I guess we would have much better ones, if we don't have hundreds of them all doing nearly the same ! Agreed, but that probably won't happen... -- ___ Robin Berjon [EMAIL PROTECTED] -- CTO k n o w s c a p e : // venture knowledge agency www.knowscape.com --- Change is inevitable except from a vending machine.
Re: ePerl (fragment of Re: Apache::SimpleTemplate)
Hi there, On Sat, 7 Jul 2001, Todd Finney wrote: We use ePerl for a fair number of things, and I have yet to run into something we needed of which it was not capable. Didn't I read somewhere that there were security concerns? Just asking. Ditto. 73, Ged.
Re: Apache::SimpleTemplate
At 06:16 PM 7/7/2001 -0700, brian moseley wrote: On 7 Jul 2001, Randal L. Schwartz wrote: Yes. Writing a templating system in Perl is trivial. Writing a *useful* templating system in Perl is demonstratably hard. unless you keep application features in a separate layer from the templating system (eg the servlet api ;) I think it is still quite difficult. Even if you have servlets, for example, adding JSPs was quite a task. At issue is providing a minimal API yet still allow the templates to do things that weren't originally intended. In addition one of the criteria for useful to me is fast. If the template system is slow, it's quite annoying. However, this goes against other people's ideas of useful being full featured. As Steven Wright says (paraphrased) if you had everything where would you put it? So to make something that is powerful yet fast is quite the challenge. And then there are architectural tradeoffs as to the type of application that the template is being used for. Transactions? Portal based? Integrating many apps together? Standalone? Later, Gunther
RE: ePerl (fragment of Re: Apache::SimpleTemplate)
We use ePerl for a fair number of things, and I have yet to run into something we needed of which it was not capable. What are you thinking of? It's not a question of it not being capable, it's just that most people seem to choose one of the more full-featured tools. There's lots of talk on the list about Apache::ASP, Embperl, Mason, etc., but not much about ePerl. (Maybe I should do some research in the mail archives and graph the results. Sounds like a magazine column...) Also, I think Text::Template stole some users away from ePerl. Like SSI, ePerl is perfect for some people who just want a simple solution that stays out of their way. Also, I believe that security issue Ged referred to was fixed by the author. - Perrin
Re: Apache::SimpleTemplate
on 7/8/01 2:46 AM, Gunther Birznieks at [EMAIL PROTECTED] wrote: In addition one of the criteria for useful to me is fast. If the template system is slow, it's quite annoying. However, this goes against other people's ideas of useful being full featured. As Steven Wright says (paraphrased) if you had everything where would you put it? I think this is more of an issue with CGI. All of the popular tools are fast enough under mod_perl that they're very unlikely to be your bottleneck. It's far more likely to be database work or IPC of some kind that slows down an application. Under CGI, the caching schemes of many of these systems don't work. That does make a difference. - Perrin
Re: ePerl (fragment of Re: Apache::SimpleTemplate)
At 07:47 AM 7/8/01, Ged Haywood wrote: On Sat, 7 Jul 2001, Todd Finney wrote: We use ePerl for a fair number of things, and I have yet to run into something we needed of which it was not capable. Didn't I read somewhere that there were security concerns? There was a fix made in 1998 regarding QUERY_STRING, but I think that was the last time anything like that came up. I'm not even sure there's been a new release since then; I suppose that could mean either Ralf has lost interest in it, or it's just 'done'. It's probably a little bit of both. There's a patch to make it work with 5.6 floating around, but I haven't seen anything else new in some time. Todd
RE: ePerl (fragment of Re: Apache::SimpleTemplate)
At 02:40 PM 7/8/01, Perrin Harkins wrote: We use ePerl for a fair number of things, and I have yet to run into something we needed of which it was not capable. What are you thinking of? It's not a question of it not being capable, it's just that most people seem to choose one of the more full-featured tools. Yea, I'm a glutton for punishment. :/ I don't necessarily mind, though - reinventing the wheel periodically is a good learning experience. There's lots of talk on the list about Apache::ASP, Embperl, Mason, etc., but not much about ePerl. (Maybe I should do some research in the mail archives and graph the results. Sounds like a magazine column...) Also, I think Text::Template stole some users away from ePerl. It probably doesn't help that ePerl isn't even listed at perl.apache.org with the others. Like SSI, ePerl is perfect for some people who just want a simple solution that stays out of their way. ...and people that are too lazy to bother remembering the difference between [+ +], [- -], and [! !]. cheers, Todd
Re: Apache::SimpleTemplate
On Sat, Jul 07, 2001 at 06:00:24PM -0400, Geoffrey Young wrote: I actually use Text::Template for all my templating (sigh), and have such a wrapper (save just a bit of custom code). I basically implement the HASH version and use a PerlInitHandler to set up the substitutions using pnotes. I can work it up into a more generic release if anyone is interested, but using Text::Template is really incredibly simple and it's just a few lines of code (and actually twice as long as it needs to be due to copious debugging), so I really don't think a release is warranted. In reality, I feel guilty every time I use it for not migrating to TemplateToolkit or one of the other systems available. Why feel guilty for using something that works for you? I use CGI::FastTemplate in most the stuff I write now and I'm quite happy with it, since it gets the job done. I wrote my own wrappers around this module too, like you and it works pretty well with the rest of the framework I use. -- Thomas Eibner http://thomas.eibner.dk/ DnsZone http://dnszone.org/ mod_pointer http://stderr.net/mod_pointer
Re: Apache::SimpleTemplate (don't do it!)
Yes. Writing a templating system in Perl is trivial. Writing a *useful* templating system in Perl is demonstratably hard. I too have written a templating system. About a year ago I wrote a simple module called dbq.pm. It performed database queries. Basically, you could mock up a simple html page, add some special dbq tags, and it would run queries against the database. I wrote it to see if I could write a simple version of ColdFusion It took 90 minutes to write on a saturday night. On monday morning, I made the mistake of showing it to my boss. He made it is personal quest to try to rewrite parts of our existing CGI system using this 90 minute version of ColdFusion. As his quest continued, he found that there were certain features that were not present. It was quickly made a company project, and new features (such as the ability to interface with our existing widget and api modules) were added. Then we switched to using XHTML. Everything had to be compliant. We started using Expat. DBQ (now XML::DBQ) started core dumping mysteriously. We traced everything to a problems with the (then unstable) Expat libraries. So we rewrote the XML parser using native perl. Since we now had full control over the parser, we found we could add new features (like if else constructs and defines). Then we added the ability to execute internal perl functions (like substr). Our quest was still not over, and we continued to add more features. And it is now that we realize that we have written a system that is 3 times slower than CGI, 8 times slower than mod_perl, 10 times more difficult to read than perl, and is being used in about 45% of our site. The moral of this story is that using an existing templating system will save you more hours of coding, learning, debugging, upgrading, adding new features, and maintaining than you could possibly hope to account for when writing a Simple templating system. I hope this helps answer any questions about why you should not write your own templating system. Robert Landrum
RFC: Apache::SimpleTemplate
hello! yes, i have *yet another* templating mechanism for mod_perl, and i'd like to add it to CPAN if there are no major objections. the rational: Like other templating mechanisms, it allows you to embed blocks of Perl code into text documents, such as HTML files, and have this code executed upon HTTP request. However, it is meant to be a slim and basic alternative to existing packages (Apache::Embperl, Apache::ASP, ...), without any added syntax/tags/etc, and with only the bare necessities of functionality. This is a single, small module with no dependencies other than mod_perl. It is intended for someone with basic templating needs, or for someone who wants a bare-bones building-block to subclass and to add any other methods to. i'd like to use the name Apache::SimpleTemplate. if anyone wants to see the current pod: http://peter.nyc.ny.us/simpletemplate/pod.html all thoughts are welcome. thanks! -- peter forty [EMAIL PROTECTED]
Re: Apache::SimpleTemplate
yes, i have *yet another* templating mechanism for mod_perl, and i'd like to add it to CPAN if there are no major objections. I hate to be a naysayer, but this doesn't look sufficiently different from the other options to merit adding it to CPAN. The trouble is, there are already too many of these and it looks an awful lot like Apache::ePerl, or Text::Template. At the moment you may think there's a need for it because it's simpler and smaller, but it will almost certainly grow over time. If you look at the other modules and still think what you have is truly different, please elaborate a little on why. No one here is actually going to stop you from posting it to CPAN, but I will try to talk you out of it if there's no clear reason to prefer this over other tools. I mean, just look at the train wreck you get back from this: http://search.cpan.org/search?mode=modulequery=template - Perrin
Re: Apache::SimpleTemplate
I hate to be a naysayer, but this doesn't look sufficiently different from the other options to merit adding it to CPAN. hi, thanks for your comments. i was expecting some such naysaying, and understand your point. but, i still disagree and think that simplicity *is* a valid difference. i had looked at many other modules, and i know other people who have as well but want a simpler alternative. most of the mod_perl/template packages out there are not basic building blocks-- they lie in some uncomfortable area between building blocks and full content-management systems. i don't mean to knock them at all, but for some people's needs these are way to complex and bloated. The trouble is, there are already too many of these and it looks an awful lot like Apache::ePerl, or Text::Template. Text::Template probably is the most similar existing package, but it is not made for mod_perl. someone well- versed in mod_perl could build a mod_perl wrapper of it fairly quickly, but they or especially someone new to mod_perl shouldn't have to. (i don't know of any such wrapper existing in CPAN...) if i'm not mistaken, Apache::ePerl builds a new interpreter, which also seems like overkill for many needs. (i'd like to try it out, but it won't compile for lack of perl =5.003-- i'm using 5.6.1 :). i want a perl-only implementation, that doesn't need a new c lib. At the moment you may think there's a need for it because it's simpler and smaller, but it will almost certainly grow over time. i can't say that no features will ever be added, but i think it is fair to say that it will always remain much lighter and smaller. i will not add database access, XML-hooks, or new syntax/tags, and it will always be a straight perl implementation. so, that's my elaboration. i really don't want to create mess in CPAN and appreciate efforts to prevent that, but imho this is a useful, non-superfluous addition. if someone knows of something more similar, or if there is no positive feedback, i will certainly reconsider. peter
Re: Apache::SimpleTemplate
On Sat, 7 Jul 2001 [EMAIL PROTECTED] wrote: Text::Template probably is the most similar existing package, but it is not made for mod_perl. someone well- versed in mod_perl could build a mod_perl wrapper of it fairly quickly, but they or especially someone new to mod_perl shouldn't have to. (i don't know of any such wrapper existing in CPAN...) if such a wrapper did exist, would you use it? if it doesn't, why don't you write one yourself?
RE: Apache::SimpleTemplate
-Original Message- From: brian moseley To: [EMAIL PROTECTED] Sent: 7/7/01 5:34 PM Subject: Re: Apache::SimpleTemplate On Sat, 7 Jul 2001 [EMAIL PROTECTED] wrote: Text::Template probably is the most similar existing package, but it is not made for mod_perl. someone well- versed in mod_perl could build a mod_perl wrapper of it fairly quickly, but they or especially someone new to mod_perl shouldn't have to. (i don't know of any such wrapper existing in CPAN...) if such a wrapper did exist, would you use it? if it doesn't, why don't you write one yourself? I actually use Text::Template for all my templating (sigh), and have such a wrapper (save just a bit of custom code). I basically implement the HASH version and use a PerlInitHandler to set up the substitutions using pnotes. I can work it up into a more generic release if anyone is interested, but using Text::Template is really incredibly simple and it's just a few lines of code (and actually twice as long as it needs to be due to copious debugging), so I really don't think a release is warranted. In reality, I feel guilty every time I use it for not migrating to TemplateToolkit or one of the other systems available. --Geoff
Re: Apache::SimpleTemplate
On Sat, 7 Jul 2001, brian moseley wrote: if such a wrapper did exist, would you use it? if it doesn't, why don't you write one yourself? maybe. i did use Text::Template in the first iteration of this, but it was considerably faster to parse the templates internally. (i don't remember how much faster, but something like 25% for a dumb, do-nothing template.) it seemed worth the savings not to wrap it.
ePerl (fragment of Re: Apache::SimpleTemplate)
At 06:10 PM 7/7/01, Perrin Harkins wrote: if i'm not mistaken, Apache::ePerl builds a new interpreter, which also seems like overkill for many needs. It's pretty easy to install, really. However, it's not very popular these days because it doesn't have all the features people end up needing. We use ePerl for a fair number of things, and I have yet to run into something we needed of which it was not capable. What are you thinking of? I'm not trying to start a holy war - embperl is darn nifty, and I haven't used any of the other packages enough to have a solid opinion of them. Right tool for the job, use what's comfortable, blah blah blah. ePerl is butt-simple to install, and a snap to learn (put your perl in ? here !). We've been using it for ~4 years (I think), and have never seen a problem with it. IIRC, according to the various benchmarks that bounce around periodically, it's not as fast as some of the other packages, but that's never been an issue for us. Just asking. cheers, Todd
Re: Apache::SimpleTemplate
On 7 Jul 2001, Randal L. Schwartz wrote: Yes. Writing a templating system in Perl is trivial. Writing a *useful* templating system in Perl is demonstratably hard. unless you keep application features in a separate layer from the templating system (eg the servlet api ;)