That it slows it down at all means that POINTLESS comments should be avoided -- that's all I'm saying... DO comments imbue a penalty on the parser time? YES. Do comments make it take longer to load from disk? YES.
Originally Posted by Stormrider
It is about balancing useful against the penalty; answer me this, do you consider this a meaningful comment:
Even if the comment itself were useful (opening a div is the start of a block, I'm shocked) all those equal signs are a waste of code.... It doesn't say what block is being started making it LESS useful than the DIV, the closing one doesn't say what block is being ended, making you have to scroll back up to find it -- net result is a POINTLESS comment that was a waste of time to type, waste of time to load from disk, waste of time for the parser to have to ignore when converting it to bytecode.
<?php /* ===================== START BLOCK ======================== */ ?>
That's pretty much my point. I wouldn't have a problem with it if the comments were USEFUL. (which is why I'm not entirely happy with the title chosen for the thread split -- it's a MINOR part of what I was responding to)
Go futher down his code, and you have comments like this:
What on earth does that URL have to do with sending content-type?!? Pointless meaningless comment.
header("Content-type: text/css;charset:UTF-8"); http://www.barelyfitz.com/projects/csscolor/
Again, huh?!? Meaningless comment that makes no sense. Of course, this is the OTHER thing I took it to PM over; the condition is always false so this code would NEVER run; why is this line even there?
Always true, why do these have if statements?
What on earth do those comments have to do with the user includes -- are those usernames or something?
Comments should answer questions, not create more of them.
That it's using php to output CSS (say goodbye to client-side caching) is just a further head scratcher since IMHO there's no legitimate reason to EVER do that... god forbid the end user have to edit CSS... or write your changes to a static file instead of wasting processing time creating it on every request. That's just as bad as presentational markup at that point.
I'm seeing the EXACT SAME ATTITUDE on this I encounter with HTML in terms of valid semantic markup; "Oh it's so insignificant an impact" and "Oh it's too much effort for the return"... too much effort to NOT write wasteful/pointless comments... Too much effort to NOT do something? It's akin to the "It's too much effort to follow a few simple rules to continue to make my pages useful on IE6 and even IE 5.5"
It does NOT take extra effort to go "hey, maybe I shouldn't fill a line with 90% equal signs or asterisks"... it does not take extra effort if you bother following coding conventions that prevent you from making mistakes in the first place. It shouldn't take extra effort to put meaningful names on things or to bother using the enter and tab key to make blocks of code logic clearer.
But you always have the people who claim it do, and just "vomit up code any old way"... Just look at the source code for turdpress for proof enough of that.
... and "simple code" doesn't mean pointless code with vague/misleading/nonsensical comments. Premature optimization and bothering to follow a style guide making clear code are two separate things. Simple practices that reap MULTIPLE benefits (not just optimization) are NOT evil JUST becuase a slight code speed increase are a SMALL part of it. (Have we mentioned how the thread split title pisses me off and how you guys are focusing on a SMALL part of what I was originally saying?!?)
I should have just posted the PM in the original thread and to hell with dragging it off topic.
READ MY ORIGINAL POST
All I'm saying is don't put stupid pointless comments in -- is that SO HARD or TOO MUCH EFFORT?!? Sheesh.
Now, PHP is a two stage bytecode interpreter; which is to say that it does a byte-code style compile before executing, but the inital parse still takes overhead for comments which is why stupid pointless comments (like a row of nothing but asterisks) should be avoided...
Certainly a code caching accellerator (APM, eAccellerator) helps by caching the byte-coded version, but if your code ends up flushed from the cache those comments will incur their penalty again.