On herding CATSS, or how to port anything to Go
with minimal effort on your part.
Chaotic, Artificial, Temperamental Slackerbots-requiring-Supervision
(CATSS) are amazing at debugging, but super lazy and
will leave you with plenty of half-baked code unless
given a strong lead and constant, precise feedback.
Fortunately both can be supplied with a little
hashing and a lot of printfs.
Having ported a large C and a large Python project to
Go by herding CATSS, I can generalize my current method:
The fact that you have a working program (in C or
Python or whatever) is a huge thing. We will use this as
a runnable specification to obtain massive leverage
over the wayward slacker-bots.
a) instrument the exiting code base with
prints at every basic block; your CATSS can do
this for you. Python's "if __debug__:" statements are eliminated
at compile time with zero overhead (when run with -O).
Nice. C can use macros. Go uses build tags to switch
off prints for production builds.
b) thread a Merkle-chain of cryptographic hashes of
your latest data/state through your program, and
print the first 8 bytes of your hash in each of
the above basic block prints. Again, this is an easy task
for the CATSS.
c) have your AI do the port, and then run both programs
in a loop comparing at every basic block the current
execution and data, stopping after the first divergence.
d) Have your AI repeatedly fix its porting bugs (each
divergence point) until all of your corpora of input examples have taken
the same execution paths and obtained the same
data at each print point. This loop can be automated.
e) Write fuzz tests. Grammar driven fuzz tests are
my favorite for language-ish projects. The AI
are decent at writing them. Run them for a couple
of days to harden your port. CATSS of recent vintage
are amazing at debugging and conforming one
code bases logic to another.
Enjoy your shiny new Go port's bit-for-bit exact reproduction
of the original processing.
- Jason