code_indentation.xhtml 6.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. h t t :: / / t /
  4. h t t :: // // t //
  5. h ttttt ttttt ppppp sssss // // y y sssss ttttt //
  6. hhhh t t p p s // // y y s t //
  7. h hh t t ppppp sssss // // yyyyy sssss t //
  8. h h t t p s :: / / y .. s t .. /
  9. h h t t p sssss :: / / yyyyy .. sssss t .. /
  10. <https://y.st./>
  11. Copyright © 2017 Alex Yst <mailto:copyright@y.st>
  12. This program is free software: you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation, either version 3 of the License, or
  15. (at your option) any later version.
  16. This program is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. GNU General Public License for more details.
  20. You should have received a copy of the GNU General Public License
  21. along with this program. If not, see <https://www.gnu.org./licenses/>.
  22. -->
  23. <!DOCTYPE html>
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <base href="https://y.st./en/opinion/code_indentation.xhtml" />
  27. <title>Code indentation &lt;https://y.st./en/opinion/code_indentation.xhtml&gt;</title>
  28. <link rel="icon" type="image/png" href="/link/CC_BY-SA_4.0/y.st./icon.png" />
  29. <link rel="stylesheet" type="text/css" href="/link/basic.css" />
  30. <link rel="stylesheet" type="text/css" href="/link/site-specific.css" />
  31. <script type="text/javascript" src="/script/javascript.js" />
  32. <meta name="viewport" content="width=device-width" />
  33. </head>
  34. <body>
  35. <nav>
  36. <p>
  37. <a href="/en/">Home</a> |
  38. <a href="/en/a/about.xhtml">About</a> |
  39. <a href="/en/a/contact.xhtml">Contact</a> |
  40. <a href="/a/canary.txt">Canary</a> |
  41. <a href="/en/URI_research/"><abbr title="Uniform Resource Identifier">URI</abbr> research</a> |
  42. <a href="/en/opinion/">Opinions</a> |
  43. <a href="/en/coursework/">Coursework</a> |
  44. <a href="/en/law/">Law</a> |
  45. <a href="/en/a/links.xhtml">Links</a> |
  46. <a href="/en/opinion/code_indentation.xhtml.asc">{this page}.asc</a>
  47. </p>
  48. <hr/>
  49. <p>
  50. <a href="/en/opinion/XML.xhtml"><abbr title="Extensible Markup Language">XML</abbr></a> |
  51. <a href="/en/opinion/code_indentation.xhtml">Code indentation</a> |
  52. <a href="/en/opinion/free_culture.xhtml">Free culture</a> |
  53. <a href="/en/opinion/free_software.xhtml">Free software</a> |
  54. <a href="/en/opinion/holidays.xhtml">Holidays</a> |
  55. <a href="/en/opinion/misuse_of_words.xhtml">Misuse of words</a>
  56. </p>
  57. <hr/>
  58. </nav>
  59. <header>
  60. <h1>Code indentation</h1>
  61. <p>The old tabs versus spaces argument</p>
  62. </header>
  63. <p>Honestly, how you choose to indent your code is up to you. Some people use tabs, some people use spaces, and either option if fine. However, it drives me bonkers when people argue that everyone needs to indent using spaces. Really? Spaces are a horrible way to indent compared to tabs.</p>
  64. <h2>Tabs are a single character</h2>
  65. <p>When arguing that people need to use spaces to indent, it&apos;s often said that a <strong>*certain number*</strong> of spaces should be used. Uniformity is important, after all. But what could be more uniform than indenting using tab characters? With spaces, not only do you need to decide to use spaces instead of tabs, you need to decide how many spaces to use. With tabs, it&apos;s easy. No one indents using multiple tab characters because a tab character already takes up as much space as you tell your editor to make it take up.</p>
  66. <h2>What is the tab character even for?</h2>
  67. <p>Spaces are word separators. They&apos;re not meant for indentation. Do you know what character <strong>*is*</strong> meant for indentation? It&apos;s the tab character! Why not use the tab character for what it&apos;s meant for instead of ignoring it altogether?</p>
  68. <p>Spaces make it easier to line things up. When trying to line up variable names in code or when trying to put Unicode art in your source code comments, spaces are great. However, tab characters have a semantic meaning. When indenting code, tabs are the way to go.</p>
  69. <h2>Conclusions</h2>
  70. <p>I don&apos;t care how you want to indent your code. However, please stop lecturing me about why I need to use spaces instead of tabs. You&apos;re wrong. If I&apos;m not in your employ and not making pull requests to your code, I&apos;ll indent however I please. And how I please is the only way that makes sense to me: using tab characters.</p>
  71. <hr/>
  72. <p>
  73. Copyright © 2017 Alex Yst;
  74. You may modify and/or redistribute this document under the terms of the <a rel="license" href="/license/gpl-3.0-standalone.xhtml"><abbr title="GNU&apos;s Not Unix">GNU</abbr> <abbr title="General Public License version Three or later">GPLv3+</abbr></a>.
  75. If for some reason you would prefer to modify and/or distribute this document under other free copyleft terms, please ask me via email.
  76. My address is in the source comments near the top of this document.
  77. This license also applies to embedded content such as images.
  78. For more information on that, see <a href="/en/a/licensing.xhtml">licensing</a>.
  79. </p>
  80. <p>
  81. <abbr title="World Wide Web Consortium">W3C</abbr> standards are important.
  82. This document conforms to the <a href="https://validator.w3.org./nu/?doc=https%3A%2F%2Fy.st.%2Fen%2Fopinion%2Fcode_indentation.xhtml"><abbr title="Extensible Hypertext Markup Language">XHTML</abbr> 5.1</a> specification and uses style sheets that conform to the <a href="http://jigsaw.w3.org./css-validator/validator?uri=https%3A%2F%2Fy.st.%2Fen%2Fopinion%2Fcode_indentation.xhtml"><abbr title="Cascading Style Sheets">CSS</abbr>3</a> specification.
  83. </p>
  84. </body>
  85. </html>