# Proposal of new measure for “byte count” in code golf

Byte count is the default winning criterion in code golf. Counting bytes (as opposed to characters) is reasonable, because a language that uses more characters needs more bytes to define them.

Consider the last sentence but "negating both sides": a language that uses less characters needs less bytes to define them. Assume a certain language L only uses the 95 printable ASCII characters. A program written in L consisting of 30 such characters could for example be 256-encoded into 25 bytes (ceil(30*log2(95)/log2(256))). My proposal is that as byte count we use those 25 ("equivalent bytes"), not 30 (let me call those "byte-digits").

It could be argued that the language L should just use a character encoding with 256 characters, which avoids the problem: that way the language exploits all code space provided by each byte-digit, and byte-digits correspond to equivalent bytes. However, there may be reasons in favour of using only the 95 ASCII printable characters. Or it may be the case that the language has already been designed that way.

Consider that someone designs a new language M which simply takes a program in language L and 256-encodes it (with some correspondence between the obtained bytes and a set of 256 characters). So the program with 30 byte-digits in L becomes a program with 25 byte-digits in M. A compiler for M would be very simple: base-256 decode and call language L's compiler. Let's avoid that unnecessary and ugly step.

Of course, the winning criterion can always be defined in the challenge. So instead of "the code with fewest bytes wins" it could say "...multiply your byte count by log2(B)/log2(256) and round up, where B is the number of characters your language uses". I propose to make that the default criterion.

