EightyColumns - jljusten/tianocore GitHub Wiki
EDK II uses a code style that limits code line length to 80 columns.
Although many developers have editor environments that display lines longer than 80 columns, there are still various arguments in favor of limiting the line length to 80 columns.
-
Readability: As with conventional typography, when lines grow too long, the readability suffers. References for typography generally recommend a line length limit of 60 characters. (Also, note that github limits the line width of the wiki.)
Although code and typography line lengths are not the same, the typography rule still can be useful in understanding how long line lengths in code negatively impact the code readability.
-
Accessibility: As discussed on the emacs-wiki, some developers may require a larger font to read the code. When a larger font is used, the longer line lengths are even more of an issue for readability.
-
Tradition: Although some projects do not require a limit to line lengths, when a length is called out, it is most commonly 80 columns.
Some other projects that have this limit:
- Python: https://www.python.org/dev/peps/pep-0008/#maximum-line-length
- Note, many python based projects simply follow the pep-0008 style
- QEMU: https://github.com/qemu/qemu/blob/v3.1.0/CODING_STYLE#L32
- Mesa: https://mesa3d.org/codingstyle.html
- Git: https://github.com/git/git/blob/v2.21.0/Documentation/CodingGuidelines#L185
- Linux: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v5.1-rc3#n81
- Python: https://www.python.org/dev/peps/pep-0008/#maximum-line-length
-
Code patches: If a long code line is changed, it can be difficult to see the change in the patch file.
With shorter line lengths, a change is more likely to show only the actual changed code. For example, an
if
condition with multiple tests. It is possible that when broken into multiple code lines, the condition that is changing may be the only item shown in the patch.