PHP is completely changing their philosophy at least since version 5. Before it, PHP was a duck-typed language for creating home pages. It was perfect for its purpose, because it was easy, quick and dirty.
At some point, people started using it for full-blown applications. PHP maintainers decided to support these mad men and they've started transforming PHP to meet their needs. They're trying to make it look like Java, abandoning every original PHP design principle. It took years and it still cannot be even compared to Java, feature-wise and ecosystem-wise. It's a sad, pointless struggle.
They're trying to make it look like Java, abandoning every original PHP design principle. It took years and it still cannot be even compared to Java, feature-wise and ecosystem-wise. It's a sad, pointless struggle.
The original PHP design principle was for it to be a basic template engine exposing C++ services. Things change in 20 years, who woulda thunk.
As for design principles "abandoned" since 5.x, I'm curious to hear what they are.
The renewed interest in dynamic languages that have optional typing and statically verifiable invariants is hardly unique to PHP. It's an industry trend. TypeScript is wildly popular in the JavaScript community. Python is getting typehints. Dart comes with typehints out of the box.
All dynamic languages are moving to have more static features, and all static languages are adding more dynamic features.
It's a normal process of convergence, and I agree it's a "struggle", but it's not a pointless one. We get better, more well-rounded languages as a result, which are more efficient and pleasant to work with, for a wider range of projects.
For example the lack of generic types forced us to abandon type hinting in some cases, because we'd suffer from class explosion.
Lack of generics means you can have a typed collection containing untyped (statically) items instead. I agree generics are better, but at least this approach wouldn't result in a class explosion.
BTW there's a lot of appetite for generics now and some RFCs are starting to pop up. Chances are a 7.x release will come out with generics.
For the record, Go also has no generics, but somehow people aren't as keen to pile garbage on it for this as they do for PHP. Instead we get tons of articles how "people don't get it" and Go has no support for generics on purpose. No one has that attitude in PHP. People realize it's a good feature, but it'll come when it's ready and fully baked. Lots of things to add. BTW, Facebook's dialect of PHP ("Hack") has generics.
Some other PHP 5 features are ill-designed and not thought through at all, but they're popular, e.g. the late static binding.
What's ill-thought about it? The feature came out of a real need, like factory methods:
Foo::customConstructor(...);
class Bar extends Foo {}
Bar::customConstructor(...); <- you want back an instance of Bar, not Foo.
I find I need LSB rarely, but I'm glad it's there. It's a very humble feature that doesn't interfere with anything else in the language. If you want to bind early, the syntax is still there, working as always.
It was also too late. A lot of the code embraced the duck-typing nature and now it had to interact with type-hinted code and often could not satisfy the stricter preconditions.
PHP 5 was released nearly 12 years ago. I don't know how 12 years ago is "too late" but basically all code I'm actively using right now has been written after the PHP 5 release.
Lots of major frameworks have happened after PHP 5 as well, and they've had a major version bump after PHP 5.3, and now again for PHP 7.
It was probably "too late" back 12 years ago, but the world keeps turning, and the only thing that'd be "too late" at the end of 2015 is to see code which still hasn't switched away from PHP 4 idioms.
2
u/dagguh2 Dec 02 '15 edited Dec 02 '15
PHP is completely changing their philosophy at least since version 5. Before it, PHP was a duck-typed language for creating home pages. It was perfect for its purpose, because it was easy, quick and dirty.
At some point, people started using it for full-blown applications. PHP maintainers decided to support these mad men and they've started transforming PHP to meet their needs. They're trying to make it look like Java, abandoning every original PHP design principle. It took years and it still cannot be even compared to Java, feature-wise and ecosystem-wise. It's a sad, pointless struggle.