L'indentation

Espace ou Tabulation ?

Les espaces aident à la mise en page


<section>
<h1>Ceci est un titre</h1>
<ul>
<li><strong>PHP</strong>, PSR "Code MUST use 4 spaces for indenting, not tabs."</li>
<li><strong>JavaScript</strong>, Prettier 2 espaces</li>
<li><strong>Python</strong>, PEP8 "Use 4 spaces per indentation level."</li>
<li><strong>Linux kernel</strong>, <a href="https://www.kernel.org/doc/html/v4.10/process/coding-style.html">8 espaces</a></li>
<li><strong>Golang</strong>, Tab</li>
<li><strong>Makefile</strong>, Tab</li>
</ul>
<p class="small">
<a href="http://www.opimedia.be/DS/languages/tabs-vs-spaces/">The Bible of Tabs vs Spaces Holy War</a>
</p>
</section>
        

<section>
    <h1>Ceci est un titre</h1>
    <ul>
        <li><strong>PHP</strong>, PSR "Code MUST use 4 spaces for indenting, not tabs."</li>
        <li><strong>JavaScript</strong>, Prettier 2 espaces</li>
        <li><strong>Python</strong>, PEP8 "Use 4 spaces per indentation level."</li>
        <li><strong>Linux kernel</strong>, <a href="https://www.kernel.org/doc/html/v4.10/process/coding-style.html">8 espaces</a></li>
        <li><strong>Golang</strong>, Tab</li>
        <li><strong>Makefile</strong>, Tab</li>
    </ul>
    <p class="small">
        <a href="http://www.opimedia.be/DS/languages/tabs-vs-spaces/">The Bible of Tabs vs Spaces Holy War</a>
    </p>
</section>
        

for(let i = 0; i < 8; i++) {
for(let j =0; j < 8; j++) {
if((i + j) % 2 === 0) {
console.log({i, j})
}
}
}
          

for(let i = 0; i < 8; i++) {
    for(let j =0; j < 8; j++) {
        if((i + j) % 2 === 0) {
            console.log({i, j})
        }
    }
}
          

Les tabulations

  • ✅ Un seul caractère "\t"
  • ❌ Le rendu varie
Mélange Tab / Espace pour l'alignement

Les espaces

  • ✅ Taille fixe (identation et alignement)
  • ✅ Identation et alignement
Espace pour l'alignement & Tabulation

Les espaces

  • ✅ Taille fixe
  • ✅ Identation et alignement
  • ❌ Plusieurs caractères
  • ❌ Accessibilité
Plage braille (PHOTO: EMMANUEL BERROD)

Quoi choisir ?

Bataille Tab vs Espace

  • PHP, PSR "Code MUST use 4 spaces for indenting, not tabs."
  • JavaScript, Prettier 2 espaces
  • Python, PEP8 "Use 4 spaces per indentation level."
  • Linux kernel, 8 espaces
  • Golang, Tab
  • Makefile, Tab

The Bible of Tabs vs Spaces Holy War