The wings of a programmer

April 12, 2015
By

(This article was first published on Burns Statistics » R language, and kindly contributed to R-bloggers)

Programmers think programming is really hard.  Non-programmers think it’s even harder than that.

Figure 1: The perceived difficulty of programming. perceived_programming_difficulty

Why is programming so arduous?

There are a few reasons.  Here is one.

Wings

Programming is exacting, programming needs creativity.

These are absolutely at odds with each other.

One wing wants the programmer to respect every minuscule triviality.  The other wants the programmer to conceive a scintillating new creature that fits seamlessly into an existing ecosystem.  Getting either of these out of one particular homo sapiens brain is a lot to ask.  Here we are, wanting both at once.

Failure mode 1

Do the details, ignore the creativity.

This gets you code that runs, that passes the existing test suite.  But code that is a dead end.  Ask one more thing of it and it falls apart.  The code is likely to be verbose.

Failure mode 2

Do the creativity, ignore the details.

This gives you code that doesn’t do much of anything (if you get any code at all).

Failure mode 3

Do details and creativity simultaneously.

This is frustrating for the programmer and frustrating for the eventual users.  Trying to do both of these at the same time means that neither gets done.

Premature optimization is the root of all evil

– Donald Knuth

Simultaneously doing details and design is a form of premature optimization.  Plus, brain rule #4 suggests that trying to do them both at once is, at best, inefficient — gist should come before details.

Better

Better is to use both wings, but — unlike a bird — flap one for a while and then the other.  Not like a bird, more like Paul Bunyan’s dog Sport.  Sport’s back half was sewn on upside down after he was accidentally chopped in half.  This turned out to be a good thing: when he got tired of running on his front legs, he would just flip over and run on his back legs.

First mold your new baby so it fits into the current milieu.  Only once it seems to have a good shape should you worry about it doing everything correctly.  Worry whole hog.

Failure mode 0

Real programmers know that numbering starts at zero.  Indeed there is failure mode 0, which is:

Don’t program at all.

See also

Tao Te Programming is mostly about the things that make the line in Figure 1 slope back up.  It also suggests additional ways to make programming easier for beginners.

Epilogue

There, upside down (unlike a Bird),

— from “The Sloth” by Theodore Roethke

Appendix R

Figure 1 was produced in R with the function:

 P.perceived_programming_difficulty <- function (filename = "perceived_programming_difficulty.png") 
{
  if (length(filename)) {
    png(file = filename, width = 512)
    par(mar = c(5, 4, 0, 2) + 0.1)
  }
  pdiff <- stats::splinefun(1:4, c(11, 2, 7, 8.8), method="natural")
  curve(pdiff, 0.5, 5, lwd=6, col="darkblue", xlab="Experience",
    ylab="Perceived difficulty", axes=FALSE, xlim=c(0.4,5))
  axis(1, at=c(0.7, 2.6, 4.5), tck=0, c("none", "some", "lots"))
  axis(2, at=c(3, 9, 15), tck=0, c("easy", "really hard", "really really hard"))
  box()
 
  if (length(filename)) {
    dev.off()
  }
}

The post The wings of a programmer appeared first on Burns Statistics.

To leave a comment for the author, please follow the link and comment on their blog: Burns Statistics » R language.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)