The beads in my analogy are individual base pairs (add, store, etc.). Though mutations can work on the codule level as well. So codules can be duplicated, deleted, randomly inserted, etc. But most of the "work" of evolution will be inside the codules doing traditional mutations.
Yes, the main codule is like the int main in C.
I might also create some "system" codules, that are called specially for certain events. They'd operate sort of like a callback. For eyes, for instance, I'm thinking that each object visible to the bot causes a special "vision" codule to fire. Each call of the vision codule would happen by the system, and would change the sysvars sent to the vision codule. After the vision codule has been fired for each visible object, the main codule gets to run. To keep with the C analogy, these system codules are sort of like interrupts. I still have to really think through the implications, but it makes a lot of sense to me right now. The only real downside is that it hard codes some really high level structure to the DNA. I'd be happier if the DNA didn't require imposed high level structure. But I can't think of a nice way to do something like:
given visible objects, sort based on distance
for each visible object in sorted list
call appropriate reaction codule
with my current plans for DNA. The main problem is the foreach type loop. I really don't want to expose looping capability to the DNA, not even finite loops where there's definitely a finite number of iterations. It's far too easy for evolution to invent some sort of nest loop that would eat through performance. If you had 3 loops from 1 to 1000, nested in side each other to form a trivial O(n^3) algorithm, it'll take about 3-5 seconds to run per bot per cycle. With the way the DNA currently works, even with plans for Codules, there's a direct link between DNA size and execution time.
I could make it a language rule that loops can't be nested (have nested loops fizzle), but that seems overly arbitrary. And it would make debugging DNA potentially confusing since the rule would have to be enforced across codule boundaries.