6 ms·
PHP is the perfect showcase of how good languages are not sum of features at all. I don't think you can fix PHP just adding stuff that it lacks. It can be impro
by antirez 14y ago
PHP is the perfect showcase of how good languages are not sum of features at all. I don't think you can fix PHP just adding stuff that it lacks. It can be improved in this way as, at least, it is possible for a good programmer to pick a subset of features that makes the language less a pain to use, but I wish PHP could start changing in a "let's redesign it" way.
Disclaimer: I'm a big fan of PHP, not because I like the language, but because I like the pragmatic approach.
- TazeTSchnitzel 14y agoPHP does make big, backwards-incompatible changes at major versions. They are slowly happening, but only slowly, unfortunately. But I hope to see some big changes before trunk becomes PHP 6.
- encoderer 14y agoI'll bite... like what? All of PHP4's syntax is still valid in PHP5 even if it does raise a deprecated notice. The only real thing that broke in the upgrade is if you had a LOC that was expecting an object to be passed by value. Theoretically possible but practically very very rare. And of course config settings like register globals being changed, but that's just that: a config change.
- TazeTSchnitzel 14y agoregister_globals was removed. PHP5 changed the semantics of objects entirely. Before they were value types. Still, yes, not enough has changed IMO.
- encoderer 14y agoThis is certainly a debate about semantics, but I don't think you mean "semantics." They changed the implementation of objects. And they added new syntax. But they made no changes that affected the old syntax -- except the one I mentioned.
- TazeTSchnitzel 14y agoI guess so, I'm not well-versed in programming nomenclature, I haven't done a CS course.
- deleted 14y ago[deleted]
- wvenable 14y ago> They changed the implementation of objects You're implying it was an implementation detail. They fundamentally changed how objects worked, the semantics, that made it completely impossible to move any of my PHP4 code over in a reasonable way. It is possible to make code, that uses objects, work in both PHP4 and PHP5 but you have to restrict yourself to a subset of both versions.
- encoderer 14y agoThat's interesting. What were you doing with your PHP4 classes that didn't run in PHP5?
- wvenable 14y agoThe difference between value semantics and reference semantics is pretty significant. It's almost impossible to do any meaningful OOP without taking that into account. Getting PHP4 to work reasonably requires a lot of work (hence the change in PHP5). None of the PHP4 frameworks moved over to PHP5 without a lot of re-writing. My code simply assumed value assignment semantics and changing that everywhere was just too much work. At this moment, I still have sites running PHP4.
- encoderer 14y agoI'd love some specifics. Were you passing around objects and mutating them while expecting the existing object to be unchanged? For example: $o = new MyObject() $o->important_data = 'clean'; function foo($give_me_o) { $o->important_data = 'dirty'; } foo($o); echo $o; // Need this to say "clean" Because that, literally, is all that changed. Yes, the implementation changed. But PHP4 syntax (including explicit pass-by-reference and class-named constructors) still works in PHP5. That's not an accident. That was by design. Go back and read the discussions. Frameworks chose to upgrade because you get MUCH better memory management and cleaner syntax from PHP5. But many, many people run PHP4 code in a PHP5 runtime. It works just fine. Because that example I used above -- while it is totally possible you have code like that, that's in practice pretty rare.
- TylerE 14y agoWhich is a problem in and of itself...languages shouldn't have config files.
- notJim 14y agoI agree that it would be great if they actually were fixing stuff instead of only adding stuff, but as someone who works in PHP on a daily basis, I certainly appreciate the addition of modern features as well. It seems like one way for them to fix a lot of the old stuff while maintaining backwards compatibility would be to add new string and array (and dictionary?) classes with sensibly-defined interfaces. I imagine there are a fair number of less-obvious issues around that that make not as easy as that sounds, though.
- TazeTSchnitzel 14y agoThose already exist, they are in Spl if you want them.
- wvenable 14y ago> I wish PHP could start changing in a "let's redesign it" way. I think that's foolish. Redesigning a language is making a new language -- and there are lots of other new languages to choose from. What features of PHP would you want to keep that aren't possible in other languages? Radically changing the language also leads to heavily splitting the community like with PHP4/PHP5 or Perl5/Perl6 or Python2/Python3 and nobody wants that. Backwards compatibility doesn't have to be fully maintained but it does have to be respected. The biggest issue right now with PHP is that there isn't a clear direction on where to go. Nobody wants to "fix" some of the old problems because the gains don't seem to outweigh the costs.
- jrockway 14y agoThere is room for a language that generates HTML by default, compiles every library anyone could ever need into the core, and puts it all in the default namespace. All you need to make that socially acceptable is something like GHC's -XNoImplicitPrelude option. By default, you get what might be considered to be a big mess. But when someone with a clue shows up to turn your prototype into something maintainable, they can turn on "expert mode" and program normally again. That's what PHP is missing: expert mode. As it stands now it's very difficult to turn off all the traps, so experienced programmers are forced to switch to other languages. Compare this to Perl, where it has silly behavior by default, but you can turn it off with "use strict" at the top of the file.
- wvenable 14y agoMy PHP code looks pretty much identical to my code in other languages. Everything is in namespaces and classes. There is abstractions for database access and other common operations. I don't think PHP needs an expert mode; it just needs to continue to be a better language. However, I agree, all languages should have the ability to turn off the backwards compatibility crud with some kind of statement. In PHP, it would be great to do that at the namespace level -- allowing different libraries to operate at different levels of support/strictness in the same project.
- 14y ago
- smsm42 14y agoFor some people. there's just no pleasing of them. Short of whole PHP community deciding to scrap the whole project and came to them for directions how to live further, there's nothing to be done to make them happy. This "redesign" thing you talk about would never happen. Or it happened already dozens of times, if you want. It's just called other languages, not PHP. PHP is something that it is, and it develops and gets better, but if you think the whole premise is wrong - fine, there are tons of other approaches around. That doesn't mean every topic on PHP should be accompanied by good old "yeah, that's nice, but you have to redesign it". What's the point of it?