1. It's a loaded foot gun. PHP was notorious for 1000 line files with HTML and SQL all mixed together. (I speak from personal experiences on this)
2. Templating languages are "portable" (In theory). Have a mixed env of PHP and Java... there were templating languages that would work for both teams, it took a step out of scalability.... XML and XSLT were the promise land on this one, but we fucked all that up. Portability is a big deal. We're still slinging CSV files for a good reason.
1. I've seen enough terrible things in my time, but you can make a mess in any language using any number of frameworks. And it's been a hot minute since I've seen one of those 1000+ line PHP+SQL+HTML+JS+CSS monstrosities in any serious environment.
Improper use of templating engines or trying to use templating engines that aren't up to the task can give you headaches just as well. Sadly no amount of frameworks or templating engines can stop a bad programmer from writing bad code, in the end we're craftsmen who need to learn how to use our tools.
2. This could be a valid use case, but a rather rare one. XML+XSLT is something that sounds fantastic on paper, but as anyone who actually worked with it knows it ranges from a big disappointment to an absolute nightmare.
If you need guard rails to keep you from performing database manipulations in your views you have other problems to worry about. And if anything people are cutting corners on SOC in the M and C part of MVC, not the V part.
Also I don't see how using a loop or conditional in PHP is any different from using one in a templating engine, aside from the overhead of the engine and added annoyance of debugging another language in your project.
> If you need guard rails to keep you from performing database manipulations in your views you have other problems to worry about.
Those problems are called "junior developers", and I think we'd all like to avoid them, but that's not very sustainable.
Perhaps we can fix the education problem, but given that folks just do a boot camp and head into the market, prospects aren't looking good.
> Also I don't see how using a loop or conditional in PHP is any different from using one in a templating engine, aside from the overhead of the engine and added annoyance of debugging another language in your project.
The problem is convention, or lack thereof. Without convention, who's to say where that database call should live? Frameworks, which tend to use templating languages for this reason, tend to make that convention clear to all teammates.
I want to mention that this doesn't mean you can't use PHP as the programming language for your templates as long as the conventions are clear, but PHP is poorly suited to being a template language for reasons I've posted elsewhere in this thread.
>>> If you need guard rails to keep you from performing database manipulations in your views you have other problems to worry about.
Its a one off... Its just an internal tool... This is a prototype... It's a hot fix...
I know better, I have done it. It is only with dumb luck that they didn't end up as products. Some people dont know that they should not or that it isnt a place they should try to "get away" with it. These things grow and then turn into products and someone has to clean them up.
Source: I made a lot of money turning PHP "projects" into "software".
> Also I don't see how using a loop or conditional in PHP is any different from using one in a templating engine
One of these things is Turing complete. The other is not.
Templating languages have their own laments: see yaml configs used to create "workflows", "environments" and "servers" via templating.
I've seen Python that was almost as bad as PHP. At one company, a guy actually complained that he didn't want to use multiple files, third-party packages, or anything outside of the stdlib. He'd write everything inside of a single "main.py" that ran as an AWS Lambda, which he often edited live in the console. When I first saw this, I thought I had landed on another planet.
At another job, another guy built some massive abstract-factory-factory-layer in Python, a class hierarchy 4 or 5 layers deep. 5000+ lines in a single file. It was almost impossible to debug.
Both of these are better than some C++ code I once saw. 10,000+ lines in a single file. In that file, there was a function with a 3000+ line case statement, which was mostly copy-pasta'd from other parts of the code (not in that 10K line file.)
I have seen plenty of PHP code that smelled like a nuclear dumpster fire, but you can write trash in any language.
1. It's a loaded foot gun. PHP was notorious for 1000 line files with HTML and SQL all mixed together. (I speak from personal experiences on this)
2. Templating languages are "portable" (In theory). Have a mixed env of PHP and Java... there were templating languages that would work for both teams, it took a step out of scalability.... XML and XSLT were the promise land on this one, but we fucked all that up. Portability is a big deal. We're still slinging CSV files for a good reason.