Marco Arment (in a response to Jeff Atwood) came up with a list of five common complaints that are not valid reasons for hating a programming language:
- You’re unfamiliar with it.
- You don’t like the language’s vendors.
- Idiots often use it to write bad code.
- It doesn’t fully resemble your favorite language.
- You don’t like its syntax.
PHP’s not a perfect language, of course. Nothing is. But it’s by far the best language to use for nearly any web application, as long as you use an appropriate framework and good coding practices. Any language without either of those is bad.
I’d agree that PHP has its foibles, such as its lack of closures, its bloated global namespace and its ad-hoc, inconsistent approach to conventions. However, none of these are insurmountable, and in fact, once you get used to its foibles, working with PHP isn’t all that hard.
A few days ago I finished up on several days’ work on a PHP project and started on a 𝔖𝔥𝔞𝔯𝔢𝔓𝔬𝔦𝔫𝔱 workflow. It’s an exercise that I highly recommend for anyone who is tempted to write an anti-PHP rant, because it will put everything in perspective, and give you a list of valid reasons for hating a programming language, platform or framework:
- Vertical and infinite learning curve.
- Unnecessary complexity.
- Useless documentation.
- Excessive pitfalls, gotchas and leaky abstractions.
- Design that obstructs you from adopting best practices.
- Meaningless, cryptic and uninformative error messages, buried in a massive log file deep in an obscure part of the bowels of your file system.
- Painful debugging process.
Check this out: to debug a 𝔖𝔥𝔞𝔯𝔢𝔓𝔬𝔦𝔫𝔱 workflow you can’t just hit run in Visual Studio. You have to attach the debugger to the w3wp.exe process, and even then it still won’t hit your breakpoints or break on exceptions. According to this blog post, you have to copy the .pdb file by hand into a part of the GAC’s directory structure that you can’t even access through Windows Explorer, so you have to do it via the command line. On top of that, the edit-compile-test loop is agonising — it can take two minutes to re-compile, deploy, and re-load your test site into your browser, after which you may well have to remove and restart the workflow.
Admittedly it’s not all bad. The vertical and infinite learning curve at least gives you some immense satisfaction when you finally “get it”. However, getting there feels at times like climbing the Inaccessible Pinnacle in rollerblades with your hands tied behind your back.