views:

115

answers:

4

I wondered if I should write my code clean and readable or rather small and unreadable... Or should I write it readable and then compress it afterwards when I'm publishing it on the web?

Ps. I'm building a web app, the faster, the better!

Thanks_

+3  A: 

I'd say, write a clean/readable code and then eliminate the bottlenecks, if needed.

binaryLV
+5  A: 

I think you are greatly underestimating PHP's performance if you think this will affect it.

Write clean, readable code. In fact write code as if the next guy to maintain it is a sociopath that knows where you live.

Edit In response to AESM's comment... not in any way that matters. Also you can edit your question if you want to expand on it, instead of leaving a comment.

Manos Dilaverakis
As they say, it's easier to optimize simple code than it is to debug optimized code. Which in this case is actually obfuscated and not optimized at all, so hmmmm.
Tom Dignan
lol. +1. and another +1 for the sociopath, if I could. :)
back2dos
Ok thanks! Forgot to mention this but,will this also effect its performance?If I use:echo "</span>";echo "</a>";echo "</p>";Instead of:echo "</span></a></p>";
AESM
Heh ok, I'll keep that in mind. Do you also happen to know something on the subject of "PHP vs Ruby on Rails"?
AESM
+3  A: 

PHP parses the code before executing. The first stage is tokenization, which throws out all comments and whitespaces, and converts all identifiers to tokens. This means neither meaningfull names, nor sensible comments and clean formatting will have any effects at runtime. In fact all speed effects you seem to expect from compression are already lost during tokenization.

If you do have "bigger" source files due to clean coding, then tokenization will effectively take longer. However this effect is barely meassurable compared to actual parsing and execution.

If you feel you want to optimize at that point, please consider using eaccelerator, which makes an actual difference.

greetz
back2dos

back2dos
Thanks for the wonderful explanation!
AESM