4 ms·
I have one foot in each of the PHP and Ruby camps. As a bit of an exercise I went through and did the equivalent in Ruby (implement a class, test adding proper
by damncabbage 15y ago
I have one foot in each of the PHP and Ruby camps.
As a bit of an exercise I went through and did the equivalent in Ruby (implement a class, test adding properties and methods) just to see how it'd look: https://gist.github.com/1183334 https://gist.github.com/1183334 (Slimmed down versions of both came to 118 and 50 lines for PHP and Ruby respectively.)
I'm happy Traits are coming to PHP, but given I haven't yet been able to use any PHP 5.3 features in any production environment outside of hobby projects, I'm awfully glum about the prospect of being able to make use of them any time in the next couple of years.
- larve 15y agocoming from a lisp background, and now working on a 'mid-sized' php CMS, i've been pretty happy with the reflection and other features (dunno if they are 5.3 or not) like closures to build something which has around methods, reflectioning on the docstrings to generate a REST api, etc... good fun indeed, you still have to be aware of a lot of php quirks though to make your code secure.
- troels 15y agoClosures are new in 5.4, but the reflection api has been there since 5. Indeed, PHP may not be pretty, but it's really good at hacking stuff together that just works. A lot like shell scripting, although much more maintainable. My biggest beef with PHP is that there is such a chasm between the procedural style at the object oriented one. This is mostly caused by PHP adopting a static class model (a really odd choice for an otherwise highly dynamic language). On the plus side, this tends to cause fewer surprises than you see in languages with a more dynamic object model.