17

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?

closed as primarily opinion-based by Jimmy Hoffa, Doval, user40980, Blrfl, GrandmasterB Nov 21 '14 at 4:37

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    I write software in c# and hear all the Microsoft criticism, it's pretty much just bash the other language – Scott Selby Nov 21 '14 at 1:52
  • 12
  • 4
    @Andy one shouldn't forget Jeff's blogs posts: The PHP Singularity and PHP Sucks, But It Doesn't Matter – user40980 Nov 21 '14 at 2:33
  • 4
    Aren't there two types of languages... the ones everyone hate, and the ones no one uses. – GrandmasterB Nov 21 '14 at 4:36
  • 2
    @HerrK the only way that it can be answered (mine included) is that of opinions as to why you think that php sucks. It also would lead to non-productive discussions (it sucks! no it doesn't! Java sucks just as much!). The question doesn't optimize for the good answers as it is currently written (this doesn't mean a good answer can't be written). As an aside, a good place to ask discussiony and opinion questions is that of Software Engineering Chat. It would be especially useful to chat with our own Yannis about php and its perceptions in the industry. – user40980 Nov 21 '14 at 17:38
28

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.

  • 5
    no wonder people hate php if they take wordpress as an example... frameworks like Symfony or classes like Pimple are better written clean php scripts which I would love to have to maintain. symfony.com/components pimple.sensiolabs.org – Félix Gagnon-Grenier Dec 4 '14 at 7:48
  • Every language has bugs in it. PHP had a ton of these bugs. Some are sorted, some are as it is, but alternative are created. PHP evolved with time. BUT the problem is the community. It has a community filled with noobs and amateurs. My senior once said "nobody knows php, even if they have 5 years of experience". That's true more than half of php developers don't know OOP concept. they just get work done using array and string functions copied from stackoverflow. – tejas.jaiswal Oct 4 '18 at 6:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.