On 06/10/2016 10:01 AM, Dmitry Stogov wrote:
To clarify though, didn't Wordpress and Mediawiki see only a 0.1%
slowdown? In my opinion that is definitely a tolerable performance hit
for such a feature.
I don't see any big value in this feature.
Most framework access their properties through getters and setters
anyway.
They can be and should be used to provide type-safe API.
Another level of protection that makes slowdown instead of expected
speedup, doesn't make any sense for me.
Thanks. Dmitry.
Needing an explicit getter and setter (and the overhead of the function
call) just for type checking is a bug this feature would obviate. If
the only value of the getter/setter is type safety, then you're better
off not using them. (There are other reasons to have getters and
setters, and I'd still love to see the property accessor RFC reborn, but
that's a separate issue.)
Additionally, typed properties provides a terser, more self-documenting
way of communicating the property type and thus expected behavior. I've
written several doctrine classes, for instance, that are 5 lines of
properties and 30 lines of getters/setters/docs boilerplate. If that
boilerplate can be reduced or eliminated, that's a win.
It also provides better introspection capabilities for ORMs and similar
serialization tools. Yes, in some cases richer data than this RFC
provides is helpful but not always. In many cases this would be
sufficient to build automated safety into automated tools. (ORMs,
serializers, validators that now don't need to be written at all, etc.)
That seems like a worthwhile trade-off for a <1% performance difference
in a real-world application.
--Larry Garfield
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php