Live data from Hacker News

PHP in 2021

stitcher.io

41–50 of 309 posts

Re: PHP in 2021

#41

> Still no support for generics, unfortunately Huh? PHP is a dynamic language, you already have them in principle. Usually you can just have no type and use instanceof, but also requiring the parameter to be an interface does the job in most cases if you need more clarity. Edit: There's also method_exists! Also a whole heap of other tools in the toolbox https://www.php.net/manual/en/ref.classobj.php

You have them in theory — you can use generic concepts to model operations — but that dynamism also allows you to break any generic model that might exist.

For example I might say that a function takes a parameter of type "Traversable", but there's nothing stopping me manipulating that object and turning it into a "Traversable" because of that same dynamism.

It might be possible in the future to introduce reified generics which could be guaranteed by the engine, though that may end up being too difficult to add and maintain. In the meantime static analysis tools (like Psalm, which I created) are able to model operations using generics described in docblocks, which works pretty well.

Re: PHP in 2021

#42
post #31
post #17

So basically PHP is still catching up to Hack and but not quite there yet?

Hack might be better from a language design point of view, but most people outside of Facebook seem to have lost interest in it once PHP 7 caught up to it performance-wise.

With Hack's extensive static type checking and even contexts / coeffects, it's much more than just performance. The bigger your system grows, the more pain it removes.

You still can mix it with plain PHP, much like you can mix TypeScript with plain JavaScript.

I wish high-profile PHP projects, like Nextcloud, migrated to Hack eventually; it can be done piecemeal.

Re: PHP in 2021

#43
post #5

In a post called "PHP in 2021" we really can't omit https://bref.sh/ -- it allows running PHP apps on AWS Lambda effortlessly. With all the serverless craze, it's a very important piece of the ecosystem. After writing PHP apps for two decades, I am absolutely stunned how easy it is. Amazon blogged about it at https://aws.amazon.com/blogs/compute/the-serverless-lamp-sta...

FWIW Bref is cool, but it's AWS-only and still has a couple of orders of magnitude fewer daily installations than Laravel: https://packagist.org/packages/bref/bref/stats vs https://packagist.org/packages/laravel/framework/stats.

Re: PHP in 2021

#44
post #11

It's nice to see PHP adding useful things like enums and async (green threads). My foray into Web development started with Perl, but quickly segued into PHP with how much simpler it felt. The ability to hop into vim on your server (or use CPanel back in the day) and edit your site live was exciting back then – but now that very thought makes me shudder with what could go wrong, haha. While I've moved onto JVM languag…

What do they want async for? PHP's purpose is to run once to generate one HTTP response - they'd already forgotten this by inventing frameworks, but adding async seems to especially have forgotten this. PHP already had curl_multi_perform which is very useful for running child tasks, but I'm not sure you need much more than that.

People also use PHP to write backend scripts, without web use at all.

While the original and primary purpose may have been for personal home pages, it has evolved considerably since then. Consider an accounting/aggregate billing script for a PHP application that runs on a scheduler. That isn't dependent on the web necessarily, but it does interface with the moving parts of the overall application. Async would be great here.

Re: PHP in 2021

#45

Earlier quoted context omitted.

They're not lagging behind. Based on my experience, companies in the bay area using PHP often pay just as competitively as others. There are likely a large number of "PHP" jobs available overall though which could bring average pay down, the low-end is low because there's such a low barrier to entry for something like WordPress development.

> There are likely a large number of "PHP" jobs available overall though which could bring average pay down, the low-end is low because there's such a low barrier to entry for something like WordPress development. I was about to write exactly that. There is a long tail of relatively unskilled developers who technically count as PHP devs. I also do not perceive PHP salaries to be lower relative to other web dev stacks…

I guess I can only speak for what I've seen in New York, where it seems like PHP dev salaries are a bit stunted. WordPress or otherwise.

Re: PHP in 2021

#46
post #42
post #31

Earlier quoted context omitted.

Hack might be better from a language design point of view, but most people outside of Facebook seem to have lost interest in it once PHP 7 caught up to it performance-wise.

With Hack's extensive static type checking and even contexts / coeffects, it's much more than just performance. The bigger your system grows, the more pain it removes. You still can mix it with plain PHP, much like you can mix TypeScript with plain JavaScript. I wish high-profile PHP projects, like Nextcloud, migrated to Hack eventually; it can be done piecemeal.

> With Hack's extensive static type checking and even contexts / coeffects

Have you used contexts/coeffects?

My understanding is that it's still yet to be fully rolled out to WWW, and nobody outside FB has yet played around with it. IMO it still has some DX issues (https://github.com/facebook/hhvm/issues/8828) and the examples given in documentation don't actually work in real life (https://github.com/hhvm/user-documentation/issues/1016).

Re: PHP in 2021

#47
post #8

My beef with PHP is not so much the language itself, but the weird community that surrounds it. The FIG standard that forbids TAB for indentation (which is perfectly legal in PHP), the notion that classes should be either abstract or final, the micro-optimizations (thou must use single quotes, things like that). I don't think anyone can tell anyone how to write PHP, because nobody knows how to get it right (myself in…

FWIW, I think the rule about classes being either abstract (like interfaces) or final makes sense. Inheritance is the biggest OOP anti-pattern, producing most headache and bugs. It cannot be completely removed from an OO language like PHP, but can be nicely replaced with composition using interfaces / abstract classes and traits.

Re: PHP in 2021

#48

Earlier quoted context omitted.

> I would say that Laravel is an extremely high quality framework (on par with and even in some ways better than Rails) that nobody should be ashamed to use. Never heard of Laravel. Decided to take a look. First thing the intro documentation says to do is install something called 'Docker Desktop'. I'm good, thanks. Why do I need Docker to play around with a web framework?

Unfortunately the documentation does make it look like you need docker to get started. You don’t though. A litter further down in the docs there is a section for using just Composer, if you’re still interested in checking it out: https://laravel.com/docs/8.x#installation-via-composer

What happened to Homestead?

That seemed to be the recommended way of starting last I touched PHP professionally (4-5 years ago)

Re: PHP in 2021

#49

PHP has been in a pretty good place since 7, IMO. These are some great developments. I would say that Laravel is an extremely high quality framework (on par with and even in some ways better than Rails) that nobody should be ashamed to use. It's unfortunate that the stink of old PHP is so powerful and that salaries are still lagging so far behind.

> I would say that Laravel is an extremely high quality framework (on par with and even in some ways better than Rails) that nobody should be ashamed to use. Never heard of Laravel. Decided to take a look. First thing the intro documentation says to do is install something called 'Docker Desktop'. I'm good, thanks. Why do I need Docker to play around with a web framework?

[deleted]

Re: PHP in 2021

#50
post #5

In a post called "PHP in 2021" we really can't omit https://bref.sh/ -- it allows running PHP apps on AWS Lambda effortlessly. With all the serverless craze, it's a very important piece of the ecosystem. After writing PHP apps for two decades, I am absolutely stunned how easy it is. Amazon blogged about it at https://aws.amazon.com/blogs/compute/the-serverless-lamp-sta...

I don't get it - the cheapest webhosts ($3/month) all let you run PHP - why would I need a cloud function when I have an always-on machine?

And if it's for something with high traffic, why would you want a cloud function anyway? I thought they are meant for "runs sporadically, so why have a machine that's always on?" setup.

Post reply on HN