Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 89785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:46:15+00:00 2026-05-10T22:46:15+00:00

As Knuth said, We should forget about small efficiencies, say about 97% of the

  • 0

As Knuth said,

We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.

This is something which often comes up in Stack Overflow answers to questions like ‘which is the most efficient loop mechanism’, ‘SQL optimisation techniques?’ (and so on). The standard answer to these optimisation-tips questions is to profile your code and see if it’s a problem first, and if it’s not, then therefore your new technique is unneeded.

My question is, if a particular technique is different but not particularly obscure or obfuscated, can that really be considered a premature optimisation?

Here’s a related article by Randall Hyde called The Fallacy of Premature Optimization.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:46:16+00:00Added an answer on May 10, 2026 at 10:46 pm

    Don Knuth started the literate programming movement because he believed that the most important function of computer code is to communicate the programmer’s intent to a human reader. Any coding practice that makes your code harder to understand in the name of performance is a premature optimization.

    Certain idioms that were introduced in the name of optimization have become so popular that everyone understands them and they have become expected, not premature. Examples include

    • Using pointer arithmetic instead of array notation in C, including the use of such idioms as

      for (p = q; p < lim; p++) 
    • Rebinding global variables to local variables in Lua, as in

      local table, io, string, math     = table, io, string, math 

    Beyond such idioms, take shortcuts at your peril.

    All optimization is premature unless

    • A program is too slow (many people forget this part).

    • You have a measurement (profile or similar) showing that the optimization could improve things.

    (It’s also permissible to optimize for memory.)

    Direct answer to question:

    • If your ‘different’ technique makes the program harder to understand, then it’s a premature optimization.

    EDIT: In response to comments, using quicksort instead of a simpler algorithm like insertion sort is another example of an idiom that everyone understands and expects. (Although if you write your own sort routine instead of using the library sort routine, one hopes you have a very good reason.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 74k
  • Answers 74k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer This is not possible with the present version of PostSharp.… May 11, 2026 at 2:22 pm
  • added an answer All WPF controls are skinnable by their control templates. Its… May 11, 2026 at 2:22 pm
  • added an answer Setting the property MvcBuildViews to true should work. <target name='Deploy'… May 11, 2026 at 2:22 pm

Related Questions

Knuth recently objected to 64-bit systems, saying that for programs which fit in 4
It could be as simple as one-liner scripts, or as complex as a complete
I'm writing a number of articles meant to teach beginning programming concepts through the
We should forget about small efficiencies, say about 97% of the time: premature optimization

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.