If you have any tips regarding golfing in Sesos, a language made by Dennis, and nobody else has covered them yet, please post them here! Only one tip is allowed per answer. Your tip should be at least somewhat specific to Sesos itself, and not just brainfuck. If your tip is relevant to brainfuck in general, you should post it here instead.
2 Answers
What's different in Sesos?
Golfing in Sesos is similar to golfing in brainfuck in that it has limited control flow, and that you have to grapple with the specifics of memory layout.
However, this does not mean you should write brainfuck code first and then translate it instruction-by-instruction to Sesos!
Here are some things that are different:
- You barely pay for repeated commands. For example,
add 1
is a 1-byte Sesos program.add 100
is a 3-byte Sesos program.add 1000
is still a 3-byte Sesos program. This means that things that would have been prohibitively expensive in brainfuck (e.g.++++++++++
) are fine in Sesos. - Unless you have
set mask
on, cells are not 8-bit unsigned integers—they are signed bignums. This means that you can do things like store an offset into an array as a cell without having to worry about the possibility of the array being more than 256 elements and causing overflow. - Control flow is a bit more flexible: you have do-while loops that are guaranteed to execute at least once (with the use of
nop
). You also havejne
, which is the equivalent of,]
in a single instruction.
Omit what you can
In Sesos, you can omit some instructions, specifically:
- You can omit a
jmp
instruction at the start of the program, if its corresponding exit point is not omitted. - You can omit a
jnz
instruction at the end of the program, if its corresponding entry point is not omitted.
This example program prints numbers from 10
to 1
:
set numout
add 10
jmp
sub 1
put
jnz
However, we can reduce the SBIN file's size by a triad, therefore potentially reducing it by 1 byte, by removing the jnz
:
set numout
add 10
jmp
sub 1
put