An important aspect of this problem: Even if the overall system is too complicated for beginners to understand, beginners may be able to usefully tinker with the system if it is built out of parts that they understand. The problem with PHP-based systems is that their most complicated parts may need to be built out of PHP, but the bonus is that all their simple parts are also built out of PHP, and often the bulk of the maintenance boils down to tinkering with the simple parts.
Code that is simple is easy to maintain. This is not to say that simplicity wins over the use of complex design patterns and abstractions in every scenario. It's a trade-off that needs to be considered on a case-by-case basis.
This is especially true in the open source arena where it is critical that new developers can come along and read, understand and improve existing code. Code that is too complex will not be understood and will almost certainly lead to errors.
Yes. Andi Gutmans, Zend co-founder and PHP developer says:
“the right way to think about PHP is as Visual Basic for the Web.”
http://www.tbray.org/ongoing/When/200x/2006/10/31/Zend-PHP-C...
PHP is in essence a fairly narrow tool, much like a chasing hammer (which really isn't that good for driving nails but is extremely important in some kinds of metal work). It is a preprocessor for SGML files (and this is why all programming logic is typically put in SGML PI tags). I call it a "templating system turned on its head" because whatever you do with PHP, every file is lexically part of the template even those which have no other SGML tags other than the PI tag which is indicating programming logic.
But what this means is it works very well in its own specific domain (namely preprocessing HTML, XML, and other SGML files), but degrades quite a bit as one gets out of this area. This limits code reuse basically to web apps (yes, I know you can write GTK apps in PHP, but really? why on earth would you want to?) and thus locks one into essentially one set of technologies. So there are drawbacks as well as advantages.
So for a beginner web developer, all they need is a GoDaddy account and a couple tutorial guides.
The sad thing is that many developers stop here. They don't go on to figure out how PHP and Apache work together, how memory gets used and how to manage it effectively. They don't get exposure to proper coding standards (PHP's common standards are horrible IMO). And more often then not, a PHP developer learns how to code in isolation.
Coding should be developed as a mentored skill.
But every design choice cuts both ways. These features are not merely drawbacks. These are PHP's strengths, the things that make it so delicious for "HTML authors who need to cross over into programming".
You can learn PHP with Google. My understanding is that most people do. [1] Just Google all your problems and up will pop some code that you can mimic. This works because, to first order, all PHP code is solving the same problem in the same way. You will probably not accidentally Google up some PHP-based physics simulation. You will probably not Google up some PHP code used by sysadmins to parse the output of pipes on the command line. You will certainly not Google up any PHP-based graphics algorithms or device drivers or client-side DOM manipulations or Android system functions. No, when you Google "how to do X in PHP" you'll get some code that you can paste into a template with a .php extension and then execute on your cheap shared host. Until fairly recently there wasn't even any danger of encountering object-oriented PHP.
You can argue that programmers trained in this way are useless for anything but cobbling together Web pages, and you're right, but 90% of them don't care. Web pages are a killer app. People build whole businesses out of cheesy web pages.
My suspicion is that many PHP tinkerers don't want more "architectural flexibility"; that translates into "decisions that we have to make but don't know how to make", "knobs that we have to set carefully but which we don't even know how to turn", and "oodles of online documentation for use cases that we don't have, which chaffs up the search results for the use cases that we do have."
The irony, of course, is that PHP's maintainers have been hard at work bolting features from other languages onto PHP, which as a side effect threatens to destroy the narrow domain-specificity that was its most unique feature. [2] Objects, namespaces, closures have all been welded onto the superstructure. One wonders what happens next. Maybe the folks who embrace all these things will drag the entire PHP community closer to Java, Python, Ruby, or some oddball superposition of these things. But I think it more likely that the community will continue to balkanize, with the bulk of users rejecting all these transplants but certain segments embracing one or another of them.
---
[1] I learned PHP via reading and hacking on Drupal modules, which is a much better plan, but also definitely not the beginner-friendly choice. Drupal has a steep learning curve.
[2] Though don't blame the maintainers too much: These features are in fact in demand, from the people who took up PHP without realizing that it was a narrow domain-specific language and pushed it right up to the limits of the available hacks.
I would wager that a language designed for beginners wouldn't have so much inconsistency, nor dump the user in a world of security issues with little or no support (XSS, CSRF, SQL injection).
Other people have worked around these issues, but that demonstrates the lack of support within the language.
The lack of built-in XSS prevention in PHP makes it quite terrible as templating language, especially for beginners who probably have never heard of XSS. The same applies to the simplciity of string interpolation combined with the terrible built-in MySQL driver which makes parametrized queries harder than they should be. All this used to be even more confused by the Magic Quotes in previous versions of PHP.
With so many security traps it is not a language I would recommend for beginners who just want to build something that works.
Can you expand on this, specifically as it relates to WordPress? I work with WordPress, so I'm curious as to what about it you'd consider beginner-level architectural patterns.
(And FWIW, I'm not trying to start an argument - I'm actually genuinely wanting to learn, thus my question)
Example ? Check out this file:
http://core.svn.wordpress.org/trunk/wp-admin/edit-comments.p...
there, you will see SQL statements, tons of application logic, as well as HTML output rendering. A large amount of the HTML rendering is additionally not templated but rather a long line of imperative string concatenation calls. It's all the worst examples of what PHP has encouraged, all in one file. The enormous quantity of source files present in Wordpress, most of them non-self-explanatory, is a product of this style of design.
I've never heard this before. PHP is certainly very easily picked up by beginners, and in my own opinion makes it easy for said beginners to spend years and years not moving very far beyond beginner-level architectural patterns (just look at the source of Wordpress for an example), but do the creators of PHP really consider it to be "a language for beginners" ?
I have an entirely selfish agenda here. The next time some know-nothing manager promises his client "we have the top programmers with years of experience who will write the highest quality code you can get", then demands that we do everything in PHP because that's all he knows, we can say, "really? You're going to charge the client all that money, then give the client an app written in a "beginner" programming language ?"