7

during a programming introduction course on loops my pals started writing `for` loops instead of `while` loops like so:

`for (;expression;) {}`

spent weeks explaining why it's wrong. needless to say, they still do it. had to hinder myself from ripping my hair off my head

Comments
  • 0
    actually thats the right way ;)
  • 0
    Both ways are fine..
  • 1
    It's not technically wrong, just harder to read. And anything that reduces code readability is crappy code
  • 1
    @spl0 i need an official code bible that says that it's wrong. it's the same for a compiler, which killed my argument against them, but too many bells are ringing in my head when i see that syntax
  • 3
    @applejag read Clean Code by Robert C. Martin.
    Closest thing to a Code Bible that exists on this earth
  • 1
    C has used for(;;) for a while(1) loop for as long as I can remember....

    It doesn't look odd to me.
  • 1
    what if you were told that loops are wrong?
  • 1
    @debug lol yeah use `goto` all the way?
  • 0
    seems like people forget functional programming
  • 1
    @applejag you can use stuff like recursion, internal iterators, higher-order functions like map, etc. that was a joke btw as a loop is a loop and you're right about what you posted :P
  • 0
    That's a creepy expression ;) for you. punpunpunpun
Add Comment