• Related and related (but different) – Luis Mendo Jan 23 '16 at 1:13
• – Addison Crump Jan 23 '16 at 1:16
• @FlagAsSpam But the "handicap" I'm proposing is objective, easy to define and to apply – Luis Mendo Jan 23 '16 at 1:17
• Yes, but it is nonetheless a handicap. :P – Addison Crump Jan 23 '16 at 1:18
• What defines using a character? Most languages' built-ins have only printable ASCII characters in their names, but they can use arbitrary Unicode characters inside strings. – Dennis Jan 23 '16 at 1:58
• @Dennis That's a good point. What's the Jelly approach to that BTW? Can it use Unicode in strings? How does that fit with its special character encoding? – Luis Mendo Jan 23 '16 at 2:02
• Jelly can use exactly 256 different characters in its source code; all others are either aliases or simply ignored. Being able to encode arbitrary Unicode characters in string literals is a planned feature, which will use a custom encoding consisting of those 256 characters. – Dennis Jan 23 '16 at 2:05
• @Dennis I see. Thanks for the explanation! – Luis Mendo Jan 23 '16 at 2:13
• It's trivial for someone to write a transpiler and name the compressed languages. When someone actually does, they'll be valid; however no one seems to want to. – lirtosiast Jan 23 '16 at 3:22
• This seems to be aimed at 𝔼𝕊𝕄𝕚𝕟 :) – Mama Fun Roll Jan 23 '16 at 4:17
• So how do you propose to address the issue that most sane languages can use arbitrary Unicode in strings and some even in variable names? – Martin Ender Jan 23 '16 at 8:59
• @MartinBüttner That's a problem I hadn't thought of – Luis Mendo Jan 23 '16 at 11:05
• Also related (would be a dupe except that the previous one didn't explicitly propose a policy). And this. The topic in general has been discussed many times, and if it were a panacea it would already have been adopted. – Peter Taylor Jan 23 '16 at 13:16

## Do not make it a default

That introduces another barrier to entry for code golf: a scoring method that makes no sense without explanation. Surely not every new user reads meta, so we'd have to explain to each new user who posts a code golf challenge why people's scores don't match up with the number of characters in their source code. (Ignoring for the moment some of the more atypical encodings.)

If you want to post a challenge that uses this as a scoring criterion, go right ahead! But this definitely shouldn't be the default for code golf.

• That's a good point indeed – Luis Mendo Jan 23 '16 at 1:26
• ...except that scores don't match the number of characters anyway – Luis Mendo Jan 23 '16 at 1:28
• @LuisMendo Sure, but submissions in languages which use atypical encodings such as Jelly and Seriously typically link to the definition of a byte for that language anyway. For the majority of languages, barring any insane source compression, the character and byte counts are the same. – Alex A. Jan 23 '16 at 1:33

## Encourage anyone who make new golfing languages also make codepages

This kind of rule changes doesn't really help much for most non-golfing languages. But I can see that the current scoring rule is making new golfing languages less understandable. The problem is, we only need to make use of the 256 codepoints to make programs in a new language shorter, not the CP437 or ISO8859-1 symbols. It's better to also invent a new code page, and attach a program to convert between it and other code pages such as UTF-8. If we can know your answer can be made into those number of bytes in other ways, you don't have to use CP437 or ISO8859-1 just to prove that.

• Oh, yes, we will need one BILLION esolangs! twiddles pinky – Addison Crump Jan 23 '16 at 21:44
• so how to make the codepages? my research tells me it is very hard/ impossible – Bald Bantha May 18 '16 at 21:14
• @BaldBantha Just invent it. You don't need to have it get supported in specific systems... – jimmy23013 May 19 '16 at 4:23

# I think against:

And here's why.

In choosing a programming language in non-CG, you essentially contract yourself to being tied to its advantages and disadvantages. While normally this has to do with efficiency, ease-of-access, and other reasons, here, it means signing yourself to the verbosity of the language.

### So no.

Because it is your choice to use a language and it is your loss if your language is more verbose. If you wish to use a less verbose language, then it is up to you to learn it and use it (or make it), not for a handicap to be put into place to allow for better scores in more verbose languages that you yourself chose.

• I would upvote this, but it implies that challenges are more of competitions between languages, when we have been putting forth a lot of effort to emphasize that they are competitions within languages primarily. – user45941 Jan 23 '16 at 1:40
• @Mego While that is true, there are inherent disadvantages in code size to using one language over another (i.e. bf vs. Pyth). – Addison Crump Jan 23 '16 at 1:42
• @FlagAsSpam That's the point of within-language competition; in nearly all cases Brainfuck won't be competitive against Pyth. – Alex A. Jan 23 '16 at 1:46
• @AlexA. I think this question relates to the "winners" of a competition by those who won overall, though. Within-language doesn't really have to do anything with this question, because the same language will have the same amount of reduction. – Addison Crump Jan 23 '16 at 1:51
• Yes, I was thinking of absolute winners. @Mego: I like this idea of within-language competition. What's this effort you speak about? Can you give me some link? And how is that compatible with the "shortest code" winning criterion? – Luis Mendo Jan 23 '16 at 1:54
• @LuisMendo It is general practice to compete with the language you choose, and winners therein are decided, but not awarded, as victors for their language. They only get the "accepted answer" through the shortest code overall (that's why Pyth/CJam/Retina always "wins"). There's still a competition, though. – Addison Crump Jan 23 '16 at 1:56
• Both competitions are going on in parallel: Some people pick a language and compete against other solutions in the same language. Other people try to find the language that will allow the shortest code for the given challenge. Neither competition excludes the other. – trichoplax Jan 23 '16 at 20:58

## Nah, that's too complicated, and doesn't change much

In particular, what does it accomplish besides making Pyth answers even golfier? Python, for instance, can use all the printable characters, but it will still be verbose even if you make this change.

In practice, pretty much no one is doing the re-encoding that you describe in their answers, so it seems like the specific problem you are addressing is not actually a problem in practice. (I'm not sure I would consider it a problem even if they were.)

• No one is doing the re-encoding that you describe in their answers But that's my point! Let's not require anyone to actually do it, when we just know what the result be. Let's use that result directly. It's like in mathematical proofs: "Let x be the 1000-th prime..." you don't stop the speaker and ask "wait, which number is the 1000-th prime"? You can use that number implicitly because a) you know it exists and b) you know its properties – Luis Mendo Jan 23 '16 at 1:23
• We already don't require anyone to do it...and no one does. You're trying to save people trouble that they don't currently trouble themselves with? – quintopia Jan 23 '16 at 1:45
• My idea is rather to bring small-character-set languages an improvement that they could reclaim anyway, but explicitly achieving it is boring. Continuing with my example, you can accept that there is a 1000th prime, that it is a large number and that it is odd, without actually going through the pain of actually computing it – Luis Mendo Jan 23 '16 at 1:50
• ...so this is really about giving some languages a handicap? What do you hope to accomplish by that? – quintopia Jan 23 '16 at 1:53
• The aim of my proposal is to level languages a bit. To avoid penalizing languages just because they use a smaller character set. – Luis Mendo Jan 23 '16 at 1:56
• As I said... it won't change much. I reckon the only language that could possibly be moved ahead of something like Pyth by this is Vitsy, but again, Pyth will also benefit, and it already wins many, many challenges anyway, so I can't see there being any great benefit from this particular sort of handicap. – quintopia Jan 23 '16 at 2:08
• I see. Does Pyth only use ASCII characters? – Luis Mendo Jan 23 '16 at 2:14