this post was submitted on 02 Oct 2023
1751 points (98.0% liked)

Programmer Humor

32467 readers
1065 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] herr@lemmy.world 3 points 1 year ago* (last edited 1 year ago)

Imagine getting hung up on something as trivial as a switch statement. Which is more poignant, I ask you?

switch(var){
   case 1: 
      <code>;
      break;
   case 2: 
      <code>;
      break;
   case 3: 
      <code>;
      break;
   default:
      <code>
}

or

if var == 1:
   <code>
elif var == 2:
   <code>
elif var== 3:
   <code>
else:
    <code>

The performance difference is absolutely negligible, but now you've introduced a bunch of unnecessary indentation (for no benefit) that's gonna get hard to read should you even add a little bit of additional logic, and a footgun with all the break; s.

And then in JS the syntax for the case-blocks isn't even consistent with the rest of the language.