Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do comments affect compile time?

I'm an Android developer and the following question came to my mind: When I put a big comment in order to compiling process, is that while we put our useful comment in code , can compiler take some time at comment portion?

If no, then is it not get any effect since how long our comment?

like image 442
Nikunj Patel Avatar asked Sep 06 '11 07:09

Nikunj Patel


1 Answers

can compiler take some time at comment portion?

Apart from the IO overhead of traversing the bytes corresponding to the comment (which should be negligible as long as it's not a several megabyte long comment), it will make no difference what so ever. Most compilers don't even include the comments in the AST, which means that the comments are completely gone after parsing.

Never decide whether or not to include a comment based on compilation time. Base your decision solely on whether it makes the code more readable or not.

Further reading:

  • How To write comments
  • How do I write in-code comments and documentation in a proper way? Is there any standard for this?
  • How to write good javadoc comments?
like image 164
aioobe Avatar answered Oct 12 '22 03:10

aioobe