Live data from Hacker News

A look at modern PHP

lwn.net

331–340 of 610 posts

Re: A look at modern PHP

#331

Earlier quoted context omitted.

Coming from Java, the one pet peeve I have is the automatic type conversion. I just find that I never really know what my variables are _really_ holding. It's one of those foundational issues that I just can't get over. ...but it's my personal problem - I don't hate PHP.

Work as a PHP dev, in a PHP/JS shop. In all new work we require static typing on method parameters and defined return types. Of course, if your type is 'array' it could be an array of anything but we also try to avoid that and use collection classes. It honestly feels a lot like Java now, without the compile step.

I do the same in Python with type hinting. It's not actual typing, but at least there are tools that can help call us on our dumbass bullshit.

Edit: and by "our" dumbass bullshit, I mostly mean when we thoughtlessly return type T when we claimed we'd return type U

Re: A look at modern PHP

#332
post #127
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'd assume that Django and Ruby on Rails can't be that far off.

[deleted]

Re: A look at modern PHP

#333

Earlier quoted context omitted.

Define proper please.

No native support for concurrency operators, no real event loop implementation, lack built-in support for non-blocking IO... I do Elixir regularly and Actor Model is not something PHP developers know

> I do Elixir regularly and Actor Model is not something PHP developers know

/me clutches pearls

What a travesty! I wish, I, a lowly, stupid PHP developer was smart enough to know about the Actor model!

/s

Re: A look at modern PHP

#334

Earlier quoted context omitted.

Go and Rust were designed for other things... why wouldn't you compare it to the big language that was actually designed to compete in the same space as PHP? NodeJS. Front end devs are already programming in JS, so there's less adoption cost than PHP. I can't think of a single reason to use PHP over Node (I know both, and have delivered projects in both). The comparison to .Net and Spring makes me think you might be…

Node developer here, but... two notes about your comment concern me a little. 1. "I can't think of a single reason to use PHP over Node" this is fine but can you think of a single reason to use Node over PHP. Is adoption cost the only one? 2. "you might be a bit behind the curve" while the original commenter was talking about PHP being "modern" and dimissing talk of it existing because of legacies, criticising someon…

1. Off the top of my head: SSR of JS apps, performance, better security track record. It also fits in the modern architecture better: you can certainly write a rest API in PHP, but that's not typically what you would use PHP for... and if you're going to write a react, vue, etc app, you're likely writing an api also.

2. This is not my attitude at all. I've been programming since the 90s.. In the past I've maintained PHP apps for years; maintained a custom web framework for 17 years; I still have sites running that use jQuery.

It's certainly true the JS ecosystem has that mentality... but that does not mean every JS tool can be dismissed with that thinking. NodeJS is 11 years old... it's not a shiny new thing anymore.

Re: A look at modern PHP

#335
I ended up using PHP while I worked in a design shop, as it was extremely easy to both implement designs in and easy for low-tech clients to run.

It wasn’t bad. Good docs, reasonably easy to run & deploy (except Wordpress). I don’t think I’ll ever use it again more due to career reasons, temperamentally I prefer the backend, but given the same circumstances I’d use it again.

Re: A look at modern PHP

#336

Earlier quoted context omitted.

Ruby on Rails. Django. Revel. Actix.

RoR and Django are probably the closest (Laravel was inspired by RoR). Still, I don't think they support all those features. Like I can't find any official RoR support for payments, full text search, encryption, pagination, scheduled tasks or building CLI commands. With Django, full text search seems limited. It supports PostgreSQL, but I couldn't find first-party integration for Algolia, Solr, Elasticsearch etc. or…

Python has an Elasticsearch API available as a package, which is probably why it's not packaged in with Django.

Re: A look at modern PHP

#337

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…

Haters gonna hate. Node.js programmers are looked down upon too by go programmers. C programmers are an anachronism, haskell is for academic navel gazing etc. Small minds think their favorite language is the best because they can't see outside their own problem domain.

Languages are tools that suit different needs. Use the best tool for the job, pay attention to industry trends so you don't become a Cobol dinosaur with no job prospects. Switching to node is a good career move but it won't be your last. Node has incredible momentum and developer mindshare. You can accomplish a lot with it but node projects are difficult to maintain.

Never stop learning or growing.

Re: A look at modern PHP

#338

Earlier quoted context omitted.

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…

That's a really good point. Nothing is perfect, and frameworks are no different, so after awhile the friction points come to the fore.

Also, I have a theory that with the more common languages, you obviously find a much broader user base of beginner-level programmers, or, worse, programmers who just don't care about quality, which translates to more dysfunctional code in the community in general. My coworker at one company did not have good things to say about PHP, but when he had to take over a PHP project of mine when I left the company, he said it was some of the most well-written PHP he's ever seen -- organized, easy to follow and modify, etc. He didn't even realize PHP could be written in an eloquent fashion. (Not to brag, I've written plenty of bad code too.) Point being that if all you see in a certain language is jumbled spaghetti code, it's easy to think of it as a bad language.

A good programmer should be able to create eloquent code in any language.

Edit: Realized after posting I may have sounded like I thought you were not a good programmer -- that's not what I was saying at all! You can write eloquent code and still be frustrated with what the framework or community forces upon you.

Re: A look at modern PHP

#339
post #168

It saddens me to see some of the (largely baseless and otherwise largely historical) hate for PHP. I use Hack in my day job, which has at this point diverged from PHP, and I like it for the most part. The thing that PHP does right that so few languages do is having a stateless core in the webserver. This is an incredibly efficient approach to serving HTTP traffic. Consider the startup cost issues with Java, or Rails'…

> The thing that PHP does right that so few languages do is having a stateless core in the webserver. I never understood why the HN crowd always ignored this massive benefit of PHP, in a world where it's becoming clearer everyday that keeping things stateless across the stack provides many benefits towards managing complex systems.

Most of the interesting things I’ve worked on would fall down if you couldn’t cache some stuff across requests, like database connections. If every request requires a new TCP connection, even if to something lightweight and fast like a local pgbouncer instance, requests are going to be a lot slower (and the time spent context switching from userspace to kernelspace and back a lot higher) than if you could reuse one from an in-memory pool.

I love stateless stuff and have started moving a lot of things to Lambdas where appropriate, but I wouldn’t use a completely stateless setup for handling large numbers of requests per unit time.

Re: A look at modern PHP

#340
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…

Being unpopular is one of the strengths of php. They rarely break stuff to make it look cool. Your 10 or 20 year old project can keep running, keep making money, allowing you to "learn the shiny stuff you ll never use"
Post reply on HN