Why so many people hate PHP?
Posted by AgitatedTip5613@reddit | learnprogramming | View on Reddit | 159 comments
I'm pretty new to web dev, only learned HTML/CSS and a little of JS. I found out that PHP got hated A LOT and i have no idea why. Now I don't know if i should learn PHP or not because in my countries many places teach and use PHP for backends.
start_select@reddit
Nodejs and c#/.net were created and matured while PHP was still trying to decide if it’s a templating language and if debugging was an important feature.
It was “easy” for people to write a 5 line PHP script and run it. So the field became completely overwhelmed by dangerous developers.
PHP is pretty alright today. There are good developers today. But the stain isn’t going away anytime soon.
It was easier to say “we aren’t doing PHP” and immediately eliminate 50% of undesirable candidates that won’t learn anything else.
kaisadilla_@reddit
The main problem is that there just isn't any reason to use PHP. Nowadays you write PHP in the same way you'd write C#, Java or Node.js; but you are still stuck with the hundreds of terrible language design choices PHP made.
Classic-Try2484@reddit
Swift is a great language. I’m surprised it hasn’t gotten more bite server side. I suspect that can be blamed on the windows tooling in part. It has a Mac only reputation but the Linux tool chain I think is good enough.
kaisadilla_@reddit
PHP sucks, plain and simple. People will tell you that it "works correctly" but... that's literally the bare minimum for a language to be a language. It's like saying a car is good because the engine turns on - good luck selling a car with that pitch.
The important thing about a programming language is not that it works (again, that's the bare minimum), it's that its design makes writing and reading code easy and ergonomic - and PHP sucks at that. Bluntly speaking, PHP manages to fuck up every single design choice ever. For example:
Should your language be case sensitive? Most languages are, some aren't - but PHP does both: variables are case-sensitive, but functions are not. Is this a deal breaker? No, but you can't deny it's the worst choice for that detail.
The ternary operator in PHP is left-associative, instead of right-associative like very other language. Take this example
$a = 2; echo ( $a == 1 ? 'one' : $a == 2 ? 'two' : $a == 3 ? 'three' : 'other');
This would print "two" in every single language, except in PHP. In PHP, this prints "three". Every other language understands this as "if $a == 1 is true, then 'one', else the nested ternary operation". PHP understands this as "if ($a == 1 ? 'one' : $a == 2 ? 'two' : $a == 3)" is truthy, then 'three', else 'other'). Again, this is not a deal breaker, this is just fucking up another design decision.
something
, you use[]
to access elements (e.g.something[3]
), and you add to it using apush()
method (e.g.something.push("str")
). In PHP, for some reason, appending an element to an array looks like this:something[] = "str"
, which is just absurd. What is this syntax supposed to mean? We are accessing an element not associated to any key, and assigning a value to this absence of a key, and this magically creates a new key sequentially and associates "str" with it? Again, this is not a deal breaker, but this is once again a stupid choice for this design decision.I could go on and on and on, but it's always like this. PHP can do anything, just like any other language, but for some reason EVERY. SINGLE. THING. is done in a stupid, awkward way that not only doesn't make sense, but also is different from the rest for no reason. Each decision is not a big deal in isolation, but a language is the sum of hundreds of design decisions and this makes PHP the sum of hundreds of stupid, unjustifiable brainfucks. Thus, a PHP program plainly looks stupid for any programmer that has experience dealing with multiple languages, and doesn't want to pretend to be interesting by saying "duh there's not bad languages just bad programmers, and thus I'm a good programmer because I don't complain".
500ErrorPDX@reddit
I feel silly for hating on a language because it's just a tool to get the job done, and an experienced developer can work productively in any language given time to learn it, but man, PHP syntax looks so ugly.
I've got a PHP back end on my current work project. $ before variable names and -> operator for member access just look really ugly to me.
Awesome community and ecosystem, outstanding support for every problem I have encountered, tutorials for everything, but the syntax just feels gross
ConfidentCollege5653@reddit
Indeed it's just a tool, but some tools are better than others.
kaisadilla_@reddit
100%. The analogy I like to do is that all food is food, but you cannot take a slice of dry bread and an elaborate wedding cake and claim that they are both the same and only a moron would say one is 'better'.
deaddyfreddy@reddit
then why there are some many major languages that do the job bad?
Classic-Try2484@reddit
It’s a matter of time. At one time php was easily the best tool for the job. It’s older than server side js for example. Newer languages learned from the mistakes. But also pho made more sense at the time as c was far more relevant. Lots of devs from c community were moving to the new field of web dev.
deaddyfreddy@reddit
well, you probably know, there are languages besides PHP and C
Classic-Try2484@reddit
And what, please tell, was better than php in 1998 for web dev?
deaddyfreddy@reddit
Ask Paul Graham
Classic-Try2484@reddit
He would say lisp and I would say that’s not wrong but most devs knew c not lisp in 1998. Universities were dropping Ada for Java left and right. If you want a replacement for c you want something that leverages what you know. You don’t want to retool the staff in what feels like an experimental paradigm
I won’t argue the whole push to oop was a mistake or not. But historically php made sense in its heyday.
deaddyfreddy@reddit
it was 1995 initially, and those days a lot of devs knew lisp, and no, PHP isn't C, and no, lisp wasn't the experimental paradigm, it's a decade older than C, actually :]
Classic-Try2484@reddit
I didn’t say it was experimental—I said it felt experimental. Functional programming might have been better but c/c++ had all the traction. Lisp is more than a decade older than c but when they ripped the lisp machines out of the mit lab it lost its best chance to go mainstream. It might have been interesting if php had a functional bend. I’m not saying php was c but when I used php I found I didn’t have to lookup string functions — I already knew them. They were the same as the c functions I already knew.
Percentage wise the number of lisp programmers were dwarfed by the number of c programmers
I think it’s a shame too. We don’t have to argue. Heck JavaScript started as a scheme. But scheme wasn’t hot then.
If you want to continue to argue lisp was more common than c in 1995 I don’t what to say
deaddyfreddy@reddit
I don't, but in 1995 lisp was not a marginalized language yet (like in the 2000-2010s), especially since the education system is quite inert, so we could expect the bigger percentage of people knowing lisp (MIT 6.001 btw) than a decade or two later.
Classic-Try2484@reddit
The only limitation is the lack of mutability — I understand the benefits but it’s also a headache sometimes— I have more experience with mutable Langs. I like pure functions and avoid side effects but I also don’t want to use a language that says I’m not in control and cannot do these things
deaddyfreddy@reddit
sorry, which language we are discussing right nosw? As I said, I'm not a fan of Haskell
Classic-Try2484@reddit
I dunno. Maybe clojure. You’ve only said fp and immutability is a main tenet. Otherwise lots of languages support map, filter, reduce, including php.
deaddyfreddy@reddit
Mutability in Clojure is pretty easy, you just have to explicitly say that "I really want this thing mutable".
Classic-Try2484@reddit
Sure I can agree. I knew franze lisp and scheme. But knowing vs using. Lisp like Haskell has always had a smaller crowd of zealots. Most didn’t like the langs. Whether that’s too many parens or a harder mental model. I never once considered using lisp and still wouldn’t. I do use ideas I learned from lisp in whatever language I have used since. I never thought lisps was the answer but I did always value ideas lisp forced me to learn. But most of those ideas I can use without the limitations of lisp/haskell. Tbh I thought c was a terrible lang. It’s a decent assembly. But my point was always c was the mainstream lang. It made sense for php to use that model. Had php looked like lisp/ada I don’t think it would have taken off. But u can win the argument: php should have been based off Haskell.
Why didn’t a functional version appear?
deaddyfreddy@reddit
There are various reasons not to like lisps, but I suppose in most cases they are quite subjective.
A well-written Clojure code sometimes has even less parens than the code with the same functionality written in Java or JS.
I don't know, for me the map/filter/reduce way fits the real world pretty well: "process every element of a sequence the same way, select only the ones you need, fold them to get the resulting value". I like the cider analogy (pun intended): take a box of apples, remove the bad ones, squeeze and ferment. There are no classes, pointers, multiple syntax constructions to actually do the same thing (yes, Python, I'm looking at you), etc.
What limitations? I've been writing almost exclusively in Lisp-like languages since 2013 (as a day job), and I can't imagine switching to anything else. Because it allows you to fight a problem instead of fighting the language.
I think it still is, despite new standards, etc.
I prefer assembly, it's much more straightforward and simple.
What made sense was that Rasmus Lerdorf (kind of) knew C, and "had absolutely no idea how to write a programming language".
As a person who dislikes Haskell, I disagree. It's too complex for the average person.
Because PHP just happened to be.
ojigs@reddit
Yeah, the $ prefix was my deal breaker. Somehow I found it hard seeing it littered all over the code. It's for the same reason I don't like jQuery.
read_at_own_risk@reddit
The $ prefix for variables have grown on me, and I don't mind ->, but what I still hate after 10 years of PHP is . for string concatenation.
ShlimDiggity@reddit
I just wish double clicking on the variable name would also highlight the damn $ (for copy/paste purposes)
read_at_own_risk@reddit
VSCode? https://www.igorkromin.net/index.php/2018/04/12/make-visual-studio-code-to-correctly-select-php-variables-on-double-click/
SanguinarianPhoenix@reddit
(newbie here) What is the name for "quality of life improvements" that come in very helpful when learning VScode? Such as learning "ctrl + ~" to switch between the command line and source code window?
read_at_own_risk@reddit
Check out the Help menu in VSCode
SanguinarianPhoenix@reddit
will do, thank you!
read_at_own_risk@reddit
No idea, but don't be a cargo-culter. If they do the same thing, use what's easiest for you.
SanguinarianPhoenix@reddit
Cargo cult programming is a style of computer programming characterized by the ritual inclusion of code or program structures that serve no real purpose.
Does that mean I shouldn't include this at the bottom of my college projects?
I feel like I should do it every time since it may be important in the future.
Classic-Try2484@reddit
Maybe you should start writing test code that uses the feature
Classic-Try2484@reddit
If you can find it in the menu the keyboard shortcut is usually listed next to it.
ShlimDiggity@reddit
Yep! Wow, thanks for this.
Nomsfud@reddit
I like that it doesn't. It means I can replace the name quickly when I need to show my boss and my variable is initially named $myBossSucks
Classic-Try2484@reddit
The $ was an easy hook for string interpolation
pharmacy_666@reddit
i don't really see how it's any uglier than c or java or anything else like that
deaddyfreddy@reddit
well, it's still a bit uglier
pharmacy_666@reddit
how
femio@reddit
Associative arrays
pharmacy_666@reddit
ok, that's not syntax
femio@reddit
I am referring to the syntax they use.
pharmacy_666@reddit
this is ugly?
again, how's that any different from the standard languages that have this syntax?
Arthesia@reddit
Conversely I love it coming from Java/C type languages.
femio@reddit
It's the associative arrays for me, I just can't stand them (even though I work with Laravel)
WingZeroCoder@reddit
While most of my preferences against PHP could be considered pedantic, the fact that PHP combines its numeric list type with its dictionary type in the form of associative arrays is, IMO, a genuinely bad design choice that’s seemingly forever baked into the language.
It has caused, and continues to cause, many bugs and encourages many poor choices all the way down the stack.
For as much as I love Laravel, this is an area even Laravel offers little to help offset (Model Collections notwithstanding).
EdwardElric69@reddit
Can't you access shit with class notation
buzzon@reddit
Still better than Perl
underwatr_cheestrain@reddit
PHP has been fantastic for the past few years.
Anyone complaining otherwise is either uneducated in the topic or just a grifter of fool
10010000_426164426f7@reddit
Language maybe, but runtime and language is still a mess.
The JIT never really took off, and the lead dev left to LLVM after 8.0.
PHP, when compared next to all other languages, is alright.
PHP 8 is way better then 5 and 7, but unless you are hacking on WordPress or another CMS or a legacy project, I don't see a reason to use it.
Go, JavaScript, Python, C# and Java are just better.
Python, JavaScript, Java and Rust have extremely vibrant language ecosystems. PHP is just sorta stuck without much life in comparison.
JS gets v8, python just got some JIT in 3.13, Java gets GraalVM upstreamed, Rust has the powerhouse of LLVM behind it. And if you didn't want to use those, there are other options for all of them.
PHP has, maybe 2 implementations? The JIT was iffy, and language features are only now starting to really roll out.
Ecosystem wise, Laravel and Symfony still beat out most of the competition (almost all), but that doesn't really make up for the stagnation.
Necessary_Reality_50@reddit
PHP is an outdated and ugly hack of a language.
vegan_antitheist@reddit
I invested a lot in php, and now I have a lot of old code that is a complete mess. Some is my own, and it's bad. Some is not by me, and it's even worse. It's amazing how good modern php is when you know the history. But I still see no reason to use it. There are so many alternatives. Most of the knowledge from back then was just about how messy and bad it was. You had to learn how to prevent all kinds of crazy security problems. And all that weirdness. The docs on arrays still say: "An array in PHP is actually an ordered map." Then why the fuck is it called array instead of map? Then I learned Java where it was all about design patterns and abstraction. Some of that is now outdated, but it's still useful. Not that Java doesn't have stupid misnomers. It's a language without pointers that has a NullPointerException.
JbREACT@reddit
Idk honestly, Laravel is pretty great
ThyringerBratwurst@reddit
Even though PHP has developed "for the better", I personally don't like the syntax at all: method calls with ->, namespaces with \ instead of correcting old design errors and changing the context operator to use dots for methods and namespaces...
Then there are no real import options; and PHP is still lagging behind when it comes to concurrency.
I wouldn't recommend PHP except for medium-sized websites.
stefannsasori@reddit
"there are no real import options"
What do you mean? Give an example and I'll show you how we do that in PHP
ThyringerBratwurst@reddit
PHP still has no module system, unlike JavaScript, for example. This is all regulated by the tooling, which makes it very ugly. Classes are searched for automatically (one class per file) to provide a certain level of convenience, which in turn makes namespaces useless. It is generally quite a hassle and I have no desire to develop a project with it.
Draegan88@reddit
I’m currently working with it on some legacy php 7. What I hate about it is that it’s single threaded and has no async like js. Honestly it’s just like a crappier JavaScript and it looks ugly. I dunno if it’s like this in later php but what I’m working with objects are defined as key value arrays… it looks like trash. The $$$$ makes it kind of annoying too.
leetnewb2@reddit
Regarding async:
Reactphp has been around a long time - first releases were around 2012.
Classic-Try2484@reddit
That’s not a long time.
leetnewb2@reddit
Depends on your perspective, but it was introduced around the same time as NodeJS - so in the context of using async on scripting language backend, the option has been there in php for about as long.
Classic-Try2484@reddit
Ok but pho was already 15 years in.
leetnewb2@reddit
I'm honestly not sure what you are trying to express or argue.
Classic-Try2484@reddit
I was just saying 2012 is not an old age for p lang. I’m not trying to argue. PHP made a lot of sense when it appeared. A language that showed up in 2012 could build on pho’s lessons. It should be better in certain aspects. Prior to 2012 multi threading was rare. Why would php support it when it was dev 15 years earlier.
leetnewb2@reddit
Oh, I see what you mean. I think php's evolution is sort of interesting - it was so widely deployed so "early" in its lifecycle, I guess it was never able to have sudden massive breaking change like from python2->3 as best practices emerged/evolved. I have kind of a hot/cold feeling towards scripting languages on the backend.
FWIW, I'm fascinated by nim's mummy http server: https://github.com/guzba/mummy?tab=readme-ov-file#why-use-mummy-instead-of-async
Draegan88@reddit
Thanks if I ever work with php again I’ll check it out. As for now this code base is 20 years old so nothing I can do about it now.
AmSoMad@reddit
I don't think anyone's mentioned this yet:
Because of PHP's history, starting out as a scripting language, adding features until it grew until a full language, maintaining backwards compatibility, and advancing to a modern language - it's left with a lot of really messy syntax, and to a greater extent, an extremely high number of proper nouns. Lots of distinct words for doing distinct things, with very little conformity across them, even for things that are similar.
For example:
strtolower() and ucwords() are both string functions, but one starts with "str" and the word starts with "uc". array_push() and count() are both array functions, but one starts with "array_" and the other doesn't. date_create() and strtotime(), inconsistent time function naming. Certain functions have their arguments ordered differently, such as strpos($where_to_search, $what_to_search) and array_search($what_to_search, $where_to_search). Some functions using different casing formats, etc.
So even though it's become a powerful language, it's one of the messiest, with a lot of discreet names you need to remember. A lot of people hate JS - and anyone who hates JS should take a look at PHP.
In addition to that, JS emerged as the dominant language for the web. PHP was huge in 2003, around when WordPress first came out. But by 2009, when Node started letting us write server-side JS, JS rapidly rose to prominence. Now we have Chrome's V8 engine, Apple's JavaScriptCore, Node, Bun, Deno.
DINNERTIME_CUNT@reddit
ucwords() could’ve been named better, but it isn’t the reverse of strtolower(), that would be strtoupper(). ucwords() just capitalises the first character of each word.
AmSoMad@reddit
I'm not comparing opposites, just how same category if functions have different names.
For string functions alone you have:
in JS they're all:
And PHP shares this characteristic across every category of functions/"methods". It's basically the result of taking something that was never meant to be a ful language, and turning it into a full language. Everything is retrofitted, and it's resulted in a very messy, inconsistent language. Which, for me, increases the cognitive load when trying to program. I still use Laravel from time to time, but I prefer the JS/TS frameworks.
Classic-Try2484@reddit
The functions in php align with c. See string.h. Web devs today don’t learn c so this makes no sense but in 1998 we were building dynamic pages with c so this made an easy switch to php
AmSoMad@reddit
You'd need to give me some discreet examples. All of C's string operations are consistently-written, just like JS's, and unlike PHP's. The PHP versions are functions, like C, rather than methods, like JS, but I was looking at language-consistency, not functional-similarity.
Using functions rather than methods alone, is going to make PHP "technically closer to C", but C doesn't have a bunch of categories of functions/methods, that use random names, random syntax, and random casing. Which is what I'm trying to emphasize.
I can write C. PHP requires a dictionary. And, while I hear your point, webdevs are pretty much forced to to learn the foundations and fundamentals now (often w/ C), or they won't get anywhere.
I suspect no dev who came to fruition in the last decade is going to say PHP is more similar to C over JS/TS, but maybe I'm wrong. It sounds like a natural pivot-point way-back-when (except for the part that it was server-only), but tech moves exponentially fast. I'd be reaching C#, Go, even Rust, long before I reached for PHP (and I say this, as someone who builds 1 out of every 7 apps using Laravel/PHP).
Classic-Try2484@reddit
Maybe I am comparing an early version of php. I think every thing in string.h is there. The rest was added later. I’m saying it started sensible then feature crept
DINNERTIME_CUNT@reddit
Yeah it could definitely have done with some better planning.
SanguinarianPhoenix@reddit
https://youtu.be/KYp2xWcRWYQ?t=158
Tech with Tim mentions this toward the end of this video.
deaddyfreddy@reddit
why don't have both?
Natural_Ad_5879@reddit
Because its not used by big corporations that often and because universities teach java and similar (because java is used in banking etc)
imagei@reddit
Personal take, don’t flame me for missing some technicality please 😅
PHP is the only language I flat out refuse to work with because it messes with my brain. Each time I worked with it for a couple of days and went back to a different language I found myself involuntarily using weird constructs, order of operations and other php-isms and then having to rework everything into clearer code. Idk, maybe I’m fragile or something but, while I have my preferences, it’s the only language that just feels wrong all around.
Classic-Try2484@reddit
Stay away from C/C++
Online_Simpleton@reddit
PHP wasn’t a programming language. It was created by one guy in 1994 as a set of website tools: handle basic authentication, very crude HTML templating, logging, and form submission (hard to do at the time; websites ran on C and Perl programs called by early servers using a protocol called CGI. It was very hard to do anything useful this way on the web). The second version was more like Twig or {{ mustache }}: handle the very basic logic of HTML templates; magically bind HTML form elements to variables (which is why PHP was also called “Forms Interpreter” at the time). As luck would have it, programmers with more skill than the original creators discovered this tool and turned it into a Turing-complete scripting language. This was the third version. It spread like wildfire and came to power most of the Internet because A) computer science majors weren’t interested in web development at the time, so the resources to build dynamic websites with “real” programming languages were limited; B) PHP has properties (e.g. when you crash a PHP program, you don’t take down the server with it) that made it ideal for shared, low-cost web hosts at the time; C) PHP worked well with Linux, MySQL, and Apache, so you’d have a free and open source stack that came together nicely; D) the competing platforms that emerged to try to “do things right” and replace PHP were even worse (ColdFusion, for instance).
Problem is, the language was never designed. It grew organically by accretion, to fill immediate needs. It thus has a number of inconsistencies in the naming/signature of functions. Some of the modules built into the language are also ancient and frustrating to use (SOAP clients and servers). So, people complained about how awful the language was, culminating in a blog post called “PHP: A Fractal of Bad Design,” from a long time ago. It became a rite of passage for junior developers to dump on PHP and also dismiss its developers as fake/“not real” programmers somehow. Also: the low barrier to entry and flexibility of the language let you write bad, procedural, insecure code that mixed HTML and inline JavaScript and SQL into one giant ball of mud; many of the tutorials available for PHP in the 2000s explicitly taught developers to do things the wrong way (leading to SQL injection among other vulnerabilities).
However, since about PHP 5.3 (which was a long time ago), the maintainers modernized their development practices somewhat (formal language specification; regular release schedule). They have since been regularly adding features that improve the language (namespaces; gradual typing; enums; immutability; Java-like attributes), and removing dangerous or unnecessary ones. The scripting engine was also rewritten to be much faster and memory efficient; later, just-in-time compilation was added to rewrite at least a portion of PHP programs to machine-native code on the fly. Also, the tooling is much better (PHPStan + Psalm at a compile step that checks the type safety of your code, and even support for additional language features like generics; new runtimes like RoadRunner greatly improve performance versus the old way of executing PHP as an Apache module).
In summary: 1) PHP got a lot of criticism. A lot of it was fair. A lot of it ignored the crazy Dot Com Boom context in which it emerged, and the fact that it had to be accessible to beginners or non-programmers to gain mindshare 2) PHP had major problems and limitations, many of which were addressed; many people, however, have not updated their perception of the language because they haven’t used it in years 3) PHP retains frustrations and limitations (like all programming languages), but is still a good choice for web projects. 4) Language choice is a little overrated anyhow. If your product fails, it’s probably not because you chose PHP versus Node JS (or vice versa) for your backend 5) Don’t let blog posts or Redditors dictate the language you use. If you enjoy PHP, use it unashamedly, and without desperately seeking validation for your preference (which a lot of PHP devs do). If you don’t like it, there are plenty of good alternatives now
Classic-Try2484@reddit
PHP started out as a personal scripting language modeled after c. But java was coming of age. The lower case function I noticed were all c function with arguments in the same order. C was the alternative to php and php could be nested in html. PHP had better string interpolation. This is why the vars start with $. PHP was better for web dev than c and nodejs wasn’t a thing yet. JSP would be the main rival for 5 years or so.
When php started to get popular it grew and got new versions — version 6 was the first to come with a web server u could run local. The changes were made by folk who started adding functionality from Java where camel case reigns supreme. Functions lost uniformity and argument order might come from either. But php kept growing. This is called feature creep. JavaScript was front side only so php had no real competition on the back end. Facebook used it. JSP was complicated and expensive. The blue chips used jsp. Devs complained about using JavaScript and php and someone got ja working outside the front end and claimed you could use it serverside. It was awful Then people began doing it anyway because some of them didn’t know php well enough and that began to write libraries that could do interesting things. Eventually node js evolved and php/jsp had a competitor. PHP was never good. But it was once the only sensible choice. And it was pretty easy if u came from c. And now there’s a lot of legacy. So it’s fading to new tools that are built from insights learned over 30 years of web dev. PHP had none. It’s the cobol of the web
commandblock@reddit
PHP is fine and it’s soooo much easier to make websites with PHP. But JavaScript is very popular right now
leetnewb2@reddit
One thing I haven't seen mentioned yet - php does not have a major corporate sponsor. Go, JS, TS, Java, .NET, Python, Kotlin, Rust, C++, Swift, Objective C are each sponsored by one or more more of the following companies: Microsoft, Google, Oracle, Meta, Apple, and Nvidia. You can understand the logic governing these companies supporting certain languages.
When you have that much tech resources and hiring power at play over a long period of time, it will shape the market, ecosystems, and opinions. Meanwhile, php's widespread adoption predated how modern hosting and technology stacks work. When you can accomplish backend/API stuff in virtually all of those other, well-supported languages today, it gets harder to justify starting a new project in php. Even if you find php to be your favorite, is it worth devoting time and effort into learning if the jobs aren't there and the future is uncertain?
Personally, as someone that isn't ever looking to work in programming, I like the idea of a language that is more community driven.
Electronic_Part_5931@reddit
With latest PhP versions (8+), aside from the syntax, I can assure you that you would see no difference with Java (a part from being compiled) or Python for example.
PhP has now strong typed properties, clearer syntax, weird yet useful annotation system, and even very cool syntax if you are experimented enough to use the latest good practices of coding.
Anyone hating PhP is because they are used to. Projects written in php 4/5 were absolutely UGGLY, thus PhP almost stopped existing at that point (the project was almost off, PhP6 was about to end the story, which actually never released) but they managed to bring it up again with PhP7, and now with PHP 8 it became a true programmation language with wonderful OOP concepts.
If all those marketers trying to sell you formations on the latest python virtual env or Next.js bullshit were really honest, no one would argue PHP is, and will remain, one of the absolute best web programmation language for a good amount of time.
DataPastor@reddit
Because only few know, that PHP was originally only an exchange DSL between C++ programmers and graphics designers, and originally never intended to be a standalone programming language. However, its author made it “too good” for the purpose, and people started to use it as a standalone languge. But because as a standalone language it obviously had some flaws, also it had a low entry barrier (meaning: it was super good for the original purpose), many script kiddies like me jumped on the topic and lots of spaghetti codes were created. This was irritating for folks who had a proper education (meaning: trained on Algol60, Cobol and C) and they started to blame PHP. And haters gonna hate. Software is a pop culture.
Revolutionary-Yak371@reddit
Because of depricated commands in every new version of that language.
Some commands are depricated, while some is totally with new syntax and parameters.
For instance "mysqli" vs old "mysql".
You must always update your PHP to the latest version, while updating and testing your code as well.
timwaaagh@reddit
It's good at what it does but it has major issues if your codebase expands. Debugging remains an issue. Now that's not technically a problem of the language but it is your problem if you want to use it. Other than this, dollars all over the place isn't amazing either.
hipnaba@reddit
You're reading the wrong material. No reasonable developer "hates" on languages. It's just young newbies making noise. Php is getting better and better.
There are people here "hating" on pieces of syntax, such as the concatenation operator. Does that sound reasonable to you?
akoOfIxtall@reddit
I don't hate it, just looks archaic, funny looking syntax, and the good tutorial is from ages ago using XAMP, I don't feel like reading documentation for PHP...
Fall_To_Light@reddit
Weird syntax, that's all. I can't really give up on it though because of Laravel.
dave8271@reddit
A couple of legitimate reasons (primarily, the inconsistency of the global function namespace covered in the top comment) mixed with a lot of ignorance of how the language, the engine and the ecosystem have changed over the last decade. Checkout Symfony https://symfony.com if you want to see what good PHP looks like.
Maximum-Counter7687@reddit
its fire and the simplest way to solo fullstack for a beginner nowadays.
barni9789@reddit
I don't hate PHP I'm just unsure why would you use it. Ofc if you have WordPress/Drupal then I can get it, but why would you use symphony or Laravel or vanilla php? There aren't any worse candidates In the mainstream
I don't know pho can do that the followings can't? as I see:
JS: Better ecosystem, async, faster, easier C#(.net) Better ecosystem, async, multi threaded, much faster, better syntax Java: Better ecosystem, multi threaded, much faster, better syntax (can async if needed) Python: Better ecosystem, easier
Wonderful_Device312@reddit
I hate PHP but I recently had to maintain some old PHP code and I've got to admit that it's really good at what it does. I think it's problem is that it was designed from the ground up to be the best at a very specific thing and then once it hit the real world they had to start supporting a lot of other things and those things are very tacked on and poorly implemented.
Other languages meanwhile are much better at general purpose stuff and keep trying to implement web frameworks that make them as good at web stuff as PHP is.
deaddyfreddy@reddit
shows a bad languages design? sure!
well, not really, it's just happened
Wonderful_Device312@reddit
Poor design is still a design. Their design just didn't consider anything long term or beyond the specific problem they were trying to solve at the time.
tappthis@reddit
because it's horrible compared to other options.... the unique sintax is a disadvantage, the ecosystem is notoriously prone to being exploitable, instlaling packages or making the app run isn't as straight forward as other languages...
Vntoflex@reddit
Can you mention better options, I’m new to
tappthis@reddit
if you want a dynamic scripting language, go for either python with django or node.js with express.
if you want a compiled one go for .Net with C#
All 3 of them have jobs everywhere with a vastly superior experience
Even java with spring, golang, and ruby on rails have better experience
Vntoflex@reddit
Thank you so much
tappthis@reddit
a php dev disliked me lol, In my experience they try to stop any changes because they arent a commnity known for learning outside their govmnt/contractor bubble. They barely have any reasons for using it other than "this is what I know and what is already being used here"
Just take a look of unicorn startups, the vast majority don't want to use PHP (not really even meta, they even tried to make "Hack" a thing)
They ALL use Python, Node.js, Java, .Net and/or Go . Some might still use Ruby.
Other tech is fine for smaller things, or for smaller shops with teams that know each other personally...
Vntoflex@reddit
Yea got it thanks :)
tappthis@reddit
but JS really has no equal: everything for web ends up being JS or compiled into it. It's also very important on backend too.
JS can be used in an entirely functional way, unlike python, java, ruby or c#, which are mostly OOP, or functional methods.
Vntoflex@reddit
For web dev i know that for front end I need HTML, css and jss and some frame work like react. Also found react interesting because I can algo get into react native to create apps.
My question is for back end webs the most popular are js and node.js right ?
barni9789@reddit
most popular might be hard to define. It's more likely a question about most popular in what area. Node js is very popular nevertheless and it's 100% worth learning esp if you are a frontend dev.
node has some unique things and unique challenges. one could be the lack of standard libraries and standard tools. with nodejs backend you usually will want to use a framework. most popular is express and you will have to bring your own tooling in the system or set it up yourself. No standard ORM no standard authentication etc...
I myself would try to learn at least later an enterprise OOP language/tool too like, C# .NET
tappthis@reddit
if you're still exploring what you like and dislike, and have no interest in OSes or embedded, JS is THE way to go.
Vntoflex@reddit
Ok tysm
tappthis@reddit
stay in a major language/framework until you get all of the basics really solid, and you'll get a job in no time
Vntoflex@reddit
Alll rights thanks
spellenspelen@reddit
Don't listen to him. PHP is just fine for most projects. It gets slow if your code base grows to much but it's no where near as bad as people make it out to be. It USED to be bad. But than newer versions came out.
Extension_Anybody150@reddit
Maybe it didn't work for them but PHP is still very relevant and useful, it has improved a lot over the years, and it's still widely used.
tnnrk@reddit
Learn whatever has a job market near you. Don’t listen to these idiot nerds needlessly bashing a programming language they probably never used.
deaddyfreddy@reddit
why learn programming at all then?
tnnrk@reddit
How did you land there from my comment? Be conscious of what the job market is like near you and what programming languages are more in demand near you…
deaddyfreddy@reddit
well, in most places there are lot more non-programming jobs, I suppose
deaddyfreddy@reddit
if you all you want is to get a job in your country - learn PHP. Otherwise - don't, it sucks shit.
mzalewski@reddit
It’s a social thing. People hate on PHP mainly for the same reason they are hating on Jira and Teams. What they really mean to say is “look, I am part of the same group”.
That’s not to say that PHP bad reputation is completely unjustified. There are strictly technical reasons to prefer something else. But there are also technical and business requirements that make PHP the best choice in specific case.
imagei@reddit
Other than working with a legacy codebase, what can be a technical justification for picking php over literally anything else in 2024? I’m asking about a technical justification, because team knowledge may play a role of course as well.
leetnewb2@reddit
It is a carefully evolving language that is easy to learn, highly productive, has a strong ecosystem, and won't rip your face off like python2->3 or Scala2->3. The field is obviously crowded and there are plenty of good enough languages depending on the domain. But for something that php is suited for, particularly when paired with a framework like laravel or symfony, there is an argument to be made.
deaddyfreddy@reddit
Clojure has been there for 17 years and like 99% of the code written for 1.0 is still working today
Hopeful-Sir-2018@reddit
Many moons and seasons ago - before PHP 7, there was PHP5 (6 doesn't exist and no I'm not joking). Everything before 5 is... well... dog shit.
There's two main reasons it's dog shit. One is it wasn't structured very well and tended to create shit code. Two is... it was the "only" language anyone could pick up and fuck with for free. The main alternative was Coldfusion at the time, something a former boss of mine still gets his dick hard over for some reason. Because of this - every Tom, Dick, and Harry made websites that were... well... shit. They didn't know what they were doing and went with it anyways. So you tended to stumble upon shitty CVS repo's that were difficult to decipher or figure out - also because IDE's weren't very great in their support for PHP. Debugging was frustrating as well.
Fast forward some time - PHP7 is released and things change. But very few people went back to check in on it. The reputation stank and few cared to give it another go. To be fair - unless they have a reason to give it another go, their time might be better spend elsewhere (e.g. learning Rust, C#, Swift, Kotlin, etc)
Coincidentally near'ish around this time MySQL (the free version being MariaDb now) was losing favor and PostreSQL was gaining in popularity. Postgre's problems have been resolved that MySQL gapped them a decade prior, making the playing field equal and MySQL still having a bug that's old enough to drive (or is it vote? I don't remember) if it were a child.
In this case, regardless, PHP is not a bad language to learn and understand. Even if it's shit on - it's good to know it. All sorts of websites use it and you may want to hack on it later and being even mildly competent in it will be useful.
Another reason people tend not to like PHP is it's interpreted which can make debugging slightly spicier but that problem has since, mostly, been solved.
deaddyfreddy@reddit
definitely
not true, it's 1995, not 1965, remember? There were alternative ways to generate HTML from some programming language (do you remember Viaweb, for example?)
probably because PHP had bad syntax, both hard for parsers and people :)
again it's not the 2000s anymore, most websites don't
Economy_Vacation_761@reddit
Mainly because the alternatives are better. Java, Python, and C# all have great frameworks that get the job done, are strongly typed and the debugging and deployment are great.
PHP is the default programming language of most web projects, including things like WordPress, Drupal, etc.
So it's almost a requirement to be familiarized with PHP in order to maintain existing web projects. Most developers know some PHP and they also know that it has many flaws. Also, you know that popular things get a lot of hate.
In my personal opinion, frameworks like Laravel and Codeigniter are a pain to work with.
deaddyfreddy@reddit
sorry, can I take your time machine to go back to 2007?
NoHistorian4672@reddit
“There are only two kinds of languages: the ones people complain about and the ones nobody uses.”
deaddyfreddy@reddit
said a guy who was pretty good at selling languages, not in their design, though
teraflop@reddit
Here is an article with a long list of bad or confusing design decisions that PHP has made: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
The article is 12 years old and some of the problems have been fixed, but not all of them, and the bad reputation remains.
ChezMere@reddit
Worth mentioning that PHP's peak in usage was years before this article came put, when NONE of these baffling design choices had been fixed.
spellenspelen@reddit
"some" he says. Dude it's like a whole new language now it doesn't even compare. What makes you think an blog from 12 YEARS ago is a indication of anything.
start_select@reddit
I don’t know if that’s a valid comparison.
I’m an iOS dev and I still use an iPhone 6 for development testing. The only reason it’s not my main phone is the battery died. It still does everything my other iPhones do. The only major change has been screen size and cameras in almost every iPhone model.
Bacon_Techie@reddit
That only makes the fact that not everything in that list is fixed even worse
GeorgeDir@reddit
This article is very interesting.
I want to add that many people hate PHP because it used to be the beginners entry point into web development. The same reason people now like to shit on JavaScript
dakrisis@reddit
They have always shat on JavaScript. Other languages offer ways to transpile/compile your code to JavaScript, saving respectable programmers from ever having to touch it.
maleldil@reddit
Another big issue was the lack of separation between presentation layer and backend code (in much the same way as old Java JSP/Servlet code, which is also much hated by Java devs nowadays). It's just so difficult to figure out what's going on where, and the fact that PHP is a dynamic language makes it even worse than with Java. I'm sure more modern frameworks like Laravel have solutions to these old issues, but for a lot of us the bad taste of bad, spaghetti code in PHP has never left our mouths.
illathon@reddit
You will find people who hate everything. Some things have good reasons some don't.
PHP for the most part is a simple language to use. It is perfectly tailored for web and makes starting a web server insanely easy.
waffleassembly@reddit
PHP stands for Hypertext Preprocessor. Which makes total sense to your evil twin with a goatee from Bizarro World
JohnJSal@reddit
Originally it was Personal Home Page.
homomorphisme@reddit
Aside from it being an admixture of different design decisions over the years, I think the primary reason people don't like PHP is that 1) it is highly ubiquitous, and 2) there is a metric fuckton of code written poorly in PHP. That means that eventually one might be forced to use it in bad codebases.
DINNERTIME_CUNT@reddit
Because sheep go where they’re told.
Mikiz@reddit
I don't know honestly. I feel like all the bad things people say about PHP could also be applied to NodeJS, and the people saying the bad things about PHP love NodeJS, so it doesn't make sense.
Temporary_Practice_2@reddit
You shouldn't fall into the bandwagon as a beginner. PHP is a beautiful and powerful web programming language. And there is no substitute! ...Most people who bash it aren't web programmers...If you love the web, you will love PHP.
armahillo@reddit
PHP is a fantastic language to start a web development journey.
If you go beyond and learn additional web and software principles, it can carry you farther than that.
josephjnk@reddit
Something to remember is that, because there are so many languages, the vast majority of developers don’t have first-hand experience with the vast majority of tools. PHP’s reputation is mostly due to people with little to no experience in the language.
I see a lot of people complaining about syntax in the comments here. Syntax complaints are a very surface-level complaint, and are usually what developers complain about when they don’t know enough to complain about anything deeper. I hear developers swear that OCaml’s syntax is the ugliest they’ve ever seen just as much as I hear OCaml developers say that they miss the syntax whenever they use a different language. Syntax only matters when it’s especially verbose or confusing; hating a language because it uses “$” a lot is an affectation. Just about anyone who programs extensively in a modern language will get used to that language’s syntax eventually.
What matters is a language’s semantics, ecosystem, and standard library. Like most older languages these were a mess in early versions of PHP. This was a valid reason for PHP to get a bad reputation, just like JavaScript did.
Modern versions of PHP clean up a lot of rough edges while still carrying baggage. Again, this is true of most languages that have been around for a long time. My understanding is that there’s work on adding some static typing to PHP, as well as Hack, which is a language based on PHP that Facebook developed. I’m not a PHP dev so I can’t attest to how good these are.
I would personally rather not use PHP for a new project; Scala and OCaml are more exciting to me, and TypeScript is what I’m good at. But I will almost certainly never be able to get a Scala or OCaml job and it’s important to be realistic about career prospects. Most importantly I’m not going to disrespect another developer’s knowledge and skills just because they use a language that doesn’t appeal to me.
Specialist-Phase-567@reddit
Because its popular to jump on hate bandwagons
WystanH@reddit
PHP is kind of a victim of its own success. It started out with the goal to be simple, originally Personal Home Page tools, something a novice programmer could use to spruce up their "Home Page."
It became very popular and more features were continuously added. Not all the new features were great. It's like a city busting outside of the original inner walls. While that's the fate of most general purpose languages, PHP kind of didn't start out with that in mind.
What's worse, for PHP, is that folks with very little programming experience made lots of cool things. And, well, lots of painful stuff that more experienced programmers occasionally have to maintain. And that, really, is an endless font of hate.
BewilderedAnus@reddit
Hating on PHP is unironically a team-building exercise. It's something most developers have in common.
tobesteve@reddit
Sounds like if new artists would be hating on Taylor Swift. Yes she's popular, yes she makes money, but but but, $!
AaronKClark@reddit
Once you know the basics of programming you should be able to jump back and forth between languages fairly easily. PHP was novel for it's time in that it was a far much easier langauge to use than perl, and it was geared to scripting and automation. Maybe people complain about python even though it is an order of magnitude better than php or perl was. Programmers will complain about the most trivial things all while making six figures in the comfort of their home in their underwear.
huuaaang@reddit
I go back to PHP 3 days and PHP was legit trash back then. And only existed because perl CGI was worse. So I'm traumatized by PHP 3-5. Since then I haven't had any need or desire to revisit it to test the claims that it is better now. I've moved on. There are far more interesting languages that I'd rather tinker with.
spellenspelen@reddit
Yeah it used to be, even tho you'l never use it again maybe you'l find the improvements still somewhat interesting: https://youtu.be/ZRV3pBuPxEQ?si=VYik5-6rE7PWSMy-
clearlight@reddit
Because it’s popular, haters gonna hate.
ToThePillory@reddit
I don't hate it, but I see no reason to use it again.
You don't have to hate a language to choose not to use it, there are so many languages out there that you can't learn all of them, so if something doesn't interest you, then you can probably just drop the idea of learning it.
If you like it, and can get a job in it, go for it, but it's not for everyone.
SeoCamo@reddit
Php is one of the easy languages to learn, one of the languages for the web.
OliB150@reddit
TIL PHP is widely hated! I’ve always quite liked it but I’ve never been a power user. The first language I ever used also had $ variables so it’s never stood out to me as particularly weird.
coolkid42069911@reddit
My main issue with php is that it lets people write bad code and doesn't really tell you how you should write code.
Conscious_Bank9484@reddit
All about the $
mxldevs@reddit
I learned PHP to build and maintain wordpress plugins and it's not a language that I particularly enjoy working with.
But I'm not sure how much of it is related to the way wordpress is designed.
fruszantej@reddit
$, fucking $
EdwardElric69@reddit
Goofy ass language $ -> /
femio@reddit
Because:
1) Dynamic scripting languages like PHP, JS always have pretentious haters
2) It gets a bad rap due to heavy use in Wordpress (an ecosystem with janky dev experience and a ton of security issues)
3) More subjectively, the syntax is a little weird and not that enjoyable to write (imo, take my opinion with a grain of salt but I'm not the only one who feels that way)
hellohennessy@reddit
It is hard, ugly and annoying. But many are forced to use it anyways.