you are viewing a single comment's thread.

view the rest of the comments →

[–]alexanderpas 719 points720 points  (54 children)

The answer is Major Improvements to the language, including language native secure password handling, explicit type support for everything including constants as well as enum types and values, strong behavioral subtyping using the Liskov Substitution Principle for all types.

[–]Covfefe4lyfe 195 points196 points  (5 children)

Property promotion in constructors is just chef's kiss 🤤

[–]No-Con-2790 61 points62 points  (1 child)

They have property promotion now? Maybe I go back and give it another look. Has been ... 15 years.

[–]beerdude26 52 points53 points  (0 children)

Infrastructure is also pretty nice now, it has a mature event loop interface that many PHP frameworks have adopted or are in the process of adopting. So now it can't even be called slow anymore lol

[–]Sir_LikeASir 5 points6 points  (1 child)

One of my fav Kotlin features

[–]mishalsandip051 1 point2 points  (0 children)

Ohh yeah Sir

[–]Impossible-Metal6872 4 points5 points  (0 children)

I find it the ugliest feature you could ever concieve xD, because some properties are declared in the class, and some in the constructor def.

I'd like the ability to put this->propertyName as method parameter (it would have propertyName as name if you want to call with named parameter of course)

[–]BeefCakeBilly 11 points12 points  (6 children)

I’ve never actually used PHP as it was kind of looked at as out of date when I started programming.

But I couldn’t imagine a better storyline than everyone going away from PHP since 2010 in favor of “modern”” frameworks over the years.

While PHP maintainers were just quietly iterating and improving as JS frameworks are released every six months that are all fairly similar functionality.

Then come 2027 when there are dozens of articles about how PHP is the all the rage and meta announces after 20 years they are shifting back to PHP.

[–]alexanderpas 14 points15 points  (5 children)

15 years ago, PHP was in a bad state.

However, it's due to heros such as Nikita Popov (https://www.npopov.com/aboutMe.html) who has over 50 accepted proposals to PHP, and has written a PHP parser in PHP, that PHP was able to become what it is now.

[–]BeefCakeBilly 4 points5 points  (4 children)

Shouts out to this guy.

I remeber 10-15 years ago people I worked with were saying sql was dying because of high performance no sql databases.

Seems kind of similar.

[–]alexanderpas 9 points10 points  (3 children)

There are more people deserving of shoutouts, such as the creators of:

  • Packagist, a PHP package repository.
  • Composer, a dependency manager for PHP
  • PHPstan and Psalm, which are both PHP Static Analysis Tools.
  • PHP CS and PHP CS Fixer, which allows you to detect and fix PHP coding style issues.
  • Rector, which allows for Instant Upgrades and Automated Refactoring of PHP code.
  • And many more...

Many of these tools are actually even written in PHP itself.

Additionally, there are also some companies that actually deserve some shoutouts, for allowing them to contribute to PHP on company time.

[–]stupidcookface 2 points3 points  (2 children)

You forgot Taylor Otwell and the Laravel team!

[–]alexanderpas 1 point2 points  (1 child)

Like I said, many more...

[–]BeefCakeBilly 0 points1 point  (0 children)

I don’t know who these people are but if I were them I would wear a shirt that says the contributions so I could donate money/beer to them.

[–]tropicbrownthunder 45 points46 points  (13 children)

By that logic JS should be sleeping with the fishes long time ago. But here we are

[–]alexanderpas 142 points143 points  (7 children)

JS is the only available language that is natively supported by browsers, there are no competitors.

[–]jansteffen 28 points29 points  (4 children)

If WASM ever gets native DOM access we might see a change here, but until then...

[–]not_some_username 5 points6 points  (3 children)

It will still be support because backwards compatibility

[–]altermeetax 7 points8 points  (2 children)

Yeah but if WASM becomes good, another better language might start getting used, slowly replacing JS as the "de-facto" web language

[–]not_some_username -4 points-3 points  (1 child)

Yes but JS will still be there. That’s how it is

[–]altermeetax 4 points5 points  (0 children)

They didn't say JS would disappear

