Time complexity of datatype and comment length

In principle, parsing longer input must be slower than parsing shorter input (assuming the entire input has to be parsed, which is certainly true for compilation). So yes, increasing function name or comment length does increase the time it takes to process your source code. The real question is, by how much?

And the answer is: in practical scenarios, not in any measureable way. Comments are simply discarded. Identifiers are probably hashed. It would surprise me if changing identifier/comment/literal length in any practical project affected compilation times by more than 0.1%

On the other hand, it could easily reduce programmers’ understanding of the code to a small fraction of what it would be otherwise, which will increase development times, maintenance costs, and probability of introducing bugs.

Leave a Comment