if we have too much commented code in .net would it effect code performance?
Comments and whitespaces are not not compiled by any compiler and are ignored, so these two have no effect on performance.
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.
There are two main reasons why this can happen: Too many times comments are just an excuse for writing bad code. Instead of writing good code, programmers believe that if they write dirty code with some weird hacks, and describe it with a 5 lines of comments — that the code is readable and well written.
What are the negatives of HTML comments? worsens the UX - even not visible, the HTML comments are part of the DOM tree and increase the number of DOM elements. This, in turn, affects the quickness and responsiveness, also leads to slower CSS selectors and DOM manipulation.
Almost all compiled languages discard comments when creating the resulting binary (this includes all .NET languages, Java, unmanaged languages, etc).
Interpreted languages (like JavaScript, when not compiled), may have a tiny performance hit, since the interpreter has to skip over the comments. But it's so small you shouldn't concern yourself with it.
The real question is why you need to have so many comments? An excess of comments can hurt readability and thus maintainability. Comments should be concise, precise and succinct, and should not state the obvious (e.g. i++; // increment loop counter
). They should help explain why something was done (edge cases, hacks), describe how and when to use the code (API documentation) or explain the gist of what is going on in the method or class. If the code isn't readable, try refactoring it. If there are complex business processes, describe them in depth in the appropriate project documentation, not in code comments. Also, don't leave large amount of comment-out code, it hurts readability even more. If it is no longer needed, remove it - the removed code should exist in your source control anyway.
No at all. Resulting IL bytecode will be same, with or without comments, with or without indentation, etc.
Common interpreted languages will get effected due to more comments in code. But c# is a compiled language and comments do not effect the execution.At the start ofcompilation, compilers removes all lines beginning with the // characters and also the text between the /* and */ delimiters.So there will be no performance degradation.
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