10
\$\begingroup\$

In some languages using a compiler flag might significantly shorten the source file, by making the compilation command longer. Should we make inclusion of the character count of the flag in the total character count, mandatory?

EDIT: As mentioned by Chris Jester-Young the -D compiler flag for C/C++ could be game breaking if not included in the count. You could potentially define your whole program in the command line and have a source file that is only 1 character long.

\$\endgroup\$
2
  • \$\begingroup\$ Can you provide example or link to it? \$\endgroup\$
    – Nakilon
    Jan 27, 2011 at 22:58
  • \$\begingroup\$ What about interpreter arguments? perl/ruby -p for example. In Ruby's case you can also write it into the shebang and Ruby will gladly go ahead and parse that itself. \$\endgroup\$
    – Joey
    Jan 29, 2011 at 20:07

3 Answers 3

11
\$\begingroup\$

I think so. Otherwise, people can embed huge amounts of code in a C submission by using -D to define lots of macros "for free".

\$\endgroup\$
2
  • 8
    \$\begingroup\$ I don't know if this justifies a general rule, but this particular case would count as cheating in my mind. \$\endgroup\$ Jan 27, 2011 at 23:55
  • \$\begingroup\$ @dmckee: Fair point. +1 \$\endgroup\$ Jan 27, 2011 at 23:58
2
\$\begingroup\$

The big difficulty here follows from defining "non-standard". Presumably I am allowed gcc --std=c99 because that is standard, but what if I want -funsigned-char? The later tells gcc to use a valid (i.e. acceptable to the standard) interpretation of the source, just not the one gcc usually uses.

In or out?

And gcc has a lot of those kinds of options.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ If it feels like cheating and it looks like cheating and it smells like cheating and it tastes like cheating and it sounds like cheating... \$\endgroup\$
    – gnibbler
    Apr 29, 2011 at 5:27
2
\$\begingroup\$

Bottom line - I think we should disallow -D (or at least count its chars), and allow all the rest without counting.

-D can be used to write 1-byte programs, so it must be either disallowed or counted.
I prefer to disallow it, to discourage people from replacing #define with -D (we want short programs, not short programs + compilation lines).
-include should be treated the same (like -D, it replaces things which should have been in the source).

A simple case is -std=c99, -ansi etc. I think it's agreed that these don't need to be counted. You might as well count 3 chars for gcc (but I have c as an alias...)

Other flags, however, don't offer a clear way to save chars. They may end up useful in some circumstances, but they don't automatically shorten the program.
Finding flag that allows you to shorten your program is often quite creative. So I think it should be encouraged. If anyone finds a way to save a couple of chars using -fallow-parameterless-variadic-functions, I'm in favor. Adding 40 bytes makes it useless.

Some cases I actually saw on this site:

  1. Using -O2 to optimize tail recursion:
    I think it should be allowed for no charge. Also note that in most cases, the program could work without it, given a deep enough stack.

  2. -msse3 -O3 -ffinite-math-only used in this answer:
    The program works without the flags, just terribly slowly. I see no reason to charge for them.

  3. -nostartfiles used in this answer:
    The point here was not using the letter a in the program. But this letter does appear in the flag, so if counting the flags you should count the a.
    I really don't know about this one. It surely is creative.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .