Lately I've been coming across several jokes and comics about how apparently awful PHP is.
As a complete ignorant of the language, why is this? Is it my own perception or is this the overall general feeling on the programming community?
Note: This is written from a highly opinionated stance.
See also: PHP: A Fractal of Bad Design
Long ago, when the web was young, you wrote a web app in perl. That was really it. That was your only choice (unless you really liked working with strings in C). (And yes, I'm glossing over great swaths of ASP and the like... I'd rather forget those days.) There were great and large applications of the web written in perl. And there were many, many pieces of... well, crap written in perl. You can still find them if you look - buggy CGI scripts that someone slapped together that don't even come close to sanitizing their inputs.
As the web became more enterprisey, the great and huge applications moved to other frameworks that were better designed for handling thousands of connections (perl at that time wasn't). Those who could learn a new language moved on to Java (that was the best choice for many frameworks). Those who couldn't, well, there was this language that looked a lot like perl and did some things better (didn't need to fork a process for each request). It was php.
Php grew, organically... if you can call a Frankenstein monster organic. Lots of hacks (did you know the original hash function for function names was strlen?). Partial things added to the core language (rather than libraries) that still remain there today. Its not that pretty. (Poke at reddit's /r/lolphp which pokes fun of many of these inconstancies... did you know that -1 month
is always 30 days?)
And while great and huge things have been built in php (look at wordpress as an example), it is still a monster under the covers with esoterica about how things work (or don't work, or what parts of things work most of the time).
It's the quick and easy language to learn so a lot of people who don't want to spend time learning a language use it. And then when it breaks and you have to maintain it now? Well, a language that allows such lack of discipline from coders who don't always understand what they are doing makes for some very 'interesting' bugs.
Its the language of quick tossed together websites and half baked wordpress plugins. Where some 16 year old wrote the code for their neighbor for $20 or a college student for beer money... knowing that they'll never look at it again. Go browse Stack Overflow's php tag for a bit and consider that you may be maintaining that code some day.
Remember that everyone else's code always sucks. And if you have to deal with someone else's code in php - it sucks.
fuck you, I manage just well through all these exceptions
, it really is an opinion-changing post. – Félix Gagnon-Grenier Dec 04 '14 at 15:13