Search code examples
javaandroidc++cprogramming-languages

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?


Solution

  • 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: