A while ago I listened to a talk by Jonathan Blow that covered optimization and talked about how most people worry about it too early and how they should just focus on making things work. I know there was much more said in this talk (it’s long and very interesting), but this is the general message that has stuck with me after listening to it - possibly because many other people already express the same opinions on optimization. It makes sense, but to be honest I’ve been on the fence about following it without question myself.
A disclaimer. I’m no expert, so what I think isn’t really relevant or important to anyone (and if you have been reading my posts and thinking otherwise, stop it). The only person it is important to, in fact, is me, and that’s pretty fricking important considering I’m the one sitting here for hours on end after a day of client work trying to learn this stuff.
I also like to keep my code relatively clean, and sometimes I’ll spend an hour or so just going through and fixing up spacing, commenting, uncommenting, renaming variables, etc. It’s not just that I enjoy the process in general (it’s kind of relaxing when your brain is cramping from trying to make a new feature work), but it helps me review what I’ve done, make sure I understand it, and commit it to memory.
And maybe leaving that kind of thing until later stages is ok in theory, but if I leave it and just keep going, as someone who’s not an expert with this stuff, I’ll make more clumsy mistakes that slow things down further. And then I’m left with this bundle of bad, bad, performance-crippling crap. So personally, the only way I can manage to make this huge thing run relatively well in different browsers is by polishing the little rusty parts while they’re still fresh in my mind, before they get worse and worse and explode and everyone dies.
I think the “don’t optimize” advice is probably great for people who already kind of know what they’re doing. But for people who are totally new at this and teaching themselves, “optimization” likely means fixing up things that would already be taken into account naturally by a professional programmer. To them, it’s probably not even optimization - it’s just doing things right.