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?

Latest comments (37)

Collapse
 
mtsafe profile image
Albir Tarsha

I would like to contrast your opinion that you choose the programming language that achieves the goal of your project with that of the Elm programming language. A big part of the philosophy of Elm is to bring joy to the programmer. If you look at the Elm home page the tag-line says, "A delightful language for reliable web applications." Programming languages don't have to be unpleasant, but sometimes ... it is what it is.

Collapse
 
yonasgg profile image
Yonas

The thing I hate about PHP is the $ sign to declare variables :), also naming inconsistency is another reason.

Collapse
 
abbddos profile image
Abdul Rahman Sabbagh

Well, one of the reasons that I do not prefer to use php or even touch it these days is that it allows you to organize your project the way you want. In other words, there is no organizational pattern to it like ASP MVC or Django or Flask.

This kind of freedome that php provides makes it easier for beginners to start learning and make projects as they like, but later as projects get bigger, and more developers contribute to them, it gets harder to understand what is going on.

Now there are frameworks that somewhat provide MVC pattern to php. Rasmus Lerdorf, the man who created php, described them in one of his workshops as "they all suck".

I actually used php for a while, but later as I learned how to use the MVC pattern on ASP and in python, I made the switch and never looked back.

Collapse
 
raquelohashi profile image
Raquel Ohashi

I love php! It always worked well for me!! ❤️

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.

Collapse
 
omarajmi profile image
Omar Ajmi

I fucking hate that i have to type $ every time write an identifier name, other then that it's fucking amazing and does it's specific job like no other

Collapse
 
cahyowhy profile image
cahyo wibowo

back in my old day people still mix php with html template hahaha,,

Collapse
 
ashishkpoudel profile image
Ashish K. Poudel • Edited

If someday you start doing frontend then never ever use REACT because it mixes javascript with same html

Collapse
 
joshualjohnson profile image
Joshua Johnson

When I asked this same question to a boss of mine, he brought up the fact that our company has made 100s of millions of dollars off of PHP. I never questioned PHP again!

Collapse
 
gragoon profile image
Adrian Vaucoret

Even if PHP have several problems (random parameters order, loosely-typed, etc), it's the best language for the web. Without any PHP framework, you can render html page and all functions and classes are web-friendly. Try to do queries to Mysql database, encode datas to Json or submit a form in a browser with any other language, you will understand that I say.

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
 
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
 
essiccf37 profile image
essic

You got two categories of PHP “haters” :

  • Those who are not pragmatic. You often recognise them by their habit of thinking of the solution before understanding the problem to solve
  • Those who are pragmatic. You often recognise them by their down to earth approach at solving problems while still thinking of the long term game

I like to think that I am part of the pragmatic group, which only is my opinion really.
Exactly like a lot of ideas that people say about programming languages, for example :

  • language is just a matter of syntax
  • all languages are just tool to solve a problem, they have no value in themselves
  • all languages have defaults so they all are the same
  • choose the right tool for the right job

As you guess, I do not agree on those points, however I have no formal proof so I often make the point about assemblers and how if we had not evolve those, we would be still required to know and handle whole new categories of issues while writing a form … but not today, at least not in depth.

If somebody wants to use PHP to write code. Fine by me. In truth as long as I don’t work on it or that I was not ask about my opinion, it is not my problem. Perfectly useful software have been done and are being made in PHP, so It works. What bother me about PHP, is its cost.

I used to code PHP, so I have experienced that the fast workflow, the stateless request/response model built on HTTP, the great community, the very well built Web Frameworks that exist.
I have not experienced first hand but I followed efforts made by Facebook and PHP7 to greatly improved the ecosystem.

I talk about ecosystem because languages are useful also because of it, talking or using about languages without including the ecosystem, is not worth the time. This lesson has been learnt, that’s why Go, Rust, Typescript ... have also a strong focus on tooling and communities to speak of some ecosystem aspect.

My PHP « hate » comes from everything you have to KNOW about it, to maintain and evolve a large code base, in short PHP scales badly.
Please avoid talking to me about design patterns and good practices. Those exists in all languages and using them in PHP does not solve my issue in the least. That’s why Facebook who has no choice than to live with PHP, invested so heavily in this (we can agree that they know good practices and design patterns rights ?), that’s why PHP 6 does not exist and PHP 7 offers nothing than Facebook already provided (for the most part).

This was true (to many people, me included) : eev.ee/blog/2012/04/09/php-a-fract... maybe less so today but I seriously doubt it.

This is why, when I finished to figure out what is the problem I have to solve by prototyping in whatever language fits my workflow or whatever method of my choosing and that I have to choose my tech Stack, PHP is never on my list. It cost too much to maintain in the long run.

In short : McDonald fast food is popular. It does the job but in the long run, it will KILL you.

Collapse
 
alejandromadari profile image
Alejandro Madariaga Angeles

Well i think PHP has improved alot.
But the first project working with it made me disliked it.
For example there was lack of consistency or standards, like strcmp and str_split, it makes it seem like the whole thing was just wrapped together with duck tape, it’s very different from languages that show just how much tought and effort was place into design them
It has come a long way, and weird naming it’s still there (for legacy reasons), but i heard that everything underneath has changed and improved a lot.
JS i always liked it, it has it’s flaws but i like it, however the lack of a proper INT or other numberical types still bugs me.

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.

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