I'm going to be starting a project (a programming challenge) where the compiled source code must be under a certain amount of bytes, and I already know that I am going to be having trouble meeting that criteria.

Therefore, I am going to have to take certain measures to reduce the size of my code that I would not normally take in normal code that wasn't a challenge.

Is this on-topic because it is reducing the code size. Or, because I will have had to take abstract measures, is it considered golfing?

The above text is very specific: more generally, my question is "What is the difference between golfing and reducing code size?".

Where does Code Review draw that line between a user that is actually looking for their code to be golfed and a user that is actually looking for their code size to be reduced.

Note that when I say "golfing", I mean golfing the compiled output: this does not mean to obfuscate and compact the textual source code itself.

  • \$\begingroup\$ Why will you have that compiled-code-size requirement? \$\endgroup\$ Commented Aug 18, 2015 at 11:01
  • \$\begingroup\$ @SimonAndréForsberg It's a personal challenge. And, because the code needs to be bootloader-sized. By the way, welcome back! \$\endgroup\$
    – SirPython
    Commented Aug 18, 2015 at 13:34
  • \$\begingroup\$ Briefly, I don't think trying to reduce the size of the executable because it needs to fit inside of x Kb on a bootloader is off topic. Will try to follow up with my reasoning later. \$\endgroup\$
    – RubberDuck
    Commented Aug 22, 2015 at 16:45

2 Answers 2


Reducing the size of your program in terms of character-count, and reducing the size of your compiled executable, in byte-count, are different things.

This is not the only criteria, but, for example, The two lines of code that follow are probably the same size, when compiled:

for (int cursor = 0; cursor < dataLimit; cursor++) {
    sum += data[cursor];

for(int a=0;a<l;a++)s+=d[a];

One is golfed to minimize program size, the other is readable.

Golfing is not normally about executable size, but program size.

It's true that often, golfed code can also be smaller executables, but that logic is not a given.

  • \$\begingroup\$ Reading this, it says, "Minimizing the size of your executable is about reducing the number of instructions and has nothing to do with how many lines (or characters) are in your source code file. Using code-size-optimization for these questions is arguably misleading. Moreover, outside deploying to embedded systems, worrying about the size of your executable isn't something that gets done any more these days. And if it is something you're worried about, your question isn't likely to be a good fit for Code Review." What are your thoughts? \$\endgroup\$
    – SirPython
    Commented Aug 18, 2015 at 2:39

Therefore, I am going to have to take certain measures to reduce the size of my code...

Correction: you need to minimize the compiled output, i.e. the output that your OS/machine understands, not us humans. Unfortunately, I think that means it's not really within the scope of CR... It can still be within the scope if certain source code optimizations can lead to smaller binaries, e.g. cutting the number of loops, eliminating function calls etc.

  • \$\begingroup\$ The optimizations would be source code optimizations that lead to smaller binaries, but they aren't changes that I would make under normal circumstances where I do not have a limited size. \$\endgroup\$
    – SirPython
    Commented Aug 18, 2015 at 1:37
  • \$\begingroup\$ @SirPython perhaps you'll like to discuss it in 2nd monitor first then? :) My personal opinion is that at least this is not totally about golfing, i.e. minifying source code, that would be off-topic without a doubt. Maybe there's a specific angle we can work with here... \$\endgroup\$
    – h.j.k.
    Commented Aug 18, 2015 at 1:45
  • \$\begingroup\$ Shall we talk here? \$\endgroup\$
    – SirPython
    Commented Aug 18, 2015 at 1:51

You must log in to answer this question.

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