PHP 5 OO In 24 Slides
An anonymous reader writes "At php|works about a week ago John Coggeshall gave an interesting talk on object oriented programming using PHP version 5. Even if you couldn't be at the talk, his slides are available online which gives you a pretty good idea of what you can expect from the OO model. Java programmers will be pleased."
Ugh I just noticed I got fp :)
Anyway, I wouldn't really need OOP in scripting.
From slide 5:
Member methods may also be declared final, preventing them specifically from being overloaded in a sub class
s/overloaded/overridden/
See here.
Why? Because it sucks as much or more than Java's sucky OO?
The only languages with semi-decent OO are ones with multimethods/generic functions e.g. Common Lisp.
It really depends on what you are trying to achieve but I used PHP CLI many times to solve quick problems. PHP's impressive function library makes it easy to do anything. Can you give me an example where PHP isn't suitable for general scripting?
BTW, I agree PHP is better at web than scripting. Now back to the main topic...
As always, Coggle (I just need to spread John's 'short' name) used his PHP girls in the slides.
These are far from being the first slides about PHP 5 available. I had seen some from Zeev Suraski 1.5 year ago. Actually, about every PHP conference around the world ever since PHP5 was buildable had it's set of PHP5 slides.
Qui ne va pas à la chasse n'a pas de gibier
PHP Queb
Which means they failed to grasp what good clean OO is and instead inherited everything to hell and developed a standard toolkit of 1500 seperate classes?
As many times as I've heard this fun fact, it never ceases to amaze me: "In ZE / PHP 4 objects weren't references, so when they were passed to a function a copy was made."
I've never heard this one before, and it's just as ridiculous: "In PHP 4, you couldn't access a member function or properity indirectly through another object's member function or properity.."
Yikes. How did they get it that wrong!?? And how did they manage to come up with (what looks like) a very reasonable object system for PHP 5?
Also, what is the "interface" feature for, if the language is not statically typed? Will you get a runtime error as soon as an implementing but non-conforming class is defined? Or is it primarily just a more formal way of documenting your class? Or does it work solely in concert with type hinting to prevent you from passing in an incorrect type?
If you bother to make slides for a presentation, and then publish them on the web, you should take the extra minute or two and run a spell check over them. Reading something that includes misspellings and grammatical errors every other sentence is not just distracting -- it makes me wonder if the content and examples are correct.
Personally, I'm less than impressed. Why should I cheer and hooray about PHP introducing some OO features in PHP in 2004 almost all of which Java has had since version 1.0 in 1995? Is that supposed to be a great feat?!
Stupidity is mis-underestimated.
Does it make sense to define classes, create objects, restore objects from some serialized storage or database, etc. etc. in the context of a web application? That's a lot of scaffolding to build and tear down for every HTTP request.
OOP clearly makes sense in many applications where the class definitions and objects have a lifetime longer than a single call. And it's possible to write server-side applications that "live" longer than a single HTTP request. But that isn't the PHP execution model.
The ZEND Accelerator has clever caching and compilation mechanisms, but how many people have the Accelerator installed? How many ISPs? Without those optimizations the PHP interpreter is scanning/compiling the entire script (including all of class definitions) for each request. In that environment it makes sense to keep the scripts as short and simple as possible, not add code and complexity with OOP.
I'm not saying that OOP is a bad idea, even in PHP code. But does it make sense to implement full-blown OOP instead of using included files for common code? In my PHP 4 projects I mainly used classes to get a namespace, not for any other OOP purposes.
Java programmers will be pleased.
I'll be pleased when PHP gets static typing.
A much more better speled deskripshun of PHP5's OO language enhancements are is available from the horse's mouth
Yes, Java developers will be pleased... because they'll stick with Java. PHP is destroying its niche by trying to go the Java-ish OO route.
Yet another acronym! POO - at least its in keeping with GNU-like querky acronyms!
So you're saying that if a networking library requires a linked list or hashtable it should roll its own rather than reusing an existing, efficient implementation?
Also, your example seems contrived. Please show me where I need to access a linked list from within the classes in java.net. Will some List implementation be loaded by the classloader in your networking program? Probably, but not by the networking packages. If it's loaded, it's because the programmer needed a List.
Also, a JVM will likely have quite a few *.so files lurking in the background. Unless the classes that need the native support are loaded by the classloader, the loadlibrary call is never called for them. Class definitions aren't loaded into memory unless they're used.
You'd advocate splitting off the string handling functions of the standard C library from the other functions? Sure, it's a different header file, but it's the same *.so file. After all, all I need to do in my program is tokenize a string and spit it back to the console. Why should I have to map a 1.2MB library just for that? (By the way, I was being facetious.)
Or maybe you enjoy dealing with twenty different ways of threading. And if you point to your one favorite threading library, do you use that same library on UNIX, Mac, et al.? Or are you the type that states that threading has no place in software -- a fork is the only true way kinda guy. What about database access? ODBC or do you code each and every database separately? (Then again, with ODBC, you have to make enough special cases that indeed you do code each and every database somewhat differently.)
My point is these are solved problems. And for that matter, there is nothing stopping a person from writing their own linked list or hashtable implementation. Nothing. Why doesn't anyone? Because over and over what has been seen is that the standard ones are either (a) better or (b) good enough that the extra effort isn't worth it. I know that (b) probably upsets you, but if my project isn't about hashtables and the difference between the two implementations would have a negligible impact on the overall project, it's not worth doing. Reinventing the wheel in this case is what KILLS innovation.
Enough hyperbole. Please show me where the JSL is deficient. Let's debate specifics.
It's funny you should mention that. I'm assuming you are talking about C++'s std::string and using type traits and template parameters to make appropriate forms of strings for the task at hand. (See, I read Modern C++ Design and Dr. Dobbs too.) First,
- I don't need to go outside, my CRT tan'll do me just fine.