Live data from Hacker News

A look at modern PHP

lwn.net

61–70 of 610 posts

Re: A look at modern PHP

#61
post #14

Even with PHP7, PHP still feels like it is playing catch up. There is nothing new or revolutionary in PHP7, just adopting features present in other major languages. Adopting as other newer languages like Go and Rust seems to be moving beyond those features. A catch up into a world that's on its way out, if one will feel so blunt. PHP's raison d'être remains its ease of getting an instance running on a webserver. But…

> But with fewer people self-hosting these days, that has become less an advantage.

I don't think fewer people self-host. There are some going to big clouds, there are some using integrated offerings like squarespace, but there are still many hosting their website with a regular hoster. And probably in total many more than in the past.

> And even for those who do self-host, the advantage is becoming narrower as other languages have made it easier to distribute their web applications.

Did they? How?

With PHP, all the users has to do is to fetch the project files and upload them with FTP to the directory the hoster told them to. No other environment matches that - and no other environment is supported by those hosters. If you want to run something else - like Ruby, which I prefer to use, or something that creates a binary for you - you are looking at a completely different type of hosting. Digitalocean, Heroku - and that's not as easy, if the application is not provided as a one-click-install.

Re: A look at modern PHP

#62
post #49
post #33

Earlier quoted context omitted.

I got back into web development in the last year or so. Previously I did mostly Python/Django and then 5 years of something unrelated to dev. Now I'm working in a fairly typical PHP/Wordpress mixed joint, and now I understand why PHP has the bad rep - because it allows/tolerates/even encourages bad practices (and beyond the usual "shoot yourself in the leg" we can see in other popular/common languages). And I guess t…

The thing I hate about php is the inconsistency and unpredictability for new-to-php developers. camelCase? snake_case? nocase? Who knows what the global function will be. And who knows what order the arguments should go in. Sometimes the array is first, sometimes not (in array iterating functions like map). The thing that got my goat the most however was that referencing an undefined variable merely caused a warning,…

FYI when you start a PHP project you need to change your dev machine php.ini to be super strict, so all warrnings should just error out.

The inconsistency seems to have it's logic and at that time was consistent and made sense, you need a good IDE to help with this. Using PHPStorm and then using PHPDoc to define your functions parameters and return type is a joy, the IDE will catch your type mistakes, show you where you missed to catch an exception and it will code complete stuff.

Re: A look at modern PHP

#63

Does php still use $ for variable names in 2020?

Of course. Why change that for zero gain? Powershell does too.

Can you point to some research that scientifically proves that the use of dollar sign in variable names makes it harder to solve computer science problems?

Re: A look at modern PHP

#64

Earlier quoted context omitted.

>If you want to get your customers to self-install your software as painlessly as possible, what other language can match or exceed the ease of deployment of PHP? Anything with containers. Docker was a real game-changer here.

But in the overall scheme of things it's order of magnitudes more difficult to deploy. PHP is upload a file whereas docker requires many more steps (for example: https://kb.sloppy.io/en/collections/156106-getting-started )

The first section in that link literally says

>In our dashboard you will find pre-configured Open Source apps like WordPress, Plone and other. They are all based on the official docker images and can be deployed with just one click.

Otherwise I don't see how something like this is that much more difficult https://www.openshift.com/blog/deploying-applications-from-i...

Or this https://kb.sloppy.io/en/articles/1313693-setting-up-mongodb-...

Re: A look at modern PHP

#65
post #36

Earlier quoted context omitted.

At the same time, being able to install new or change existing software just by uploading some files to a cheap webhost is not to be dismissed as easily.

Most webhosts provide some kind of support for containers don’t they? Perhaps I’m completely missing the point here? I’ll readily admit that Im young enough to have used docker to deploy apps nearly everywhere I worked. Is php useful for ultra low cost websites? Is it low maintenance? Is that the appeal? Genuine question.

Dropping PHP files to a FTP site is as easy as it gets.

Re: A look at modern PHP

#66

PHP, Python and Ruby all feel to me like last-generation languages. IMO we should be building new frameworks on modern languages that support concurrency & static typing. The most promising new stack I've seen is Kotlin's KTOR framework. Thanks to the expressiveness of Kotlin it's not really any more verbose than something like PHP or Ruby but it's far more powerful and robust.

Alas, I feel the same way. After much thought this weekend, I concluded that it was time to move on from PHP. I decided against the any other scripted language (Ruby, Python), as it felt like more of the same.

Requirements were strict typing, functional programming support, built-in concurrency, decent library support, and real support for both native and Javascript. It pretty much came down to Kotlin or Rust.

I really want to like Rust more, but the library support, and the jobs in my area just aren't there (yet?).

Picking up Kotlin feels like coming home.

Re: A look at modern PHP

#67

PHP, Python and Ruby all feel to me like last-generation languages. IMO we should be building new frameworks on modern languages that support concurrency & static typing. The most promising new stack I've seen is Kotlin's KTOR framework. Thanks to the expressiveness of Kotlin it's not really any more verbose than something like PHP or Ruby but it's far more powerful and robust.

Php supports (somewhat) strictly defined types.

You can defined what types/interfaces methods needs to return, what types/interfaces variables must have, what types/interfaces the method arguments needs to have.

It also supports class inheritance, abstract classes, interface classes, class traits, etc.

Re: A look at modern PHP

#68
post #47

If you're starting with WebDev in 2020, choose Go or Rust. Concurrency & safety + simple deployable static ELF binaries > weak typing and legacy bloat.

Why would I use Rust for Web dev or anything else that is not some low level system programming? I mean if you want to write some toy project and want to learn sure, but for a serious project I would chose something that uses a higher level programming language, that has a big and stable standard library and that also has a big community made , well tested libraries to work with.

Re: A look at modern PHP

#69
post #14

Even with PHP7, PHP still feels like it is playing catch up. There is nothing new or revolutionary in PHP7, just adopting features present in other major languages. Adopting as other newer languages like Go and Rust seems to be moving beyond those features. A catch up into a world that's on its way out, if one will feel so blunt. PHP's raison d'être remains its ease of getting an instance running on a webserver. But…

Rust and Go for writing a cusomizable CMS like Wordpress, really? Also PHP playing catch up and not breaking up my stuff with every point release is just fine. It means stability, maturity. Even Node.js has LTS releases.

Dart is more suited for this type of thing if one wants a new and shiny statically typed language with great performance.

Re: A look at modern PHP

#70
post #41

PHP, Python and Ruby all feel to me like last-generation languages. IMO we should be building new frameworks on modern languages that support concurrency & static typing. The most promising new stack I've seen is Kotlin's KTOR framework. Thanks to the expressiveness of Kotlin it's not really any more verbose than something like PHP or Ruby but it's far more powerful and robust.

Nah. The JVM must go; we have Docker and the universal platform are Linux ELF binaries so the entire "bytecode" concept makes sense for the compiler (i.e. LLVM), but no longer at runtime. It's just bloat.

The JVM does what Docker does for far less overhead and is easier to understand and upgrade.
Post reply on HN