DEV Community

Juan De los santos
Juan De los santos

Posted on

Why some people hate PHP?

Don't Hate PHP

For a long time I have seen that the developers around me hate PHP, and I still do not understand why this happens.

I don't like some PHP stuff, but that does not mean it's a bad programming language ... I think every programming language has its own purpose, so instead of starting to complain about "why PHP does not work for me " I think we should spend more time comparing different programming languages and choose the one that achieves the goal of your project.

What is your opinion?

Top comments (37)

Collapse
 
assertnotnull profile image
Patrice Gauthier

First I want to say the article "a fractal of bad design article" is a good reference. A complex tool gives the possibility of a complex solution. You don't need a complex tool to create something complex. Complexity should lie in the business code, not the framework/language. This is why Go is gaining momentum but it's also a hype (because Google).

PHP as a coding standard only since 2012 github.com/php-fig/fig-standards/c...
PHP had outdated tutorials for years and the "standard" framework Zend was/is paid so it was rarely used. So it also trained programmers with bad practices.. like common SQL injections.

As example, Python was there as long as PHP but from the the start they decided to impose a coding standard. Python PEP-8 exists since 2001. You don't hear much people complaining about Python because it was done simple and with a standard from the start. The Zen of Python is the best thing you can have in programming in general even I think.

Collapse
 
okolbay profile image
andrew • Edited

I second that, php community is immature, there’s still a ton of bad practices advertized as good/applicable solutions, progress of this platform is slow and innovation is not there at all, what is it php community actially introduced, and not borrowed? I am a php dev btw, but hey folks, lets be realistic, there is NOTHING exciting about php

Collapse
 
tnsaturday profile image
TNSaturday

Well, being able to just
$username = $_POST['username'];

was pretty much exciting in 1995, don't you think?

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

Because people use Y, and it's clearly better than X.

All languages have strong points and weak points. These pros and cons also vary based on domain: there are some places where PHP is useful, and other places where it's utterly useless.

Every coder should know multiple languages. I think it's a legitimate concern that if somebody knows only PHP* that their coding knowledge is somewhat limited. There are so many differnet constructs in other languages that you might just never see in PHP. Granted, it, like all languages, evolves over time.

*My concern applies basically to any language. You can't know just one and expect to be a good programmer.

Collapse
 
tnsaturday profile image
TNSaturday

Every coder should know multiple languages.

I second that. Also changing levels and paradigms also helps a lot. For example, if someone uses PHP on a day to day basis, learning something like Scala or Clojure would change his way of thinking completely.

Collapse
 
chocolim profile image
Choco Lim

PHP is the best worst programming language.

I love it, and hate it too.

Collapse
 
gash profile image
Gash

I don't mind using it as long as it does the whole job.

Collapse
 
weswedding profile image
Weston Wedding • Edited

A lot of it is because it's the cool thing to do! Especially when it comes to PHP and JavaScript, the mockery is because it's just "common knowledge" that they're bad languages even though if you press someone to explain why they won't be able to. Even if they have a reason it usually involves arbitrary examples or really specific expressions that fail in surprising ways that don't really have real world examples.

PHP and JavaScript both came out of a particular moment in history and seem to have a lot of overlap in their issues; loosely-typed languages often do.

The noise with Javascript has died down considerably in the past 5 years, though. People are less certain about their mockery because of how big Node.js has become and how robust some of the frameworks written on the front end have become.

It's still easy to find, though.

Some people do legitimately get burned, though. Languages all have landmines, even strongly typed languages.

Collapse
 
tnsaturday profile image
TNSaturday

The big thing with JavaScript is that is the only language that lives in the browser, so people have to use it whether they like it or not. If PHP was the only language to run natively on the server, few to none would ramble on it.

Still, they are unsatisfied with JavaScript and have written a bunch of transpilers for it - that clearly resembles that even in situation of only one language possible people tend to find troubles.

Collapse
 
thinsoldier profile image
thinsoldier

I have encountered far too many people who think PHP is from the mid 90s while thinking javascript is from the 2010s and therefore better and "modern"!

Collapse
 
jjsantos profile image
Juan De los santos • Edited

