Does it take longer time to compile if you have a lot of comments in the code?

Author: (knutia)

A slightly odd question, but is there any sense in that? Can I speed up my compile time by deleting old code and comments? I have a lot, in some cases much more comments than code


  1. FYI: Rik accepted the challenge. You can find his analysis here:

    Author: Theo Neeskens (
  2. Hi Knut, just talking about parsers in general: ignoring comments is the very first thing a compiler normally does so this should not take too much time. deleting "unused code" will per se reduce the parser tree (AST) and therefore will speed up the compiling process. In uniface, it is more to get all the different database sets together from the database because there are no simple textfiles to be processed. So sometimes a simple "clean up" can speed up the compiling process be deleting "deadwood" UXGROUP/UXFIELD entries. But to get a proper answer, I think it's the best you contact your local CPWR representative.

    Author: ulrich-merkel (
  3. Maybe you should ask Rik Lewis. He seems to enjoy that kind of research. Look at his blog:

    Author: Theo Neeskens (
  4. Compile time, yes. The compiler will need to execute logic to determine if it is a comment or not. It might be a trivial check, but it needs to be done and that might take a very small amount of time, which in theory could add up.

    Author: Adrian Gosbell (
  5. knutia said ... I have a lot, in some cases much more comments than code

    If the comment is necessary to understand what is happening, there's no reason to sacrifice maintainability for microfractions of compile time. Most coders will say inline comment is much easier to maintain and use compared to find some hopefully synchronised external documentation. You will find much comments in the LPMX, sometimes as BLOCKDATA, because they are directly at hand. Most cases I checked, the UFORM comment field was totally out of sync with what happend in the actual code.

    Author: ulrich-merkel (