7 ms·
What to Look For in PHP 5.4
- nixle 15y agoNice to read something constructive and informative besides all the hate PHP has been getting lately.
- SomeOtherGuy 15y agoWhat do you mean lately? PHP has gotten tons of well deserved criticism since it was created. It isn't "hate" to point out that a popular language is much worse than many other comparable languages.
- maratd 15y agoWhen that "well deserved criticism" comes from the same people who feel compelled to post in every PHP thread, obsessively, over and over again ... it's hate. Hate isn't inherently negative. You can hate evil, etc. However, if you hate a programming language ... there's really something wrong with you. It suggests a very sheltered life. There are far more important things in life that deserve your hatred.
- SomeOtherGuy 15y ago>When that "well deserved criticism" comes from the same people who feel compelled to post in every PHP thread, obsessively, over and over again ... it's hate. No, you choose to label someone else's opinion as "hate" because it lets you dismiss it and throw out baseless insults at those people with less risk of getting taken to task for it. You told other people (theoretical people at that) what they think, and then told them there is something wrong with them and they lead sheltered lives. How incredibly arrogant.
- dmansen 15y agoI think something that forces me, almost daily, to waste my time dealing with problems that are simply nonexistent in more sane languages deserves my hatred. (And I have a LOT of hatred for it!)
- tabbyjabby 15y agoWhat are some of the problems you deal with when coding PHP on a daily basis?
- rickmb 15y agoIt becomes "hate" when the criticism is ill-informed and largely irrelevant. The bits of PHP that are "much worse" are mostly either legacy cruft that nobody in their right mind uses anymore, or bits are rarely touched in day to day programming but are safely wrapped in frameworks, ORM's, libraries etcetera. Beyond that, PHP simply isn't particularly elegant (mostly since it was never really designed to be a programming language), and we all know it. Other than that, I rarely see any relevant criticism, let alone constructive criticism.
- SomeOtherGuy 15y ago>The bits of PHP that are "much worse" are mostly either legacy cruft that nobody in their right mind uses anymore, or bits are rarely touched in day to day programming but are safely wrapped in frameworks, ORM's, libraries etcetera. Huh? The article in question demonstrates otherwise, note they just now fixed one of the problems with anon functions, a relatively new feature. PHP continues along the path of adding "features" randomly and without even understanding the purpose behind the feature, and so you get half-features that kinda work and don't really solve any problem in the context of PHP, but were just added so they could check off "some feature we don't understand" on the feature list. >Other than that, I rarely see any relevant criticism, let alone constructive criticism. In the context of PHP, I think "you should use a better language" is as constructive as you can really get. There's nothing wrong with warning new web developers that PHP is worse than every other language that lives at the same sort of level (perl, python, ruby, pike, etc).
- lonnyk 15y ago>PHP continues along the path of adding "features" randomly and without even understanding the purpose behind the feature, and so you get half-features that kinda work and don't really solve any problem in the context of PHP, but were just added so they could check off "some feature we don't understand" on the feature list. This is not how features get added to PHP. Please spend some time on the PHP mailing list if you would like to know how it works.
- 15y ago
- DonnyV 15y agoI'v been thinking about using Php lately. I come from a C# background, so I was poking around to see what I would be missing or gaining from Php. Why haven't they added a compiled option yet? I know you can use http://phpcompiler.org http://phpcompiler.org compiler to do it but why hasn't it just been added to the project? The speed increase is well worth it. Also I noticed Php doesn't have generics or Template classes. I use these a lot in my C# libraries. Anyone know if thats going to be added anytime soon? I do like that its used everywhere. Also looking for a good MVC framework for Php like Asp.net MVC. UPDATE Can you please stop down voting. I'm not hating on Php, read my other comments below.
- darklajid 15y agoDidn't downvote you, but 1) You're hijacking the thread with something unrelated and better suited for some online research or sites like SO 2) According to your questions you're not investigating PHP, you're looking for C# in disguise/in another set of clothes.
- DonnyV 15y agoYeah your probably right about asking this here. I was hoping for some Php experts maybe to point me in the right direction. I'm not trying to hate on Php just want to learn an open source framework or language that has similar features to C#. I really don't want to learn Java because I think thats a dead language. I'd rather use Mono but they don't have very good support for asp.net mvc.
- seanp2k2 15y agoCheck out HipHop which transforms PHP into C++ then compiles that using G++ https://github.com/facebook/hiphop-php#readme https://github.com/facebook/hiphop-php#readme This is what Facebook uses. That aside, PHP is plenty fast as long as you avoid Zend and design your apps correctly for what you're doing. Lots of bad stuff out there giving PHP a bad name, like Magento.
- mgkimsal 15y ago
- sipefree 15y agoIt's been a long time since I had any interest at all in PHP, and these new features make me feel uneasy once again. The development server seems like the only good thing about it. Traits looks like a silly implementation of multiple inheritance mixins, with a 'use' keyword that doesn't really fit in with the language itself. And the whole 'insteadof' thing looks weird. It will lead to hackish code for many people, encouraging weird monkey-patching. The author says "when stored in an array", then proceeds to use "$functions['anonymous']". That's not an array. Sigh. I know PHP likes to call them that, but I just find it weird that they would continue to insist on mis-naming two of the fundamental data types of computer science. The introduction of closures can only be a good thing, and a lot better than the passing of a string name of a function as a callback argument from before. As usual though, it's expected that most servers and frameworks won't get the update for some time, due to whatever backwards incompatible changes have been made. I know it's all the rage to hate on PHP these days, but even giving an objective look at the state of the language, given the thriving ecosystems of its competitors, makes it look to me like something I would never touch.
- j_col 15y agoI don't think that PHP referring to hash maps as an array is a bad thing, in fact I've always loved the flexibility of the overloaded array implementation in PHP. > ...due to whatever backwards incompatible changes have been made. PHP is normally very good that way, does anyone know of any backwards incompatible changes that have been made? > I know it's all the rage to hate on PHP these days, but even giving an objective look at the state of the language, given the thriving ecosystems of its competitors, makes it look to me like something I would never touch. Yes you're right, it is quite fashionable to hate PHP and has been so for the ~10 years I've been using it, but who cares it gets the job done (a language for the pragmatists not the purists).
- sipefree 15y ago> I don't think that PHP referring to hash maps as an array is a bad thing, in fact I've always loved the flexibility of the overloaded array implementation in PHP. But they're not arrays. JavaScript and Lua do the same thing, allowing you to assign numeric or hashed keys on objects (or tables in Lua), but they don't call them Arrays, because they aren't. Arrays have expected behavior and implementations. So do hash maps. It's fine to amalgamate them, just give it the right name. > PHP is normally very good that way, does anyone know of any backwards incompatible changes that have been made? I haven't looked at any in this version, but recently there was an article (I think on HN) complaining about severe ABI changes that required all compiled modules to be recompiled, leading to adoption problems. > Yes you're right, it is quite fashionable to hate PHP and has been so for the ~10 years I've been using it, but who cares it gets the job done (a language for the pragmatists not the purists). I used PHP for many years as well, and for that reason I don't think it's a language for the pragmatist at all. It's not expressive enough, it encourages bad coding, and it doesn't have an ecosystem comparable to Ruby, Python, or even the amazing one Node.JS has managed to garner in the past year or so.
- zombielifestyle 15y agoClosure::bindTo gives a nice js-like feeling, but i wonder why the hell a invocation of a closure in a class member triggers a warning.
- TomNomNom 15y agoClass/object members and methods do not share a "namespace", so it's possible to have a method and a member with the same name. If you assigned a closure to a member that had a colliding method, PHP wouldn't know which one to execute. I'm guessing this is at least some of the reason for that behaviour. You can force it to work in the absence of a collision by using a __call override. An example of which can be seen here: https://github.com/TomNomNom/Talk---New-stuff-in-PHP-5.4/blob/master/10-mungeable-objects.php https://github.com/TomNomNom/Talk---New-stuff-in-PHP-5.4/blo...
- zombielifestyle 15y agoDidn't think of that, pretty obvious now. ty :)
- randallsquared 15y agoLink didn't work for me, but http://jburrows.wordpress.com/2011/12/05/what-to-look-for-in-php-5-4-0/ http://jburrows.wordpress.com/2011/12/05/what-to-look-for-in... did. Not sure why the date would have changed to earlier.
- notJim 15y agoI think this may have been posted prematurely. Even in the version you linked to, it seems like part of the traits example has been cut off.
- adaburrows 15y agoIt's been fixed. I found the correct revision and restored it with the right date. The original link works again.
- robmorgan 15y agodid I submit the right one?
- philjackson 15y agoWhat to look for in PHP 5.4: 404 Not found. I'm going to assume it's a backhanded insult and chuckle along.
- Achshar 15y agoits a 404 for me too!
- deleted 15y ago[deleted]
- ck2 15y agoHas anyone tested the three opcode caches with the 5.4 release candidates? I am depressed that eaccelerator seems to be fading away - they removed their shared memory functions for their build with 5.3 support. In my experience eaccelerator is slightly faster and more stable than xcache. As a bonus, when it did have working shared memory functions (under php 5.2) it has session handler support so sessions are done completely in memory (added: without any additional code or modification)
- maratd 15y ago> it has session handler support so sessions are done completely in memory. It is unbelievably easy to build session support for other op-code caches. Here is my code for APC: if(extension_loaded('session')) { function ses_open($path, $name) { return TRUE; } function ses_close() { return TRUE; } function ses_read($id) { return (($GLOBALS['session'] = apc_fetch($id)) ? $GLOBALS['session'] : FALSE); } function ses_write($id, $data) { if(!isset($GLOBALS['session']) || $GLOBALS['session'] != $data) { if(apc_exists($id)) { apc_delete($id); } return apc_store($id, $data); } else { return TRUE; } } function ses_destroy($id) { unset($GLOBALS['session']); return apc_delete($id); } function ses_gc($max) { if( ($apc = apc_sma_info()) && ($apc['avail_mem'] / ($apc['num_seg'] * $apc['seg_size'])) < 0.25 ) { return apc_clear_cache('user'); } else { return TRUE; } } ini_set('session.save_handler', 'user'); session_set_save_handler('ses_open', 'ses_close', 'ses_read', 'ses_write', 'ses_destroy', 'ses_gc'); } The only problem is that this still requires you to compile the session extension. I am looking into ways of working around that, since it's not really used for anything except re-direction.
- ck2 15y agoHow exactly would you use this with third party code executing on the server that cannot be modified? eaccelerator's session handler (was) simply built in and requires no modification, just add the one-word setting to your php.ini
- adaburrows 15y agoI fixed a spelling issue using the iPhone app. For some unknown reason it published an earlier version. It has the same content, but a different date.
- adaburrows 15y agoI just edited the date manually. The original link is back up.
- mildweed 15y agoI've been waiting for PHP to use traits my whole professional career as a PHP dev. Super excited they're here now.
- coenhyde 15y agoYeah, the lack of traits/mixins were the biggest problem with php's object model.
- kemo 15y agoI still think PHP is good enough. Not the best, the fastest, the safest or the coolest but - good enough. ... and it will remain that way for a long, long time.