I agree with you, most of the time, when we "love" a programming language or something else, we also hate it or get frustrated, because we always find something difficult that we can not find a way to solve it unless we spend a few minutes/hours playing around with a tedious documentation... XD

Collapse
 
shenril profile image
Shenril

I wrote my opinion there :)
code-artisan.io/love-letter-to-php/

Collapse
 
eljayadobe profile image
Eljay-Adobe

Programming languages are tools. Some languages are more suitable for a particular domain.

PHP is a tool for a fairly narrow problem domain, albeit an incredibly popular domain.

For all the PHP haters out there, the next question ought to be "Well what would be a better tool to use in this problem space?"

To quote Bjarne Stroustrup, "There are only two kinds of languages: the ones people complain about and the ones nobody uses."

My primary programming language is C++. I have a love-hate relationship with C++. I've been using it for the last 27 years.

When I consider my project, there is no ROI in rewriting the application in a different language. It would take years to port. Assuming the entire team was working on such a ill-advised rewrite.

Be that at it may, as a thought experiment, I've considered what would be suitable alternative languages that would be better than C++ for my project. Maybe... C, Go, C#, F#, Scala, Clojure, Swift, D, or Delphi/FreePascal/Oxygene. That's a big "maybe", and for each alternative language to C++ there are pros/cons tradeoffs, rather than clearly superior language.

PHP is likely in the same situation. What would be a viable alternative languages to PHP, for problems which are well suited to PHP's wheelhouse?

Collapse
 
okolbay profile image
andrew

ehm, ruby?)

Collapse
 
eljayadobe profile image
Eljay-Adobe • Edited

Ruby on Rails would be one reasonable alternative to PHP.

I'd probably choose Elm.

Otherwise, Python on Django... because I dislike both Ruby and PHP, and I like Python. But that's just me.

However PHP has a certain appeal* that Ruby, Python and Elm don't have.

* not to me; but I can see where PHP lures kids into the van.

Collapse
 
pchinery profile image
Philip

I think it is a mixture of the language and what people did with it. It provides a really shallow barrier to start programming, so a lot of newbies started doing stuff with it (I did as well) and so the "average code level" is or was lower. And I think that's just natural, because we all started a some point and (hopefully) learned a lot since then. But the impression from these early days can stick in people's minds.

The second part is, that the makers of PHP were learning how to create a language while creating one as well, which led to entry and removal of magic quotes, auto variables etc. and also inconsistent names and parameters for the functions (search with needle and haystack or array and item?).

And when the people have set their mind and start making jokes, it is hard to give it a fair chance again. That being said, I personally prefer other languages today, with static typing and a carefully designed set of language features. But PHP today also is not PHP of the early days anymore.

Collapse
 
wesnetmo profile image
Wes

Most of PHP bad rep comes from wordpress and beginner programmers, I think. Wordpress might work, but it's literally PHP4 old. It still contains shims for PHP4, and overall it's behind at least 10 years.

I complain about PHP a lot, but I don't hate it. In fact I'd say the opposite; I find it very hackable, it is fast, it's a free open field unlike other languages that instead drag you in their quirks with no way out. Many times I've considered switching to another language, but there was no clear winner over PHP.

Collapse
 
tnsaturday profile image
TNSaturday

I want to point out, that many of the hating people got to know PHP sometime in the mid 2000-s, when it slow, poorly designed procedural language with no real company or driving force behind it. It didn't have any coding standards nor real OOP support. It lacked a lot of features that every decent programming languages have. It was vulnerable to SQL injections and XSS attacks. Tutorials supported bad practices and had no consistence at all.

Now PHP's a completely different language. It's got great object oriented support, allowing you to use classes, traits and interfaces, static methods and many more. There are a lot of design patterns commonly used by many MVC frameworks making web development a breeze. When you use modern mainstream framework like Laravel, it feels almost like RoR and it's surely feels better than Django to me.

ORM, ActiveRecord, Composer package manager, lots of great Symfony bundles - all these makes writing performant PHP solution with ease. PHP-FIG delivers coding standards that make our code look consistent. The performance of PHP 7 almost equals Java's one in single threaded cases making it unbeaten among interpreted languages.

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