Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Alvaro Videla on Structured Programming with Go...

Alvaro Videla on Structured Programming with Go To Statements by Donald Knuth

Harmful GOTOs, Premature Optimizations, and Programming Myths are the Root of all Evil

See: http://videlalvaro.github.io/2015/02/programming-myths.html

This talk is a discussion of the paper Structured Programming with Go To Statements by Donald Knuth, in which some programming myths that populate our industry are reviewed.

Maxims like "Go To Considered Harmful" or "Premature optimization is the root of all evil" are revisited and analyzed in context, both in the paper in which they appeared, and by further comments made by the authors, which are usually ignored.

At the same time a glimpse is given about what was the computer industry back in 1974, the year Knuth's paper was published, in order to better understand the concerns of the author in his paper.

At the end we try to analyze the current state of our industry, specifically around what has been dubbed "Buzzword Oriented Programming", the attitude of judging the merit of technologies based on blog post titles, or the 140 characters of a tweet.

The talk was originally presented at Papers We Love Madrid.

Papers_We_Love

February 12, 2015
Tweet

More Decks by Papers_We_Love

Other Decks in Programming

Transcript

  1. myth: an unproved or false collective belief that is used

    to justify a social institution dictionary.com
  2. Some Myths • No Unit-Tests, no working code • Procedure

    calls are expensive • NoSQL is faster than traditional DBs • 10x Engineers • Servers are cheaper than engineers
  3. May I ask if there is a reason why you

    prefer using goto instead of function recursion? https://github.com/igorw/retry/issues/3
  4. retry library <?php namespace igorw; class FailingTooHardException extends \Exception {}

    function retry($retries, callable $fn) { beginning: try { return $fn(); } catch (\Exception $e) { if (!$retries) { throw new FailingTooHardException('', 0, $e); } $retries--; goto beginning; } }
  5. retry library <?php namespace igorw; class FailingTooHardException extends \Exception {}

    function retry($retries, callable $fn) { beginning: try { return $fn(); } catch (\Exception $e) { if (!$retries) { throw new FailingTooHardException('', 0, $e); } $retries--; goto beginning; } }
  6. A case against the goto statement + Niklaus Wirth =

    Go To Statement Considered Harmful
  7. Please don't fall into the trap of believing that I

    am terribly dogmatical about [the go to statement]. I have the uncomfortable feeling that others are making a religion out of it, as if the conceptual problems of programming could be solved by a single trick, by a simple form of coding discipline! E. Dijkstra
  8. Please don't fall into the trap of believing that I

    am terribly dogmatical about [the go to statement]. I have the uncomfortable feeling that others are making a religion out of it, as if the conceptual problems of programming could be solved by a single trick, by a simple form of coding discipline! E. Dijkstra
  9. In search of Silver Bullets • Microservices • Testing •

    Agile • Performance Tricks • NoSQL • Message Queues
  10. There is no single development, in either technology or management

    technique, which by itself promises even one order of magnitude [tenfold] improvement within a decade in productivity, in reliability, in simplicity Frederick Brooks Jr No Silver Bullet - http://worrydream.com/refs/Brooks-NoSilverBullet.pdf
  11. Structured programming with go to statements • Introduction • Elimination

    of Go To Statements • Introduction of Go To Statements • Conclusions
  12. TL;DR: 1974 • Almost no personal computers • Public Encryption

    a new thing • Structured Programming was all the rage • Abstract Data Types a new thing
  13. “Experience indicates that nearly everybody has the wrong idea about

    the real bottlenecks in his programs” D. Knuth Computer Programming as an Art - http://dl.acm.org/citation.cfm?id=361612
  14. “premature optimization is the root of all evil” D. Knuth

    The Godwin Law of Optimization Discussions
  15. “Yet we should not pass up our opportunities in that

    critical 3%. A good programmer will not be lulled into complacency by such reasoning, he will be wise to look carefully at the critical code; but only after that code has been identified” D. Knuth
  16. “Yet we should not pass up our opportunities in that

    critical 3%. A good programmer will not be lulled into complacency by such reasoning, he will be wise to look carefully at the critical code; but only after that code has been identified” D. Knuth
  17. “the universal experience of programmers who have been using measurement

    tools has been that their intuitive guesses fail” D. Knuth
  18. “My books emphasize efficiency because they deal with algorithms that

    are used repeatedly as building blocks in a large variety of applications” D. Knuth
  19. “We shouldn't merely remove go to statements because it's the

    fashionable thing to do; the presence or absence of go to statements is not really the issue.” D. Knuth
  20. “We shouldn't merely remove go to statements because it's the

    fashionable thing to do; the presence or absence of go to statements is not really the issue.” D. Knuth
  21. “The question is whether we should ban it [GOTO], or

    educate against it” Donald Knuth
  22. “The biggest problem we have as human beings is that

    we confuse our beliefs with reality” Alan Kay http://www.tele-task.de/archive/video/html5/14029/
  23. “[in the 70s] computing spread out much, much faster than

    educating unsophisticated people can happen” Alan Kay https://queue.acm.org/detail.cfm?id=1039523
  24. “Those who cannot remember the past are condemned to repeat

    it" George Santayana https://archive.org/stream/lifeofreasonorph01sant#page/284/mode/2up
  25. “In 1968, the Communications of the ACM published a text

    of mine under the title "The goto statement considered harmful", which in later years would be most frequently referenced, regrettably, however, often by authors who had seen no more of it than its title” E. Dijkstra https://www.cs.utexas.edu/users/EWD/transcriptions/EWD13xx/EWD1308.html
  26. “In 1968, the Communications of the ACM published a text

    of mine under the title "The goto statement considered harmful", which in later years would be most frequently referenced, regrettably, however, often by authors who had seen no more of it than its title” E. Dijkstra https://www.cs.utexas.edu/users/EWD/transcriptions/EWD13xx/EWD1308.html
  27. “Classics cut to fit fifteen-minute radio shows, then cut again

    to fill a two-minute book column, winding up at last as a ten- or twelve-line dictionary resume” Fahrenheit 451
  28. “[…] there has been far too much emphasis on go

    to elimination instead of on the really important issues; people have a natural tendency to set up all easily understood quantitative goal like the abolition of jumps, instead of working directly for a qualitative goal like good program structure” D. Knuth
  29. “[…] there has been far too much emphasis on go

    to elimination instead of on the really important issues; people have a natural tendency to set up all easily understood quantitative goal like the abolition of jumps, instead of working directly for a qualitative goal like good program structure” D. Knuth
  30. “we should strive most of all for a program that

    is easy to understand and almost sure to work” D. Knuth
  31. “we had better see to it that the computer industry

    does not kill computing science” E. Dijkstra https://www.cs.utexas.edu/users/EWD/transcriptions/EWD12xx/EWD1284.html