Live data from Hacker News

PHP 8.1.0

php.net

161–170 of 286 posts

Re: PHP 8.1.0

#161

Earlier quoted context omitted.

Honest question: what are people using if not PHP? Node? Python? The 80% of us who aren’t FAANG and are writing CRUD apps. I’ve tried researching the pros/cons and all I get are low quality listicles. Nobody can tell me why PHP is “bad” or what Python does that PHP can’t. Inconsistent params are the only argument I’ve heard. Which my IDE solves. What about JavaScript splice vs slice. I look it up every time.

Out of date but this is the classic anti-PHP polemic. https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/

Can we _please_ stop posting that link, in 2021? It's very, very outdated.

Re: PHP 8.1.0

#162
post #77

Genuinely curious: who here thinks PHP is a good choice for a new project and also has experience with other languages such as Scala, Kotlin, Python, or JavaScript and their respective web frameworks?

PHP is still used today because it needed good docs. Who's laughing now?

Re: PHP 8.1.0

#164

PHP has a lot of warts, and I mean a lot , but one thing I really like about PHP that virtually no other Web languages offer is that I can just drop code in my Web server's document root, go to that path in my browser, and it runs, without needing to deal with frameworks, boilerplate, compiling, etc.

I see this being echoed in many different ways. For myself, this aspect of PHP is how I was able to get into software development for fun in my younger days. "Change this, save it, refresh and see what happens" was amazing for motivation at one point in time.

Re: PHP 8.1.0

#165
post #134

Reading some comments here and it does confuse me Promises, async and await in javascript, coroutines and threads in kotlin, fibers in some language runtime (including this php 8.1 [0]), single process (nodejs), multi-process(php-fpm worker), single-thread, multi-thread, goroutines in go, multi-core coroutines Googling the definitions and x vs y situation helps a little, the main confusion to me is why some people wa…

> modern times to run php, people would use php-fpm with nginx, it is running multiple worker (single) process, so why would anyone [2], [3] wants multi-core coroutines in it? What does it even mean?

Not everyone does. There's also https://reactphp.org (which is an event loop runtime, similar to Node), and https://amphp.org (also event loops), and Swoole https://github.com/swoole/swoole-src (coroutine runtime, similar to Go).

Fibers are basically an API that event-loop runtime libs can use so that userland code doesn't need to use promises or generators to run non-blocking operations. Fibers are not useful for php-fpm or swoole users.

Re: PHP 8.1.0

#166
post #108

Earlier quoted context omitted.

There isn't a language that can replace php in 2021. Javascript doesn't have the size of build-in library. Golang is compiled and limited, blank spaces/tabs will kill a Python program. Ruby /rails is slower. All are harder to host. What could you replace php with? The tales of legacy mistakes holding back php are things with no basis in reality. What legacy mistake holds php back? Method names/parameter ordering? Whe…

Honest question: what are people using if not PHP? Node? Python? The 80% of us who aren’t FAANG and are writing CRUD apps. I’ve tried researching the pros/cons and all I get are low quality listicles. Nobody can tell me why PHP is “bad” or what Python does that PHP can’t. Inconsistent params are the only argument I’ve heard. Which my IDE solves. What about JavaScript splice vs slice. I look it up every time.

I write PHP for my job almost every day, and have for the past 4 years, and there's some truth to what you say: anything you can write in another language, you can also write in PHP.

Personally, I can't stand writing PHP, because, sure, I can write secure, testable, safe code in any language, including PHP, but, how do I say this, PHP is the only language that feels actively hostile to my attempts to do so. The house style at my current company could be boiled down to "Check 3 times that there are no PHP footguns present in this code. We have been burned before." The developer experience and tooling is far behind comparable languages. I feel like I have to put my sysadmin hat on to fix anything that goes wrong with my environment.

When I write Javascript or Python, I have complaints and issues, but I enjoy writing code. I think PHP, for many programmers, including myself, is just a hostile and unenjoyable experience. If you enjoy writing PHP, I have nothing against you and am certain you will remain employable, there's a lot of PHP out there.

> Honest question: what are people using if not PHP? Node? Python? The 80% of us who aren’t FAANG and are writing CRUD apps.

Python, Node, Java, .NET, Ruby. MVC CRUD apps are pretty similar in all of these (also in PHP). All of those languages (including PHP) power many many many software companies (including FAANG, who use a lot of Java and C++, and Facebook famously was built on PHP).

Re: PHP 8.1.0

#167

Earlier quoted context omitted.

There's already kinds of classes that can't be instantiated, why would this specifically be a breaking change?

If by "kinds" you mean abstract classes, yeah. I just checked, there's no special handling for those since requesting them from the container makes no sense. I suppose a constructor could depend on an abstract type and expect an actual implementation, though. I haven't thought about that use case actually, but it's possible to configure a substitute for this case. Other IoC containers may handle this one better, sinc…

I can't think of any situation you'd put an enum in the container though. Maybe I'm just too tired to think of a situation where that would be helpful. Can you think of one?

Re: PHP 8.1.0

#168

Earlier quoted context omitted.

I think you (and to be fair, many people) are missing a huge part of why PHP is still popular. Saying Ruby can replace PHP sounds to me like saying that Ruby can replace Excel. It's fundamentally misunderstanding _why_ it's popular in the first place. I have a HTML page. How do I add a hit counter to it with Ruby? I can do it right now in PHP with zero dependencies and it'll fit in this comment: You are visitor numbe…

This example seems to be a great demo of why people do not like working with PHP. PHP makes the shit method the massively simpler way and the good method much harder. Now you open yourself up to risks like what happens if we accidentally let some user input change the file opened as well as the content written. While with rails, to do basically anything, you already have a full db ready and incrementing a counter usi…

I don't find these kinds of what-ifs very useful. I haven't used Rails, but does it somehow prevent you from accepting user input and programming it to go where you say you want it to go? Isn't there an element of "holding it wrong" with any language or framework?

Re: PHP 8.1.0

#169

Earlier quoted context omitted.

I just run go test. No need for alt+tab. Why reloading anything when testing the backend code?

Perhaps it's not a SPA but has traditional backend-side templates for pages.

You don’t need to recompile for template updates.

Re: PHP 8.1.0

#170
post #80

Earlier quoted context omitted.

Once you throw that stuff in K8s, you’re back to 10seconds.

Do you debug your apps in a K8s environment? Why?

To be clear, I’m not saying this is a good reason, but I’ve been doing it lately because otherwise the browser security features prevent a local auth service from passing tokens to the backend app via the browser. I need to figure out a way around this because the iteration loop sucks; probably I’ll add a flag to disable auth on the backend app so I can test non-auth-things locally.
Post reply on HN