Live data from Hacker News

A look at modern PHP

lwn.net

321–330 of 610 posts

Re: A look at modern PHP

#321

I wonder if most developers that trash on PHP for trivial issues like seen in this thread haven't been using it for many years, or had a bad experience (e.g. maintaining a legacy app). Some developers live in a kind of technical vacuum where, I guess they assume, the technical features of their programming language are what makes the difference in the value of the business they're building. In reality, the difference…

I wonder how many developers hate PHP because one is just supposed to hate PHP. I'm sure there are many with well-thought-out reasoning though, like seen in this thread. It's useful to keep an open mind about things though. I'm probably more a PHP fan, but I can't say that I'm a huge fan of its programming style. It's much more enjoyable to me to churn out applications in .NET or in Ruby, but it's hard to argue with…

I think you're missing a third group of PHP haters that's actually a majority: those who've used PHP, sometimes extensively, and built up a backlog of "this is stupid" bits in their head about it. They don't have deeply reflective reasons or a strong theoretical basis for hating it, they've just suffered with it for a good while, found some better alternative, and are now sceptical that any amount of improvement will be able to outweigh the friction they "know" will be there if they try to come back.

So the anti-PHP feeling for this group is broad but shallow. Here's what I think is interesting: JavaScript is here right now. Like PHP, it's incredibly popular, almost mandatory to know in some degreee, and using it for any length of time causes one to build up a catalog of "WTF?" and workarounds and "use this library instead" and a constant churn of "it's great if you use on top of it".

I used PHP a lot, and found it quite pleasant with Laravel, but the latent pool of distaste means I'll never go back. I work heavily with JS now, and can feel that wide puddle of "why do I have to put up with this?" spreading, even while other parts are really good.

