Comments weigh the code in C#?

Asked

Viewed 174 times

4

I use the C# language with Unity Engine and, as several programmers have access to the code, we usually comment a lot so that everyone can understand what is there. I saw in other responses recommendations to use a mini-scanner but they were always related to languages for web development. Would that be useful/apply to C# in this case? How can I be optimizing this part?

4 answers

6

Viu that, right? Although there say that hardly makes a difference, the context is not web but interpreted languages.

Minification is required for the transmission of the code. The gain is too small for the compilation that takes place in the client. The only reason to minify is that the source travels through the network. With the Webassembly this problem ends because the code is compiled before.

C# is compiled, then even weigh to make a Parsing, because it is more text to evaluate, but it is something tiny, despicable, does not even tickle in the compiler. For the execution the comment has zero weight by all the ways it analyzes since they disappear altogether.

C# has other things that go to the execution that weigh and people do not realize :)

  • You commented on other issues weighing that we don’t usually account for, some of these things would be in the way of writing the code?

  • @dotSonic yes..

  • could you give me an example? or more than one. or this is not subject to speak in the comments?

  • Exactly, there are several, it is a list becomes complicated to list, because almost the list has no end, I wouldn’t even know how to classify the main ones. I gave a very incomplete talk where I had hundreds of items, and pretty much just talked about C#, don’t even get into . NET :D I am always posting things that can help my social networks (in my profile).

5

Comments are ignored by compilers/transpilators at the time of lexical analysis by when code is compiled comments are always passed forward, not even in binary executable files.

The reason why minification is used in web development is that the client transfers the file .css, .js, etc and then reads the file locally. All comments, extra whitespaces and blank lines are equally ignored however the client has already downloaded the file with them, spending bandwidth and space.

The minification then serves to make sure that the files in the web development follow only with what is really necessary for the page and, in some cases, get to the point of changing the names of the variables to use less characters.

Useful resources:

3


Like C# is usually used in compiled form, the compiler himself leaves comments aside, that is, they do not interfere with the size or performance of your program.

Comments are definitely not something you need to worry about in this language, but there are numerous other ways to optimize your worksheet C#. In that link has some tips worth checking out.

2

As C# is compiled, comments are ignored by the compiler, meaning there is no loss of performance. Take a look at the logic of your system, maybe the way it was written is weighing on.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.