Status report, 5 April 2008
Ah, how time makes fools of us all. From Jan 22:
I’m at a point in development where I can finally say I understand how the whole application is going to fit together. It’s very reassuring - there was always this uncertainty as to how the different modules were going to connect (in particular, how asynchronous events were going to move around.) Now that I have a model I’m happy with, it’s just a matter of ‘colouring in’ what’s left.
I’ve just returned to the SyncDroid code after a few months off and I have that “holy crap, what was I thinking?” feeling. The small-scale implementation is fine, but the object model sucks. I can’t figure out what should be talking to what. Comments that I’ve left in the code indicate that I did have a plan, but when the journaller code is making merge decisions and the merge code is storing data on the disk, it’s a sign that something has gone wrong.
So I’m refactoring it all. Again.
I have a new plan which looks suspiciously like the old one. I think the difference is that this time I have a better idea of how data flows through the system. I’m finding SyncDroid to be very difficult, conceptually - there are multiple threads and multiple priorities and databases coming and going all of the time. Alan G. Carter of The Programmers’ Stone speaks of the importance of juxtaposition in programming. This project has juxtaposition up the wazoo. There’s enough that I can’t hold it all in my head at once (yet) and so I’m struggling.
Perhaps it reflects the elementary difficulty of what I’m trying to do. Perhaps that’s why no-one has done it before. I’ve certainly never struggled so much to hold a mechanism in my head before, and in past lives I’ve programmed 64-way machines, massively parallel dynamic hardware, and then both in the same system.
Anyway. It’s coming along, slowly. The other thing that I’m noticing with Python is that the amount of behaviour you pack into a given volume of code is very high. My major contract client has me coding predominantly in C, so it’s quite jarring at times. It’s not a bad thing, but I often wonder how much more difficult this would be in C. I don’t worry so much about memory management - I’ve got that pretty well down - but more things like standard libraries and unexpected crashes. The nasty thing about C is that it’s so brittle - a single misused pointer will crash your entire program. Python won’t let you make that sort of mistake, and if you do anyway, it handles the mistakes far more elegantly.
I’ve also finished some C security work lately and have come to the conclusion that if you want to write secure software, don’t do it in C. In fact, let’s generalize that. Don’t ever use C. That’ll be the right choice most of the time. If someone asks you to code in C++, run for the hills. Or at least make sure you’re invoicing by the hour.
Maybe it’s time for a holiday. My 26th birthday is coming up soon and I feel very old.