Debunking Smarty myths

I have found yet another article condemning the use of Smarty because...

[...] When you add a template language on top of this the template language has to be interpreted, converted to php and then interpreted as php and outputted. This doubles the amount of work that the cpu has to do to return the page the user requested [...]

All right, Toms of the world: did you ever have a look at Smarty's temporary directory? (hint: it's usually called templates_c)

Because if you had done so, you would have noticed that the only times the templates are parsed are

  • a) the first time the template is loaded
  • b) when the template has been modified

All the other times Smarty simply includes the compiled (read: pre-parsed or generated) templates, which consist in php code! (that can be therefore accelerated with php op-code accelerators)

Now, once you recover from this possibly traumatic revelation, let me tell you something else: you can also cache entire pages with Smarty! And those will hardly involve your php interpreter at all when being served to the user, because most of the content will have already been generated! How smart is that?

I can understand you don't want to use Smarty because it's yet another syntax to be learnt, or because you don't want to add another layer of complexity to your code, or maybe simply because you don't like its syntax. But give credit where credit is due: Smarty has helped lots of high traffic sites get way further than they would have reached had they relied on php templating only, thanks to Smarty's cache functionality.

And that's an achievement few template systems hold.