Live data from Hacker News

PHP Annotations Are a Horrible Idea

theunraveler.com

31–40 of 127 posts

Re: PHP Annotations Are a Horrible Idea

#32
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…

It violates the "I don't need to look inside comments for sources of bugs" rule I'm quite fond of.

I've defended PHP for some time now, but this is getting ridiculous.

Isn't PHP embedded inside markup? Wouldn't it be simpler to do something like:

?> and not violate any expectations?

Re: PHP Annotations Are a Horrible Idea

#33
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…

the official RFC for annotations is actually a little cleaner in syntax, easier to read and implemented in the language itself which is a way beter system than comment annotations. On a level I do agree that docblock comments are no place for annotations, it's the best we can have for now though, just until annotations become a native PHP feature. Judging from the RCF and discussions on internals we still have a long…

Wow, I didn't know about those RFCs to make annotations a part of the language. Thanks for posting.

Re: PHP Annotations Are a Horrible Idea

#34
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…

Agree. Symfony and Doctrine 2 compile annotation to PHP anyway. I'ts much easier to use annotaions than xml or yamls configurations.

Re: PHP Annotations Are a Horrible Idea

#36
post #14
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…

I disagree. > First of all PHP isn't about elegance...PHP is about getting stuff done. What language isn't about getting stuff done? > He doesn't offer one good valid technical reason why not to use comments... Not true. The OP explicitly points out that it breaks many PHP debugging capabilities. > The fact that you can even parse out comments with the reflection API lends, to me, that meta-programming is a-ok. So wh…

Many of the OPs complains have the tone of "not my PHP!!!".

If old PHP devs learn to look for annotations, points 2 and 4 no longer apply, and many points in 1 no longer apply either.

It sounds more like a PHP dev grumbling about change... (what else is new)

Re: PHP Annotations Are a Horrible Idea

#37

This could be solved if annotations were supported syntax. This works well in other languages (e.g. decorators in Python and annotations in Java)

(Python 3 has function argument and return annotations too)

I've made a static type checker for Python...

https://github.com/williame/obiwan

Re: PHP Annotations Are a Horrible Idea

#38
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.

Not necessarily. Several Symfony components rely on doctrine/common simply for parsing annotations, even if you are not using Doctrine for anything else.

Re: PHP Annotations Are a Horrible Idea

#39
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…

> I'll take the first one because I have other shit I need to do.

Uhh, what's so hard about making an array?

Post reply on HN