I don't know how you overcome this, broadly. Perhaps it doesn't matter, because I think this group (and I'm part of it) blows with the wind more than most, and if the winds shift back, we'll probably come along.

Re: A look at modern PHP

#322

Earlier quoted context omitted.

I accept it mentions that in the content, I guess its the title I find misleading. You can see on this very HN thread, lots of confused replies are falsely equating those features as new developments. My simple point is that PHP has been "mature", in OOP terms anyway, for at least 10 years now, so the original author tying that milestone to PHP 7.4 seems weird and outdated to me.

> I guess its the title I find misleading. This meme of people on HN judging articles entirely on their title really needs to die. > My simple point is that PHP has been "mature", in OOP terms anyway, for at least 10 years now You keep saying that and I keep replying that nobody was ever arguing otherwise. > so the original author tying that milestone to PHP 7.4 seems weird and outdated to me. Again, they wasn't. You…

> presumably because you just read the title and the pre block and skipped over all the rest of the content

Nope, read it all as I mentioned already.

Re: A look at modern PHP

#323
This may sound hurtful but hear me out - One thing worth mentioning why someone would not want to use PHP in 2020 is that a PHP programmer is looked down upon by other programmers.

And im saying this without hate or malice. I love PHP since I was a PHP dev from 5.2 - 7.0. I built PHP libraries and WordPress plugins that have helped many people. Ive since moved to Node because PHP jobs have dried up in my country.

PHP devs arent respected which is sad because we all belong to the same programming community. And PHP has contributed a lot to the proliferation of websites. At the end of the day programming languages dont matter to businesses as long as it gets the job done at a reasonabe cost.

Re: A look at modern PHP

#324
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

I can't really understand the hate towards php in general, never was able to understand it. I started programming in PHP and then moved to c# and now mostly JS, but never really understood the motivations behind people bashing on PHP. Like, some of my friends that today mostly program in React/Nextjs praise the framework as something amazing and the SSR as something really innovative, and - honestly - it resembles PH…

as a Ruby/Rails guy, I feel the same way. Seems like Rails became the top stack to shit on to feel better about your stack these days. People are just tribal. We need to feel superior to the "other" to feel better about ourselves.

Re: A look at modern PHP

#325
post #76

Earlier quoted context omitted.

C# (optionally using the ASP.NET framework) running on the fast, efficient, cross-platform .NET Core. Or Java/Scala/Kotlin. Or Go. Or Python. Or Node + Typescript.

If my project is "big enough" to warrant something like Laravel, I would just pick Rails or Phoenix over it any day. I find both those languages much better to work in and I just feel like I'm getting things done way faster. If its smaller than that, I'dd definitly just pick go or node with express or go maybe. I work with PHP 5 days a week through work and even a few years into it, i still do not like it. Its feels…

well, that's your biggest problem. PHP 5 is a steaming pile of dung when compared to PHP 7.

Re: A look at modern PHP

#326

Earlier quoted context omitted.

Why are you using "=="? Use "===" and make explicit casts as required.

Sometimes "==" is used under the hood ( switch/case i think?) and it's hard to avoid it completely even if you always use "===" in the code

You don't need to use switches. In fact, I'd argue that if blocks are better if you're evaluating against variable data types. Alternatively, if you really, really want to use a switch statement and loose typing might cause issues, it's pretty easy to compare types before the switch statement, e.g,

    if(gettype($a) !== "...") { return false; }
    switch($a) { ... }

Re: A look at modern PHP

#327
post #272

Earlier quoted context omitted.

Can't speak for others but I've worked on many legacy PHP codebases over the years, it has never been a pleasant experience. Even when it's a PHP 7 codebase the same bad practices from PHP 5 and earlier are all present and accounted for. As are the subtle bugs stemming from an inconsistent standard library and PHPs approach to error handling. I'm sure that there's plenty of good PHP code out there, maybe I've just be…

Ya? Can't speak for others but I've worked on many legacy C++ codebases over the years, it has never been a pleasant experience. Even when it's a C++ 17 codebase the same bad practices from C++ 11 and earlier are all present and accounted for. As are the subtle bugs stemming from an inconsistent standard library and C++'s approach to verbose error handling. I'm sure that there's plenty of good C++ code out there, may…

> I can literally copy and paste what you said replacing it with any language and end up being correct.

This is the best point in this thread, IMHO.

I think it also is due to the fact that PHP is a fairly easy language for a non-coder to pick up little-by-little. One can easily start using it for doing simple things, like injecting dynamic data into a web page. From there one can learn to scale up to full web apps.

I think this lower barrier of entry makes a lot of developers feel insecure. A lot of coders think they are blessed with some sort of special ability to write code. They seem themselves as elite and they use elite tools. When some kid comes in with some PHP snippets and generates a lot of value from that they complain that their code sucks, the language sucks, the developers suck, blah blah.

In my 20 years of writing code (starting with PHP) I have learned the lesson over and over again that while writing code commercially the fact that the language has feature X or that it forces certain patterns means almost nothing. Sure, your developers might feel better about themselves but that is about it.

Re: A look at modern PHP

#328
post #112

The amount of misinformation, false claims and unsupported statements in this thread is mindblowing for the quality that I've been used to see on HN. Here are some facts: - Symfony was the backend framework with the most contributors in 2019 [1] (yes, out of any backend framework written in any language) - PHP has more active contributors than it ever had [2] - Laravel is one of the most used frameworks in the world…

Majority of the HN commenters argue irrelevant points or are trolls and have never gone deep in any technology to be an expert and comment about it. I've seen absolutely moronic comments here. You should see the comments on 'React' or 'Java'. I'm pretty sure most have never written a "hello world" equivalent in it. It's cool to hate something popular.

Re: A look at modern PHP

#329
post #164

Earlier quoted context omitted.

So I take it all the things in this article ( https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ ) are no longer relevant? For example "foo"==TRUE, "foo"==0 and TRUE !=0 are logically consistent now? Or json_encode no longer returns null for invalid input?

Why are you using "=="? Use "===" and make explicit casts as required.

And what is the equivalent of "===" for ">" and "<"?

Re: A look at modern PHP

#330
If you want to know why-the-hate watch this[1] talk — one of the best and eye-opening talks I've ever heard.

It has nothing to do with the language itself and everything to do with the user of the language.

[1] The Pervert's Guide to Computer Programming Languages https://www.youtube.com/watch?v=mZyvIHYn2zk

Post reply on HN