Re: NSMapTable with C strings as keys
Re: NSMapTable with C strings as keys
- Subject: Re: NSMapTable with C strings as keys
- From: Ian Joyner <email@hidden>
- Date: Thu, 30 May 2013 11:30:12 +1000
On 29 May 2013, at 14:14, Oleg Krupnov <email@hidden> wrote:
> While I generally agree that premature optimization is evil,
That seems to come out of a belief that well-structured code is code that runs poorly (this belief came out of an IBM system of the 50s/60s that had really poorly running subroutine calls - so the recommendation was not to structure things).
In one sense I think we should always be optimizing code. That is in the sense that we write well structured and correct code. Usually optimization naturally follows. There seems to be a school of thought that writing poorly structured code must be optimized, but I have usually seen that most badly running code is a result of poor structure and refactoring makes it both structured and optimized. Once you have got to such a structured state then you might be able to see where further optimizations can be made to profiled areas of code which might result in more complex, but still structured and optimized. Where something simple is replaced by a more complex algorithm it should be well documented.
That is the subject of Dijkstra's book "A Discipline of Programming". Once a well-structured algorithm is developed, better optimizations can then be seen. This is the 'engineering' part of software development - making software run practically (not the drawing diagrams part). For particular computations (that is where the algorithm works on particular data sets), an algorithm might not be optimal, so needs to cater to those cases.
In summary - we should be producing well-structured code early on. This will usually result in well-optimized code. However, this is not a guarantee and particular cases may need to be addressed later (that is the premature optimization case). But we should always aim to produce well-structured code.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden