Hacker News new | past | comments | ask | show | jobs | submit login

The PHP of today is now a fine house built on a terrible foundation. The warts from the original language are still there, but inexplicably they have decided to just soldier on and build a good language on top of them.

For instance they've built a perfectly good object system with many advanced features; yet arrays, strings, etc aren't objects so you can't even call methods on them, they can only be manipulated by a dated, procedural API.




Adding feature upon feature to a language that does not have a good foundation generally leads to disappointing results. My favorite examples are Javascript, Perl and C++.


It's especially a problem with dynamic languages, the lack of safe refactoring makes changing the language very difficult.

Everybody learned the wrong lesson from the Python 3 debacle. The lesson everybody learned was "Big language changes are bad, don't do them". Whereas the lesson everybody should have learned was "Writing code in a dynamically typed language is like writing it in stone, it's really expensive to upgrade it later".


It is possible to add that, one of of the core developers has done that as an extension, with one limitation, not possible for a mutable api.

https://github.com/nikic/scalar_objects

However scalar methods also creates a bigger discussion around the existing standard library, should functions be duplicated? Etc.

Better in my opinion, because the standard library is mostly functions in the global namespace is to add pipe operator, it has been voted on but not passed yet due to some limitation.

Pipe operator is more flexible because you can use your own functions when chaining.

And then of course there are libraries that does this, which is similar to how Java does it, compare float vs Float.


I see no reason why arrays should be objects. PHP is not Java even if a lot has been borrowed from it over the years.

Array manipulation and associative arrays in PHP are some of its strong points. Yes they are easy to abuse but they are also extremely flexible and make development fast.


There's no reason for arrays to be objects if PHP wants to be a procedural language like C. In the days of PHP4 it was a procedural language and that design made total sense.

However nowadays nobody uses PHP as a procedural language, they use it as an object-oriented language. In that context it is extremely strange to have this procedural API still hanging around for "old" types.


The only problem I see is that array functions are in global scope and not namespaced. Other than that having primitive types doesn't hurt.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: