Live data from Hacker News

PHP 8.5

stitcher.io

111–120 of 197 posts

Re: PHP 8.5

#111
post #90

Earlier quoted context omitted.

C hasn’t changed all that much, and someone who coded in C99 would take about 30mins to catch up to a modern C23 codebase’s changes. Famously so, as conservatism to change is the main friction in the community for about two decades now. If you pull out examples of the earliest C, sure, it looks weird . But that C was already obsolete in 1989. Since then, it’s had a minor iteration (e.g. five-eight additions/modificat…

You can learn everything about undefined behavior in 30mins?

It's moot to the aforementioned point. Undefined behavior wasn't introduced as a new language "feature" between C89 and C23; it's existed the whole time. We're talking about specification deltas, not the entire corpus.

But, if you want an answer to your question:

You can learn to avoid undefined behavior in about 30 seconds.

If you're purposefully fiddling with undefined behavior, it's because (ideally) you're A) an advanced developer and you know exactly what you're trying to achieve (and inspecting the generated code) and/or B) you're using a specific compiler and don't plan on porting your code elsewhere.

Re: PHP 8.5

#112

Earlier quoted context omitted.

What do you mean developers should deal with functions like those? They're used when necessary, yes, just like any function. And no IDE is required. I'm really puzzled.

> And no IDE is required. What else to say, good luck. You didn't get the anecdote, that's probably because you haven't worked with PHP (long enough). I will give hint: inconsistency.

Either working with PHP for 21 years is not long enough or simply too long. I honestly think these small inconsistencies are irrelevant in the big picture of building something complex. Like you said, programmers should deal with them. It just doesn't sound like a big deal.

Re: PHP 8.5

#113

PHP's evolution since PHP 5 has been substantial, and I think this is a real problem. As someone who learned the language years ago, the pace of change (generics, attributes, match expressions, typed properties) makes modern codebases genuinely difficult to follow. I suspect this affects many developers who cut their teeth on PHP but haven't kept up. The language has become a different beast, which is a strength for…

It's a real problem with almost all software today, nothing ever gets done. they just keep piling unto it no matter how great it was. the idea of simplicity as a goal and feature is lost on this generation.

Re: PHP 8.5

#114
post #71

Earlier quoted context omitted.

I am quite sure many people would fail Pub Quizzes related to C, when taking into account the whole language alongside compiler extensions, regardless of the compiler.

To learn all of the common GCC and MSVC extensions would make up a fraction of the language features of C# or Java. You’re really overstating the complexity to make some invalid point. “Actually, one of the most notoriously conservative and simple (in feature set) languages is really super complex and has evolved a ton because it has _Generic and varargs now, and __packed__ exists as a compiler feature.” And to furth…

A pub quizz would consider more than GCC and MSVC, and still I would bet many would fail if talking only about those two.

And I would double down on my bet regarding ISO C related questions, as I have met a few folks that contrary to myself as language nerd, hardly know what is written there or have even opened the PDF drafts at least once in their life.

Re: PHP 8.5

#115

Earlier quoted context omitted.

It has nothing to do with being “too hard”, and everything to do with not making sense to the type system. PHP is weakly-typed and heavily reflection-based (so everything is aware of it’s and each other’s type at all times). Adding generics to PHP would make CS fundamentalists somewhat happy, but do nothing to change the fundamental design of PHP nor offer any of the traditional benefits that generics offer to strong…

> And would be a massive headache to implement Exactly. The type system was never built for anything even slightly more complex. Its basically annotations for primitive types and classes. PHP has always had an weak type system, so adding generics will most likely never happen. > Adding generics to PHP would make CS fundamentalists somewhat happy PHP has really only one collection datatype (the infamous array), so hav…

[deleted]

Re: PHP 8.5

#116

