Premature optimization is the root of all evil.. NOT!

We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.

Famous computer scientist Donald Knuth

His quote is often clipped down to just “premature optimization is the root of all evil”, but that is NOT TRUE.

Yes, don’t micro-benchmark everything when you begin a project, but please do think ahead. And once you’ve got the program working as intended, then make it faster by profiling and looking for the bottlenecks.

Choose the proper data structures. Array? List? Hashset? Queue? Dictionary? Caching?
Take a few moments and think it over.

How often will this line of code be ran? Do I need to inline it, or pull it out into a separate method?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s