A complete rewrite of EC Recombination! Episode 65 of Unhindered by Coding
Channel: Unhindered by Coding!
Date: 27/01/2023

We did a lot with the `Recombinator` trait today, including rewriting it once, and realizing at the end that we'll have to rewrite it again. :-)

"…plan to throw one away; you will, anyhow" – Fred Brooks in _The mythical man month_

(It's worth noting, though, that we're not throwing away the whole system, and are instead doing something far more incremental and agile.) 

Having the `Recombinator::recombine()` method take a `Population` and `Selector` as arguments really turned out to be a bit of a mess. There was way too much unnecessary dependency, and it made writing tests _super_ ugly. So we removed those, and set it up to take in a fixed (constant) length array of genomes. That worked great, but I'm pretty sure it'll break when we try to write `Pipeline`. In Rust `[T; 1]` is a different type than `[T; 2]`, and we can't have things with different types in a `Vec`. So if `Pipeline` takes a `Vec(Recombinator(…))`, it's going to require that all those `Recombinator`s have the same type. If we stick with arrays, they won't. So I think we'll have to switch to having `recombine()` take `Vec(G)` instead of `[G; NUM_PARENTS]`. Sigh.

Unfortunately we don't yet have great refactoring tools for Rust, so these changes do take a fair bit of work to push out through the whole system. If I wanted to do more "serious" refactoring, I wouldn't completely replace one trait with another, but would introduce a new trait, and have a way of moving between them so we could update the uses in a more incremental fashion. Since no one's using this but me at the moment, though, it's not really necessary to work that incrementally.

Learned about using the `Not` trait, which was cool. I don't think our use of it will actually remain, because I think we'll need a `Mutable` trait that generalizes that idea, but it was neat to know that it was there.

================

In the first few months of 2023 (at least to mid-March) I'm streaming at https://twitch.tv/NicMcPhee four times a week:

* Tuesday: 10am-noon CST
* Wednesday: 7-9pm CST
* Saturday: 2-4pm CST
* Sunday: 10am-noon CST

The Tuesday and Sunday slots will be focusing on building the EC system in Rust and on the ice-repos webapp. The Wednesday and Saturday slots will be going through the Advent of Code 2022 puzzles/exercises.

Thanks for watching!