A lot of people are too proud to be associated with PHP. I am ready to admit that know nothing about the language except that a lot of people make cool things with it. My favourite PHP product at the moment is BookStack ( https://www.bookstackapp.com/ ), a really good wiki. I run an instance for my family and it's great. But there are loads of things. And I notice that many of the sites I like using...are built on we…

Modern PHP is a damn fine, fast language. I wrote production PHP from 2021 to 2023. The problem with PHP wasn't the language or the ecosystem (PHP community packages are very solid in my experience), it's the existing PHP code you'll work with and the people that hire for PHP.

My salary literally doubled within two years of getting a gig that wasn't PHP. If you see a listing for PHP dev work, there's a good chance it's notably lower salary. There are still solid gigs for it, but I swear they lean lower.

The other problem is the existing codebases. There is some awful legacy PHP 4 era code. There are also a lot of practices that old PHP had that are just awful to work with, and there's a bit of variety in there. So many bad data access patterns out there. Many of old PHP codebases have their own spin on that kind of thing.

I understand this isn't actually due to the language, but there is a real correlation (in my experience) between old bad code and it being in PHP. Which is totally fair because it was a good tool to reach for to "get shit done (r)" and that code was successful enough to have to continue to live.

Modern PHP has, thanks to the core language and the big frameworks, made it wonderful. I lead a big push to go from PHP 5.8 to PHP 8.1 at the time at my last company. It was wonderful. The quality of the code we were enabled to write was huge.

If I was starting a new project today, I probably wouldn't reach for PHP, but I'd gladly join in on a modern (last ten years) Laravel project.

Re: PHP 8.5

#117
post #114

Earlier quoted context omitted.

To learn all of the common GCC and MSVC extensions would make up a fraction of the language features of C# or Java. You’re really overstating the complexity to make some invalid point. “Actually, one of the most notoriously conservative and simple (in feature set) languages is really super complex and has evolved a ton because it has _Generic and varargs now, and __packed__ exists as a compiler feature.” And to furth…

A pub quizz would consider more than GCC and MSVC, and still I would bet many would fail if talking only about those two. And I would double down on my bet regarding ISO C related questions, as I have met a few folks that contrary to myself as language nerd, hardly know what is written there or have even opened the PDF drafts at least once in their life.

[flagged]

Re: PHP 8.5

#118

Earlier quoted context omitted.

I downvoted you before reading the fine article. I'm back to correct that. The new array_first() and array_last() functions are nice, everything else is either reimplantation of existing features or "features"which will make maintainability more difficult. The pipe operator is one such example. I don't need it - these nested methods are not really an issue in any codebase I've seen. The new syntax only works for unar…

I'm sort of on the opposite side. I'm unconvinced by extra functions for arrays in the global namespace and I'm happier about syntactic improvements and debugging improvements.

I'm glad to hear a dissenting opinion. Interesting that we experience PHP differently.

What is your background? I've been working mostly with PHP and Python for about 25 years. Do you come from e.g. Java?

Re: PHP 8.5

#119

Earlier quoted context omitted.

> And no IDE is required. What else to say, good luck. You didn't get the anecdote, that's probably because you haven't worked with PHP (long enough). I will give hint: inconsistency.

Either working with PHP for 21 years is not long enough or simply too long. I honestly think these small inconsistencies are irrelevant in the big picture of building something complex. Like you said, programmers should deal with them. It just doesn't sound like a big deal.

> I honestly think these small inconsistencies are irrelevant in the big picture of building something complex.

Big picture is PHP is a poor tool. I enumerated only one annoyance about writing software on PHP, 80% of all websites on the web being built on it doesn't make it any better. Some companies keep building on it, because:

1. They started writing the codebase in PHP, now they are "locked" (cost of switching to another language is extremely high)

2. Hiring PHP developers usually costs a lot less (at least 20%) than say Java/Python developers

People keep arguing that, for seasoned developers it doesn't matter what tool one chooses. Then what is the point of choosing a tool over another, if you gotta check the docs constantly for inconsistencies? (I'm sorry, you gotta use IDE anyways)

With that said, there is no ideal language, however PHP is single most annoying language after JavaScript.

Re: PHP 8.5

#120

Earlier quoted context omitted.

It has nothing to do with being “too hard”, and everything to do with not making sense to the type system. PHP is weakly-typed and heavily reflection-based (so everything is aware of it’s and each other’s type at all times). Adding generics to PHP would make CS fundamentalists somewhat happy, but do nothing to change the fundamental design of PHP nor offer any of the traditional benefits that generics offer to strong…

> And would be a massive headache to implement Exactly. The type system was never built for anything even slightly more complex. Its basically annotations for primitive types and classes. PHP has always had an weak type system, so adding generics will most likely never happen. > Adding generics to PHP would make CS fundamentalists somewhat happy PHP has really only one collection datatype (the infamous array), so hav…

Python managed to do this by not actually checking the types at runtime. If you declare a list[int] return type but you return a list[string] then nothing happens, you're expected to prevent that by running an offline typechecker.

PHP chose to check types at runtime. To check that a value is really an array the runtime could have to loop through the entire array. All the types PHP currently implements are simple and cheap to check. For more elaborate cases you need an offline checker like PHPstan and comment-based type annotations. (PHPstan catches 99% of issues before the runtime gets to it so for my own code I'd prefer the Python approach with its cleaner syntax.)

The runtime checking seems the key difference, not so much the historical strength of the type system. Python's language implementation does very little typechecking itself and PHP's third-party offline typecheckers are respectably advanced.

Post reply on HN