DEV Community

Discussion on: Underestimated PHP

 
insidewhy profile image
insidewhy • Edited

I guess you're not too familiar with recent ES standards, but when it comes to OOP JavaScript and PHP are very close. JavaScript has private methods/functions now, but not protected. TypeScript has had this level of encapsulation for quite some time though.

I think in general it's not objectively correct to say that PHP has more "modern features" than JavaScript. One thing that really bothers me is how verbose functional programming can be in PHP and many would argue that functional approaches to coding are becoming more popular than OOP (does that mean "more modern"?)

By API I think you mean standard library, this isn't so much of a problem for me given how easily it is to fill these gaps with third party packages and once you throw tree-shaking into the mix there isn't even a runtime size or performance penalty for doing so.

Thread Thread
 
pyrsmk profile image
Aurélien Delogu • Edited

I'm aware of recent ES additions. Compared to PHP 8.1 there are many things where Javascript is clearly behind PHP. But, indeed, FP in PHP is quite a pain to use.

Yes I meant Standard Library, my bad. Indeed, we can fill the gaps with third party libraries, but it points out what the language lacks of. Anyway, PHP also miss many things and with my comments I just wanted to underline that : no, PHP is quite different from what people think of it. And : yes, Javascript is not especially superior. All depends on what we're talking about.

For example, Javascript is a clear winner when it comes to async task handling.

Edit: just to add that we should not forget that PHP has static type checking