Nikunj Patel Nikunj Patel - 1 month ago 8
Android Question

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?

Answer

can compiler take some time at comment portion?

No, you won't be able to see any measurable time difference in compile time by adding / stripping comments in a typical Java/C/C++ program.

Use comments if you believe they make the code easier to read and maintain, and don't base the decision on whether to include / exclude them on compile-time.

(Sure, the parser will need to traverse the whole file, so if you have a gigabyte-comment, you may see a difference. But typically, the time it takes to parse (and throw away the comments) is an insignificant part of a full compile.)

Further reading: