Re: annotations again
| From: | Martin Scotta | Date: | Tue, 10 May 2011 12:28:53 +0000 |
| Subject: | Re: annotations again | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52212@lists.php.net to get a copy of this message | ||
On Tue, May 10, 2011 at 5:45 AM, Rasmus Lerdorf <rasmus@lerdorf.com> wrote:
> On 05/10/2011 01:10 AM, Jordi Boggiano wrote:
>
>> On Tue, May 10, 2011 at 10:02 AM, Lars Schultz
>>
>>> To explain what I mean, I'll use the example provided in the RFC. Could
>>>
>>> anyone please explain the advantages of having "passive" annotations over
>>> "active" PHP Code.
>>>
>>
>> I think your example shows very well why annotations are good, it's
>> much more concise.
>>
>
> By concise, you mean shorter, easier to read?
>
> I have a really hard time looking at:
>
>
> <Entity("users")>
> class User {
> <Column("integer")>
> <Id>
> <GeneratedValue("AUTO")>
> <ManyToMany("Phonenumber")>
> protected $Phonenumbers;
> }
>
> as a PHP user and instantly understanding what this does. It looks
> completely foreign from a PHP syntax point of view.
>
> Whereas:
>
>
> class User_EntityAnnotation {
> public function getEntityName() {
> return 'users';
> }
>
> public function getColumnInfo($property) {
> switch($property) {
> case 'id': return array(
> 'column'=>'integer',
> 'isPrimary'=>true,
> 'autoIncrement'=>true
> );
>
> case 'Phonenumbers': return array(
> 'manytomany'=>'Phonenumber'
> );
> }
> }
> }
>
> is way more verbose, but I can instantly grok what is going on without
> learning a new syntax, without waiting for my opcode cache to support it,
> and without waiting for my editor to understand the new syntax.
>
The editor argument is out of place
do you really think that the engine should we built around what IDE
supports?
> Don't underestimate the difficulty in getting opcode cache support for
> something like this. If you think the engine code is complex, try digging
> into the opcode cache code. It will be much much harder to write the opcode
> cache support than it was to write the engine code for it.
>
> I also have a personal problem with code that needs to introspect on every
> web request in order to run. But that is likely because I am old and gray
> and used to stare sceptically at the assembly output of the first C
> compilers to see if I could come up with an alternative that would take
> fewer cycles.
>
> -Rasmus
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>