DEV Community

Joshua Johnson
Joshua Johnson

Posted on

What's the deal with downing PHP development?

I'm trying to wrap my head around why so many developers down PHP development like it is a second class language?

Secondly, what are the better alternatives for web development?

Latest comments (64)

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli

PHP is the only language where I have seen development practices that are mind blowingly awful. I fully understand that you can write bad code in any language, but for some reason PHP devs manage to top any expectation of bad code one could have.

Let me give you 3 examples.

  1. The switch statement (or equivalent) is available in many languages. It is fine to use. The paradigm is that you switch on a variable and each case is a constant. There are two languages I am aware of that do not enforce that constraint. javascript and PHP. There is only one language I have seen this constraint ignored. PHP. In multiple places in the code they used switch(true) and the case statements called functions. This was a well known company.

  2. Using comments as code. I was trying to use a CMS developed in house (different company to the one above, not well known) and I was trying to figure out how to change which the main page was. I had to change part of a comment. I realise this isn't a default part of the language, so I guess the dev must have felt really proud of themselves.

  3. Drupal 7 breaks PHP's raison d'etre. In my opinion PHP is a templating language for HTML. That's the best you can hope for it. Drupal 7 (maybe 8 is better, I don't know, I ran from PHP after this) is clunky, slow and confusing. But on top of that we had installed three themes, two were deactivated. Yet somehow a deactivated theme was able to interact with the active theme and break the templating it provided. Amazing. Why would Drupal allow deactivated themes to do that?

So, sure, you get bad programmers everywhere, but the frequency and severity which they occur in PHP means I am never going near it again. It is a bad language.

Collapse
 
mellen profile image
Matt Ellen-Tsivintzeli

As an alternative, I find Django a lot easier to get into and use than Drupal.

 
thinsoldier profile image
thinsoldier • Edited

The most likely person to review my php code is someone who also knows php.

And if I'm using a library whose author preferred camel case along with another library whose author preferred snake case, the problem still exists independent of PHP's inconsistencies.

Collapse
 
notriddle profile image
Michael "notriddle" Howell • Edited

Let me start with a blatant opinion: I'd rather use PHP than pre-await Node for writing a web application, because callback-oriented development is stupid. Node only became worth using when they added async-await, and even with that you end up having to write wrappers for outdated parts of the standard library just to write straightforward code. JavaScript just isn't that good of a programming language anyway.

Now with that out of the way, PHP has two big problems:

  • It's inconsistent. Like, blatantly inconsistent, for no obvious reason. Some functions have prefixes like array_map($arr, $fn), some of them don't like sort($arr), some of them are not actually functions like empty($arr), and PHP has method call syntax, but doesn't use it for any of the array stuff. And parts of the standard library use CamelCase, while others use snake_case. The classes stdClass and DateTime are both in the standard library, too, just in case you were wondering what type of case class names should use.

    • Because of this, WordPress and Laravel both have equal claim to being "the PHP way" despite having such different coding styles. The better-respected Python, for example, has "there should ideally be one clearly correct way to do it" in its core manifesto.
    • Even other old crufty programming languages, like Java and C, are still able to at least follow consistent naming schemes (C always uses snake_case, Java has lowerSnakeCase variables and methods and UpperCamelCase classes).

  • It has built-in affordances that are unusable in large, well-tested codebases. Superglobals, for example, make any functions that use them much harder to test, and php.ini is just one more piece of the environment that can affect whether a piece of code works right or not. And when PHP starts writing warning messages to the browser that get interleaved with the rest of your HTML, stuff can get really, really broken, so you have to turn that off, too, in production.

    • The last big PHP app I worked on had a bunch of wrappers to try to work around this, and shipped a "use this php.ini" in the source repo for the same reason.
 
5n4p_ profile image
Andreas Schnapp

I must admit that my knowledge of PHP might be outdates (I haven't take a look on PHP for years). But if you once really dislike a language you rarely give it a second chance. Maybe that's one of the core reasons for the bad reputation of this language.

So, I guess you are most likely right and I'm most likely wrong about the PHP of today.

 
5n4p_ profile image
Andreas Schnapp

Have you also switched sometimes to PHP too? ;)

Maybe it differs more then you thought...

Collapse
 
5n4p_ profile image
Andreas Schnapp

I think the impact of different syntax/grammar is much much bigger as in natural languages. Or could you easily express the same logic in assembler as in your favourite language. This should be very difficult and take much longer even if you really good in assembler.

Collapse
 
lucafabbri profile image
lucafabbri

that's why Spanish is the second ( or even the first ) spoken language, while German is the first hated :)

Collapse
 
itamarst profile image
Itamar Turner-Trauring

You might want to read blog.aurynn.com/2015/12/16-contemp...

Collapse
 
dserodio profile image
Daniel Serodio

I'm one of the PHP haters :) This post is able to express the problems I see with PHP much better than I can: eev.ee/blog/2012/04/09/php-a-fract...

Collapse
 
joshualjohnson profile image
Joshua Johnson

Yeah this one was shared already. My response was basically the beginning states that the author is “cranky.” Which lended itself to mean this blog post is basically bias. In order to make an argument, you have to remain unbiased. After all the comments to this question, I still don’t have a clear answer other than people just don’t like it. And there are many reasons they don’t like it.

Collapse
 
a_mujthaba profile image
Ali Mujthaba

Facebook was written in PHP

Some comments may only be visible to logged-in visitors. Sign in to view all comments.