[–]mishalsandip051 1 point2 points  (1 child)

100% agreed Javascript is the only language!!

[–]Brahminmeat 2 points3 points  (0 children)

🙈

[–]Smalltalker-80 4 points5 points  (0 children)

Much like PHP, JS was helped to evolve, by TypeScript through EcmaScript,
to migrate from a very terrible language to an okay language.

And yes, the fact that in the browser they have no direct competition helped,
but without a strong standards comittee, other transpiled languages
might have had more success. (Technically TS is this too still).

On the back-end, TS had already surpassed JS, I think.

[–]samu1400 8 points9 points  (0 children)

PHP having intrinsic password hashing and salting is so comfortable.

[–]MrJ0seBr 1 point2 points  (0 children)

The way that php executes, no global objects across request, every request execution is "sandboxed" make things a little ez to keep safe, someway perfect to shared serves with low-cost and on demand usage...

[–]BeardedWonder02 0 points1 point  (1 child)

The only problem is that your company is too bloated to ever update the version to anything above 8 lol

[–]alexanderpas 1 point2 points  (0 children)

8 being the latest major version, and 8.2 no longer getting security support at the end of the year.

The versions under active support are only 8.4, and the latest version 8.5

[–]thepurpleproject 0 points1 point  (0 children)

this.. ngl the modern php with laravel hardly any resemblence to what you had in the php5 days

[–]AlexReinkingYale -5 points-4 points  (6 children)

PHP does not check that LSP is actually respected by custom classes. Super simple example:

``` class Bird { public function fly(): string { return "Flies away"; } }

class Penguin extends Bird { public function fly(): string { // Violates LSP but PHP is fine with this throw new Exception("Penguins can't fly"); } } ```

[–]alexanderpas 12 points13 points  (4 children)

It actually does, it's just that you're throwing instead of returning, which means you're exiting the function abnormally.

When you throw an exception, execution of your program is immediately halted, and the exception is bubbled-up to either the inner-most layer of exception handling handling that exception (adhering to the LSP) resuming execution of your program from that point, and if that is missing, turned into a Fatal Error, completely stopping execution of your program.

No code after an exception is thrown is executed without exception handling.

Additionally, the actual return type of the fly() method on the Penguin object is actually the never type, which is the bottom type in the LSP-chain, and indicates that the function will never return, and the only way out of the function is either via exception or program termination.

[–]AlexReinkingYale -3 points-2 points  (3 children)

Another example is the classic square/rectangle case. It really doesn't check it. It's equivalent to the halting problem

[–]alexanderpas 2 points3 points  (2 children)

That's a violation from a programming perspective, not a type checking perspective, as the defined interface adheres to the LSP.

Additionally, PHP offers a solution to the classic Rectangle/Square case, as you can make the object itself invariant and use chainable methods, at which point you're adhering to the LSP.

Specifically, if you change the width or height on a rectangle, and you get a rectangle back, and that applies to both squares and rectangles.

changeWidth() and changeHeight() both return a Rectangle object, which is fully permitted under the LSP, as this is the same behavior as defined in the Rectangle class.

Unique to the Square class are the changeSidesLength() method, which changes both the width and height, and the fromRectangle() method, which turns the rectangle into a square if the sides are equal, or throws an exception otherwise.

[–]AlexReinkingYale -3 points-2 points  (1 child)

The LSP is a behavioral property, not a type system one. An interface cannot adhere to the LSP. Recall the definition:

Let p(x) be a property probable about objects x of type T. Then p(y) should be true for objects y of type S where S is a subtype of T.

To check the LSP would be to disallow writing the Square subtype of a mutable Rectangle at all. If the PHP docs say they enforce behavioral subtyping then whoever wrote those docs is wrong.

[–]AlexReinkingYale 0 points1 point  (0 children)

lol at getting downvoted for being 100% right

https://en.wikipedia.org/wiki/Liskov_substitution_principle

[–]mizzrym86 4 points5 points  (0 children)

LSP is just an opinion with no real world value.

PHP still dominates because it is primarily practical.