4 ms·
I sometimes ponder what I'd fix, given the chance, about PHP: * Make the "stdout == response body" an explicit option, and make a rendering engine the default
by awestroke 13y ago
I sometimes ponder what I'd fix, given the chance, about PHP:
* Make the "stdout == response body" an explicit option, and make a rendering engine the default instead. Just sending all output is a senseless DEFAULT.
* Remove all the array_x functions and turn arrays into a class instead, and change the parameter order to be consistent across all the functions. A similar action could be done across many other classes of functions, too.
* Tighten equivalence requirements, == should work like ===.
* Etc.
But I always realize I'd just end up with Ruby or Python, both of which already exist and have fantastic ecosystems. Oh well.
- Gigablah 13y ago> == should work like === Then why not use === ?
- awestroke 13y agoI know enough to use === when I program in PHP (even though I oftentimes forget) but newbies don't.
- aviraldg 13y ago>> but newbies don't ... and sadly constitute a large majority of PHP users.
- diggan 13y agoIsn't that true for all languages though?
- WiseWeasel 13y agoThey'll learn soon enough. It builds character.
- nkozyra 13y agoI think at this point simply removing critical, old bugs, unicode support and removing and/or restructuring the cruft of the standard library would be enough. Unfortunately, the biggest hurdle at this point is reputation. No full or dot release will change that.
- mgkimsal 13y agoMake the "stdout == response body" an explicit option Why? It's a primary differentiating factor for PHP, and one of the cornerstones of its popularity. Given that it powers a non-trivial percentage of the web, from single page "hello world" sites up to multi billion dollar ecommerce sites, I'd say 'fixing' that one aspect is not something that needs to be. "== should work like ===". Why? If you want ===, use ===. But given that HTTP, the lingua franca of the web, is typeless, and PHP is targeting web developers, having a language that doesn't enforce types in all cases isn't all that bad.
- awestroke 13y ago1: "Explicit option" means it's still possible, but shouldn't better practices be encouraged? Anything to push developers away from interleaving logic and templates 2: PHP, however, has types. == is wildly unpredictable
- userbinator 13y ago1. Why add complexity when it isn't necessary? Inline output is one of the best features of PHP in that it makes it extremely easy to get started using it. If you want templates you can add them. Not everyone wants them. 2. PHP is dynamically typed, like many other languages, and so you just have to know what types something can be and how they behave together. Even in a statically typed language you need to know how type conversions work. That's what the documentation is for ( http://php.net/manual/en/language.operators.comparison.php http://php.net/manual/en/language.operators.comparison.php ). It's not "wildly unpredictable", it's defined and deterministic.
- mgkimsal 13y ago" Not everyone wants them." And not every project needs them. PHP has been wildly successful precisely because it can fit in entirely small use cases, as well as big cases. Someone who needs to create a dynamic footer with a "copyright $year" in it... has no need for MVC, routing, templates, version control, etc. They just don't. It's precisely because PHP has a default content-type output of 'text/html' that this sort of 'throwaway' functionality can be done with PHP and pretty much no other language. Not that other languages couldn't do this, but everyone seems to turn up their nose at this market. And yet... this is where the majority of the next generation of developers (and the current gen, and the one before) come from.
- lotsofcows 13y ago"Tighten equivalence requirements" But PHP is a great tool for working with the messy world of the web. Being able to type !$anyvariable is expressive, obvious and straight-forward. I don't care what type it is. Unless, I do; then I use ===
- alien3d 13y agoI prefer dual world. array_x = less memory $object->array->getElement[0] = i prefer not.. Just to get element you need to declare object ?