When templates gets in the way

Published on 2013-03-26.

I honestly believe that many people who use template engines in PHP use them because it's "the hip thing to do".

Take a car. Inside the car we have the controls to operate the car. We have the wheel, the pedals, and the stick (whether it's automatic or manual). Now, let's build a box that we can put on top of those controls, a complicated interface. Now, instead of the wheel, the pedals, and the stick, we operate the car using a bunch of push-buttons.

To some that might look pretty, but all we have done is add another layer of complexity to the car.

Rather than having to learn how to operate the car with the new interface we might as well learn how to operate the car the good old fashion way.

I have never spoken to a designer who actually found that working with templates was easier than working with the underlying programming language!

Why spend time learning some stupid template language that is just as complicated as the programming language, and often even more illogical, than the real programming language?

You might as well spend time learning the real programming language, at least the part you need to use. Then instead of having learned a template language you can use for absolutely nothing else, you have learned a little about programing.

From another perspective since the template engine adds another layer of complexity you now have multiplied the number of possible bugs in the system.

A template engine will also always be slower than using the underlying programming language. The template engine will have a lot of parsing and regex to process. Mostly the template engine also lacks support for even the most basic tasks.

It is perfectly possible to build systems withour templates engines and still separate the design aspect from the code simply by using well structured code, you don't need to add complexity using a template engine.