El dom, 13-02-2011 a las 02:26 +0100, Levente Uzonyi escribió:
I know what's premature optimization.
It appear that you know but doesn't understand. See below.
What I do differently than other people (including you) is: - if I can choose from different solutions for some problem, then I usually pick the one with the best expected performance if it has neglible other extra cost (complexity, readability, size, etc) compared to other solutions. E.g.: I usually write 1 to: 10 do: instead of (1 to: 10) do:, foo ifNotNil: [ ... ] instead of foo ifNotNilDo: [ ... ] or foo isNil ifFalse: [ ... ]), etc.
This *is* premature optimization. Why? because you're programming with the performance in mind *all* the time, since the first second you start programming! And not only that, it relies on a specific VM implementation, the squeak one. Presumes that the given messages are *more efficient* (just because you know that the squeak compiler/vm combination makes them so). But this could be wrong or at least useless in other vm (like GNU or Gemstone). So by definition it is premature optimization. Lastly, to program like you (and not like others, Igor and I and most people I think) we should have in the head the specifics of the vm implementation and a handy list of the inlined messages of the vm. This is the job of the JIT, not from the developer!
- I optimize library code which is expected to be heavily used
This the time and usage will tell
- I like to optimize code
Prematurely it appears! Cheers -- Miguel Cobá http://twitter.com/MiguelCobaMtz http://miguel.leugim.com.mx