Live data from Hacker News

PHP in 2023

stitcher.io

191–200 of 285 posts

Re: PHP in 2023

#191

Earlier quoted context omitted.

Php's inconsistencies in regards to needle vs haystack make me weep. Javascript doesn't have anything remotely like that.

JavaScript absolutely has things like that. Very famously so. https://www.youtube.com/watch?v=et8xNAc2ic8

Notice that lots of (probably most of; maybe even all) examples in the linked talk are due to unreasonable inputs. `true + true` doesn't make sense; `{}.toString().call(new Date())` or `+[] === +![]` don't make much sense either. This is just not what developers do. Meanwhile, iterating over arrays is absolutely what developers do, on an hourly basis. Which is why I said that javascript doesn't have things like that — the papercuts it inflicts on you hour after hour after hour.

Re: PHP in 2023

#192

Earlier quoted context omitted.

Php's inconsistencies in regards to needle vs haystack make me weep. Javascript doesn't have anything remotely like that.

I hope you realize that "fixing" these types of early mistakes is almost impossible for PHP, a language which tries hard not to break things, especially something that's going to be used everywhere. But if this is such a deal-breaker and your IDE is dumb as a stump and can't remind you nothing prevents you from wrapping the stdlib or using something like psl to do it for you.

> I hope you realize that "fixing" these types of early mistakes is almost impossible for PHP

I do, yes; which means early mistakes stay in the language forever; same as in javascript. More's the pity.

Re: PHP in 2023

#193

Earlier quoted context omitted.

JavaScript absolutely has things like that. Very famously so. https://www.youtube.com/watch?v=et8xNAc2ic8

Notice that lots of (probably most of; maybe even all) examples in the linked talk are due to unreasonable inputs. `true + true` doesn't make sense; `{}.toString().call(new Date())` or `+[] === +![]` don't make much sense either. This is just not what developers do. Meanwhile, iterating over arrays is absolutely what developers do, on an hourly basis. Which is why I said that javascript doesn't have things like that…

Laravel's Collection class means I don't ever touch a raw array, and I've never had a "left-pad" scenario happen to me with PHP. Both languages have their warts; neither's tends to be an issue in actual practice with an IDE and experience.

Re: PHP in 2023

#194

If you are thinking about building a web application, take a look at Laravel. I not a huge PHP user, but Laravel is always on the top of my list for building web applications. It's the greatest web framework to ever exists, even better than Rails IMHO. The ecosystem around Laravel is really incredible and unlike any other framework. They have libraries for every stage of a web application from taking payments all the…

> If you are thinking about building a web application, take a look at Laravel.

Take a look at Symfony before Laravel. It will be very similar to Java developers who are familiar with Spring.

Re: PHP in 2023

#195

I started my career with PHP. Created my own apps, created client websites etc. Full of footguns, but I didn't know any better. Once I learned more languages, I never used PHP again. I actually started to feel like I'd been fooled into using PHP. Now the small PHP community keeps trying to justify their language choice with articles like these and comments like the ones on this submission. They claim it's a no braine…

  > PHP devs hate dissent it seems.
Perhaps, but do they hate dissent as much as non-PHP devs hate PHP?

Language wars are silly.

Re: PHP in 2023

#196
PHP is useful in the same way that Arduinos are useful. I helps you quickly identify people who don't know what they're doing.

Re: PHP in 2023

#197

I started my career with PHP. Created my own apps, created client websites etc. Full of footguns, but I didn't know any better. Once I learned more languages, I never used PHP again. I actually started to feel like I'd been fooled into using PHP. Now the small PHP community keeps trying to justify their language choice with articles like these and comments like the ones on this submission. They claim it's a no braine…

"the small PHP community" .... what?

Re: PHP in 2023

#198

Earlier quoted context omitted.

PHP is far from my primary language, but in no universe is the language that powers so so much of the internet "small".

Website traffic to servers running the language is not necessarily correlated with the size of the community

whats your metric for a large community? internet traffic? github projects? number public repos? number of packages? by every metric i can think of php is has a large community, not as large as java or python but still large.

how twisted does your dislike of a language have to be for you to not even acknowledge that a lot of people use it

Re: PHP in 2023

#199
post #3

used php in 2015, decided that it's not that nice. last couple of months, I've been banging my head with php7. granted, it's a legacy project, but it is still the same php 7-8 years ago.

PHP 7 is actually pretty good and was the version I stopped at. Upgrading to 8 shouldn't be all that bad and mostly you can just install the new version side by side with the old one. As with any interpreted language, you have to hit every page and what not in order to see if there are any issues that will arise. I don't know if at this point if PHP has a compiler as that would save a HUGE amount of time upgrading to…

There are breaking changes from 7 to 8.

Re: PHP in 2023

#200

Earlier quoted context omitted.

Uhm, how about PHP attributes, getting rid of comments / annotations? Named arguments? Constructor property promotion? Readonly properties (8.1) / classes (8.2)? Arrow functions or typed properties (both 7.4)? I'd say those are really cool things. Especially as a web developer, there's just so much boilerplate I can get rid of since using 8.0+.

I’m in agreement with you that it came a very long way. Now, most of those have been present in many other languages [0], often with less limitations. And as usual the old ways haven’t all been deprecated either, so it stays weird. For instance typed properties were a chance to reset the clock on type handling, but no, declaring a type will force cast parameters to that type instead of throwing an error (i.e. passing…

Yes, the backward compatibility is a crux on the one hand, on the other hand it has made upgrading PHP versions a breeze. In the past 6 months I updated several code bases from PHP 7 / 8.0 to PHP 8.1 / 8.2, the PHP part was easy (just the deprecated dynamic properties in 8.2 caused a wall of text in our loggers), the framework was a bit more difficult. The most problematic were the exotic packages that the clients had installed ages ago and that are not properly maintained anymore, so I have to figure out a replacement for those code modules.

Constructor property promotion is fine, I think. I think it ties in well with the readonly property.

    public function __construct(
        public readonly Company $company,
    )
    {
    }
There's just so much info & functionality + type safety crammed into there that wouldn't have been possible previously; it's really nice.
Post reply on HN