John, On Mon, 31 Jan 2005 14:09:55 -0500, John williams <thudfactor at gmail.com> wrote: > Nothing is more lightweight and fast than just using PHP's own > print-and-echo statements. Remember you can use <?= $var ?> in place > of <?php echo $var ?>. In fact, just by using a class definition you > are significantly slowing down the execution of PHP. How much execution time on average are you saving by using straight PHP over Smarty? On its first invocation, Smarty compiles the template into straight PHP anyways, and your gains are on the order of fractions of milliseconds. Or, your "gains" are on the order of negative milliseconds, under many conditions where you should be semi-caching database-dependent output with something like Smarty. That menu you are generating from the databse -- how often does that change? Can it really change with every invocation of the script? You are sacrificing performance for the ability to easily change the menu, when you COULD have your cake and eat it too by an appropriate expiration on a portion of your Smarty-based output. In this instance, you could have the cache rebuilt once an hour. Then, your database will get hit 24 times per day and at most you will have to wait 60 minutes for your menu to update after a change to the database. Or, you could have your cache never expire, and on the admin page to edit the menu, you could force an expiration with one Smarty statement. Certainly, we all have our preferences, but they ought to be based upon a solid understanding of the choices. And let's not forget that Smarty isn't even about performance -- it's about promoting separation of business logic and presentation, and allowing a non-programmer designer to edit templates while the programmer simulaneously creates the business logic. Speaking from experience with Smarty, it is at least 100x easier to correctly separate the two when using Smarty than when not (one has to put effort into mixing the two when using Smarty). It's not for every situation -- but I would venture to say that there are plenty of situations out there where using Smarty is a good idea, but the programmer simply doesn't want to deal with learning how to use it (which, by the way, takes about 5 hours at most, unless you're going to be writing your own plugins, etc). > I like Smarty, too, and use it in most of my large projects. And I > also use classes, so this shouldn't be taken as a slam against Smarty > or classes in general. But for simple survey or form handlers, I don't > think anything beats straight PHP. It is, after all, what PHP was > originally designed to do. What does form handling have to do with Smarty? Along those lines, though, Smarty + PEAR::HTML_QuickForm (or the like) is a knockout duo. -- Matt Warden Miami University Oxford, OH, USA http://mattwarden.com This email proudly and graciously contributes to entropy.