Skip to main content
expanded answer in response to comments
Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

Some possible reasons for using short variable names are:

  • Brevity: short variable take less time to type.
  • Following Textbooks: similar to the discussion in this software engineering SO post on short variable names, some shader code might be written using formulas from textbooks (physics, optics, math, etc) and it's common for such formulas to use abbreviations & established variables (such as often using theta for angles). Academic papers often share this trait as well (some cutting edge techniques often start research presented in places like SIG Graph). Some programmers may carry this style over to other parts of the code.
  • Historical Precedent: originally, shaders were essentially written a GPU specific assembly language. Assembly code is very terse. It's possible that some of the this style has been adopted by subsequent generations.
  • (Perceived) Memory Efficiency: As discussed here, in some cases (very old compilers, and certain interpreted languages), longer variable names take up more memory than shorter ones. Even if this doesn't apply to modern shaders, some programmers may be following cargo cult programming practices.

In my professional opinion, the only reason that holds up is the textbook/other source example and then only under certain circumstances. In the event that your developing code from other formulas presented elsewhere, using the same variable names can make it easier to compare your translation to the original. After having done that & in the other cases that come to mind, the correctness, clarity & maintainability should be focus for producing well crafted code.

Some possible reasons for using short variable names are:

  • Brevity: short variable take less time to type.
  • Following Textbooks: similar to the discussion in this software engineering SO post on short variable names, some shader code might be written using formulas from textbooks (physics, optics, math, etc) and it's common for such formulas to use abbreviations & established variables (such as often using theta for angles). Some programmers may carry this style over to other parts of the code.
  • Historical Precedent: originally, shaders were essentially written a GPU specific assembly language. Assembly code is very terse. It's possible that some of the this style has been adopted by subsequent generations.
  • (Perceived) Memory Efficiency: As discussed here, in some cases (very old compilers, and certain interpreted languages), longer variable names take up more memory than shorter ones. Even if this doesn't apply to modern shaders, some programmers may be following cargo cult programming practices.

Some possible reasons for using short variable names are:

  • Brevity: short variable take less time to type.
  • Following Textbooks: similar to the discussion in this software engineering SO post on short variable names, some shader code might be written using formulas from textbooks (physics, optics, math, etc) and it's common for such formulas to use abbreviations & established variables (such as often using theta for angles). Academic papers often share this trait as well (some cutting edge techniques often start research presented in places like SIG Graph). Some programmers may carry this style over to other parts of the code.
  • Historical Precedent: originally, shaders were essentially written a GPU specific assembly language. Assembly code is very terse. It's possible that some of the this style has been adopted by subsequent generations.
  • (Perceived) Memory Efficiency: As discussed here, in some cases (very old compilers, and certain interpreted languages), longer variable names take up more memory than shorter ones. Even if this doesn't apply to modern shaders, some programmers may be following cargo cult programming practices.

In my professional opinion, the only reason that holds up is the textbook/other source example and then only under certain circumstances. In the event that your developing code from other formulas presented elsewhere, using the same variable names can make it easier to compare your translation to the original. After having done that & in the other cases that come to mind, the correctness, clarity & maintainability should be focus for producing well crafted code.

Source Link
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

Some possible reasons for using short variable names are:

  • Brevity: short variable take less time to type.
  • Following Textbooks: similar to the discussion in this software engineering SO post on short variable names, some shader code might be written using formulas from textbooks (physics, optics, math, etc) and it's common for such formulas to use abbreviations & established variables (such as often using theta for angles). Some programmers may carry this style over to other parts of the code.
  • Historical Precedent: originally, shaders were essentially written a GPU specific assembly language. Assembly code is very terse. It's possible that some of the this style has been adopted by subsequent generations.
  • (Perceived) Memory Efficiency: As discussed here, in some cases (very old compilers, and certain interpreted languages), longer variable names take up more memory than shorter ones. Even if this doesn't apply to modern shaders, some programmers may be following cargo cult programming practices.