top | item 37440693

(no title)

hunson_abadeer | 2 years ago

It feels like you're making a bad-faith argument here. You can implement 'yes' in a straightforward way in a couple lines of C, too.

  main(int argc, char** argv) {
    while (1) {
      if (argc > 1)
        for (int i = 1; i < argc; i++) printf("%s%c", argv[i], (i == argc - 1) ? '\n' : ' ');
        else puts("y");
    }
  }
The point other folks are making is that it's written differently for a reason. Maybe not a reason that's important, but at the very least, let's try to compare apples to apples.

discuss

order

38|2 years ago

I don't see include, which means you're ignoring warnings aren't printing them in the first place. Also testing against a number instead of boolean. Also you have a horrible hack instead of proper flag parsing. And you're also abusing brace elision just to reduce LOC. And again abusing ternary syntax for the same reason.

mturmon|2 years ago

If you start with code golf, as you did, then this is where you end up. The only way to win is not to play?

moomin|2 years ago

I mean, yes, go has proper flag parsing as part of the standard library and C doesn’t. Yes that’s going to make a line count difference but it’s also why code golf arguments are pointless.