4 ms·
> I asked him why the PHP code he sent me didn't have any comments. "I don't believe in comments because they slow the PHP interpreter down." Sorry, he can be s
by alinajaf 13y ago
> I asked him why the PHP code he sent me didn't have any comments. "I don't believe in comments because they slow the PHP interpreter down." Sorry, he can be smarter than Einstein but I ain't letting him near production code.
This one wasn't smarter than Einstein. It's been a while since I've been near a live PHP installation, but IIRC running with an opcode cache like APC probably means the comments will be parsed at most once (every server restart?)
- at-fates-hands 13y agoThis true - but without the opcode cache the slowdown would be minimal since all the comments are ignored. Plus, the comments are there for future developers to use as a reference. Nothing worse than having something break, cracking open a file and have to spend hours having to untie someone else's code. I'd rather have copious amounts of comments, then a minimal speed gain due to not having them at all.
- base698 13y agoComments like: // Adds two numbers // method takes Object argument and returns list Are useless.
- wpietri 13y agoAmen, brother. As Martin Fowler writes, "Any fool can write code that a computer can understand. Good programmers write code that humans can understand." If Mr. not-Einstein had actually measured some production issue that could be traced back to commenting, he could always have written a filter that stripped them before production. My guess, though, is even he didn't believe this excuse; it was just a glib thing to say in hopes of wiggling out of trouble for being a negligent coder.
- tommorris 13y agoThat's the thing: if he'd said "I was cranking this code out quickly, but, yes, it could do with some comments", I'd have been fine with that. The excuse is worse than what he's trying to excuse!
- wpietri 13y agoAgreed! If somebody is going to bullshit me in an interview to cover up their weaknesses, I have to assume they're going to do it after I hire them.
- dusklight 13y agoSince you bring up Fowler, in his book Refactoring he gives specific examples to show why you should AVOID comments. In most situations you should try to write code that is so clear no comments are needed. That's what the above code is really about.
- kylesnc 13y agoThis! Far too often I see worthless comments because people were taught in school "you should comment your code".
- gpsarakis 13y agoI suppose someone could incorporate a procedure which strips down unnecessary strings from code files ("minifies"), especially comment blocks, during the deployment process, thus maintaining a nice development codebase while not having questions over performance.