Does variable name length matter for performance C#?

前端 未结 6 2323
别那么骄傲
别那么骄傲 2021-02-18 22:28

I\'ve been wondering if using long descriptive variable names in WinForms C# matters for performance? I\'m asking this question since in AutoIt v3 (interpreted language) it was

6条回答
  •  花落未央
    2021-02-18 22:43

    No, once compiled the original variable names are no longer used. Size of variable names should have a very small affect on compilation time, but not on execution time.

    Interpreted languages are affected a little bit by long variable names. Long names are more to read, store and lookup each time they run, but the affect should be very small. Latency in reading/writing to a disk or even the screen should far exceed the delay caused by longer variable names.

    If execution time is the problem, then more execution efficient algorithms will almost certainly provide much greater returns than shortening variable names. If memory pressure is the problem, memory efficient algorithms will again likely save much more than shortening variable names. If the solution is algorithmically as tight as it can be, it is time for a new language.

    There are few absolutes in programming, but I feel confident in saying shortening variable names in source code for performance reasons is ABSOLUTELY the wrong decision EVERY time.

提交回复
热议问题