Skip to content

Instantly share code, notes, and snippets.

@jackmott
Last active May 1, 2017 21:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackmott/b6fcc15caa4773765b2edd2b7cddf548 to your computer and use it in GitHub Desktop.
Save jackmott/b6fcc15caa4773765b2edd2b7cddf548 to your computer and use it in GitHub Desktop.
On one liner programming adivce

In general I have a problem with the whole set of short form, appeal to authority programmer advice things, of which there are many common examples:

  • premature optimization is the root of all evil
  • functional programming is easier to reason about
  • it is easier to make a correct program fast than a fast program correct
  • etc

One problem with these is that they are often stated as global truths, but are usually only true in specific cases. For each of these rules you must know when to break it. For instance the lead engine devs at ID Software say the exact opposite of the first quote - "Premature optimization is the root of all good". More important many of these things we just don't know to be true, we just think they are. And while I may agree with the sophistry behind the arguments, and think them plausible, that doesn't mean it really is so.

Now the experienced or clever (I am not that clever) among us understand all these subtleties immediately but not everyone does.

How we feel about these quotes might depend on our own personal preferences and the areas in which we work. I know that many many people somehow are not annoyed by slow software on a daily basis, so naturally those people are going to see any quote claiming that performance is less important that other factors in a good light.

Similarly if you have been the victim of theft because an insecure server was hacked, or had a company ruined due to security holes, or had to deal with unintelligble code a coworker wrote recently, quotes about correctness and clarity being of primacy will resonate with you.

I on the other hand am driven crazy by software that is slow daily, and so I tend to hate these quotes, because I imagine it may lead to something insane, like someone using a web browser, combined with node, combined with javascript to implement desktop applications. Hopefully not.

So is it easier to make a correct program fast? If you developed the underlying data structures with an understanding of the hardware, sane choices of tools, then yes, it will be. You just start profiling for the hot spots and figure out how to cool them off. But if you started with completely inappropriate data structures or used a language or framework which just can't do the job well, it could be an absolute nightmare to make it fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment