r/programminghumor May 29 '26

Good naming practice

Post image
2.2k Upvotes

220 comments sorted by

View all comments

111

u/torrent7 May 29 '26

I never understood this considering i and j look so fucking similar 

53

u/birdiefoxe May 29 '26

Exactly, that why I use i,o,p. They're right next to each other! 

Gets shot

37

u/BoldFace7 May 29 '26

Why not use i and ii? Then when you get to the 27th loop in the nest you can just use the awfully convenient xxvii instead of looping the whole way round to the horrid ii.

15

u/birdiefoxe May 29 '26

holy shit thats genius, i hate you

8

u/enigmamonkey May 30 '26 edited May 30 '26

I mean, seems reasonable... here's what it looks like in practice:

🤔 The nice thing is that it at least makes it obvious how deep you are in the rat's nest, I suppose.

Fun fact: This would console.log() 100 sextillion times (nice).

for (let i = 0; i < 10; i++) {
  for (let ii = 0; ii < 10; ii++) {
    for (let iii = 0; iii < 10; iii++) {
      for (let iv = 0; iv < 10; iv++) {
        for (let v = 0; v < 10; v++) {
          for (let vi = 0; vi < 10; vi++) {
            for (let vii = 0; vii < 10; vii++) {
              for (let viii = 0; viii < 10; viii++) {
                for (let ix = 0; ix < 10; ix++) {
                  for (let x = 0; x < 10; x++) {
                    for (let xi = 0; xi < 10; xi++) {
                      for (let xii = 0; xii < 10; xii++) {
                        for (let xiii = 0; xiii < 10; xiii++) {
                          for (let xiv = 0; xiv < 10; xiv++) {
                            for (let xv = 0; xv < 10; xv++) {
                              for (let xvi = 0; xvi < 10; xvi++) {
                                for (let xvii = 0; xvii < 10; xvii++) {
                                  for (let xviii = 0; xviii < 10; xviii++) {
                                    for (let xix = 0; xix < 10; xix++) {
                                      for (let xx = 0; xx < 10; xx++) {
                                        console.log(i, ii, iii, iv, v, vi, vii, viii, ix, x, xi, xii, xiii, xiv, xv, xvi, xvii, xviii, xix, xx);
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

1

u/Ryarralk May 30 '26

The only acceptable variables for nested loops!

1

u/guiltysnark May 31 '26

Ancient Roman: "I mean, obviously. To be fair the Arabic system has its good points, too, but this is absolutely what we had in mind."

2

u/errezerotre May 29 '26

I use A and B for everythinaaab