Live data from Hacker News

PHP Annotations Are a Horrible Idea

theunraveler.com

21–30 of 127 posts

Re: PHP Annotations Are a Horrible Idea

#21

Earlier quoted context omitted.

I think this is quite a good technical reason: Because code comments should never be necessary for a script to function properly. In which other language do you see comment is necessary to make the code function properly?

> In which other language do you see comment is necessary to make the code function properly? If by "language" you mean "some library which also provides a separate but way more painful and verbose way of doing the same thing", then it existed in Java before Java 5 added annotations to the language itself.

I never know that, but still, the point stands: making a comment necessity for code to function properly is bad, bad, bad. That's why the Java folks throws it out right?

Re: PHP Annotations Are a Horrible Idea

#22

Earlier quoted context omitted.

I think this is quite a good technical reason: Because code comments should never be necessary for a script to function properly. In which other language do you see comment is necessary to make the code function properly?

Its a syntax problem then ? what if the annotation wasn't inside comments would that make it ok ?

I think yes. It's ok if it's not inside comments. Just like any other language (I know at least C# and Java do this for example).

Re: PHP Annotations Are a Horrible Idea

#23
post #5

This is pure horse pucky. First of all PHP isn't about elegance and I find it a teeth grinding experience when people complain about it not being so. PHP is about getting stuff done. He doesn't offer one good valid technical reason why not to use comments for meta-programming PHP other than "it just feels wrong" and an "icky feeling" which is entirely subjective. "Reliance on Yet Another Library"? C'mon. The fact tha…

    He doesn't offer one good valid technical reason why not to use comments for meta-programming PHP other than "it just feels wrong" and an "icky feeling" which is entirely subjective.
Maybe it is subjective, but it sure gives me an icky feeling. You're breaking down a clear division between code and comment - fuzzing the lines. There's something about the idea that yes, I can only describe as being gross.

To each their own I guess, but it's not something I'd allow in one of my projects.

Re: PHP Annotations Are a Horrible Idea

#24

Earlier quoted context omitted.

> In which other language do you see comment is necessary to make the code function properly? If by "language" you mean "some library which also provides a separate but way more painful and verbose way of doing the same thing", then it existed in Java before Java 5 added annotations to the language itself.

I never know that, but still, the point stands: making a comment necessity for code to function properly is bad, bad, bad. That's why the Java folks throws it out right?

> I never know that, but still, the point stands: making a comment necessity for code to function properly is bad, bad, bad.

Not really.

> That's why the Java folks throws it out right?

I'm not sure what that's supposed to mean. "Java folks" don't throw anything out, Sun introduced a better and better-supported mechanism for doing what javadocs were coerced into doing.

Re: PHP Annotations Are a Horrible Idea

#26
post #13

What's in the annotation is configuration, not application logic. As such there's no real difference between putting configuration into YML, XML and annotation comments. In response to your 4 specific criticisms: 1. (DX regressions) - in theory yes, in practice the frameworks are good at this. The annotations compile down to PHP which you can look at directly, and you get exceptions if there is something wrong with t…

3) In this specific case we're reliant on Doctrine to read Doctrine annotations because we're already reliant on Doctrine to be Doctrine. Possibly relevant if the annotation reader was purely collecting metadata it did not use itself.

Re: PHP Annotations Are a Horrible Idea

#27

Earlier quoted context omitted.

I never know that, but still, the point stands: making a comment necessity for code to function properly is bad, bad, bad. That's why the Java folks throws it out right?

> I never know that, but still, the point stands: making a comment necessity for code to function properly is bad, bad, bad. Not really. > That's why the Java folks throws it out right? I'm not sure what that's supposed to mean. "Java folks" don't throw anything out, Sun introduced a better and better-supported mechanism for doing what javadocs were coerced into doing.

> I'm not sure what that's supposed to mean. "Java folks" don't throw anything out, Sun introduced a better and better-supported mechanism for doing what javadocs were coerced into doing.

I mean the Java community didn't use it anymore, because the "annotation inside comment" thing is worse than "annotation supported natively by the language". Granted, it's the only practical way to do it in PHP for now, but it still didn't change the fact that it's bad, IMO.

I wonder why SensioLabs (the creator of Symfony and Doctrine) didn't make the PHP's annotation RFC into reality. They are a quite huge powerhouse in the PHP world...

Re: PHP Annotations Are a Horrible Idea

#28
post #13

What's in the annotation is configuration, not application logic. As such there's no real difference between putting configuration into YML, XML and annotation comments. In response to your 4 specific criticisms: 1. (DX regressions) - in theory yes, in practice the frameworks are good at this. The annotations compile down to PHP which you can look at directly, and you get exceptions if there is something wrong with t…

I would argue that it's better for configuration and application logic should be separate though. You can run the same appliation with a different XML configuration without modification of the source. You couldn't do the same with in-comment configuration.

Re: PHP Annotations Are a Horrible Idea

#29
post #5

This is pure horse pucky. First of all PHP isn't about elegance and I find it a teeth grinding experience when people complain about it not being so. PHP is about getting stuff done. He doesn't offer one good valid technical reason why not to use comments for meta-programming PHP other than "it just feels wrong" and an "icky feeling" which is entirely subjective. "Reliance on Yet Another Library"? C'mon. The fact tha…

It's kind of funny cause his proposed alternative is how Doctrine originally worked...

http://docs.doctrine-project.org/projects/doctrine1/en/lates...

Post reply on HN