This question has been asked several times here about interpreted language or R but I don't find anything about a compiled language, specifically C#.
According to what I read it seems to be negligible but it still induces a very little slowdown on interpreted language: Do comments slow down an interpreted language?
What about compiled languages?! do they slow down only the compilation process but not execution?
Yes, each comment that you write will make the compilation slower, because the compiler has to read more text.
So no, comments do not slow down the programs at run-time. Note: Interpreters that do not use some other inner structure to represent the code other than text, ie a syntax tree, must do exactly what you mentioned.
No it does not effect performance. As most of the programming languages compile or interpret code and comments are skipped as computer has nothing to do with comments.
Whitespaces and comments increase the size of the JavaScript file, which slows down the actual downloading of the file from the server - minification is the process of stripping unnecessary characters from a JavaScript file to make it smaller and easier to download.
When you compile the program, the compiler actually does:
As for comments they should be extracted as tokens on Lexical Analysis stage and dropped out on Syntax Analysis (parsing) stage. So you can slow down the compiler, but not the code generated.
Many interpreted languages often do first two or three stages and only then execute, so comments don't necessarily slow down even interpreted languages.
Compilers have these phases:
In Lexical analysis, comments are skipped, it is basically like you didn't write anything.
So no, they do not affect performance in any way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With