
Originally Posted by
Stormrider
I agree that code should be self documenting, good variable names etc, but this is all distracting from the original discussion of deathshadow's claims that adding comments slows down the server too much - which is a load of rubbish!
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.
It is about balancing useful against the penalty; answer me this, do you consider this a meaningful comment:
Code:
// HTML
<?php /* ===================== START BLOCK ======================== */ ?>
<div id='new_left'>
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.
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:
Code:
header("Content-type: text/css;charset:UTF-8"); http://www.barelyfitz.com/projects/csscolor/
What on earth does that URL have to do with sending content-type?!? Pointless meaningless comment.
Code:
if(0){include'style.class_colors.php';} http://www.typefolly.com/
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?
if(1){include'style.style_fonts.php';}
if(1){include'style.style_dimensions.php';}
Always true, why do these have if statements?
if(0){include'user_1.php';}// blood,tangerine,banana,ocean,grass,coal
if(1){include'user_2.php';}// blood,tangerine,banana,ocean,grass,coal
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
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.
All I'm saying is don't put stupid pointless comments in -- is that SO HARD or TOO MUCH EFFORT?!? Sheesh.
Bookmarks