Cartoon - Highways and Programs
Written by Mike James   
Sunday, 19 February 2012

This week's selected xkcd cartoon might be puzzling to some. Why roads? The simple answer is that, to the algorithmic mind, every program is a road to travel and we are not talking philosophy here.

One of the skills of programming is the ability to put together loops and conditionals and all manner of instructions so that you build paths thought the code that the machine can follow. Take your finger and place it on the start of a program. Now follow all of the possible ways thought the program - execute the loops and take each branch of a conditional. The shape that you trace out is the flow of control graph and it characterizes the program.

 

Just like a road map tells you how to get from A to B the flow of control graph shows how to get from the start to the end of the program.

 

So what has this got to do with impossible highway junctions?

Highway Engineer Pranks More cartoon fun at xkcd a webcomic of romance,sarcasm, math, and language

 

Back in the old days the flow of control was completely free because we could build programs using the Goto or Jump statement. The result was that programmers would create programs with very complex, and often incorrect, flow of control. Yes, you really could encounter the inescapable cloverleaf and the zero-choice interchange, if not the rotary supercollider.

Examples such as these often occurred when one programmer modified the work of another or when one programmer came back and modified their own work. What was supposed to be a conditional was accidental transformed into a default flow of control and what looked like a choice became no choice at all.

Today we don't do things like this because our languages have clear control constructs - the if...then..else, the until and the while and so on. However, there are programmers who have the same sense of humour as the highway engineer and invent the not-yet, the repeat-a-few and the not-ever syntax.

Related Articles

The Goto, Spaghetti and the Velociraptor

Programming Paradigms for Languages

Teach Concepts Not Just Code

nochoicejunction

blog comments powered by Disqus

 

To be informed about new articles on I Programmer, subscribe to the RSS feed, follow us on Google+, Twitter, Linkedin or Facebook or sign up for our weekly newsletter.

 

Banner


Introducing Moziila Rec Room
27/08/2014

If you are wondering what tools to use to build a client side web app, Mozilla's new Rec Room has a set of recommendations and a tool that attempts to integrate them for you. This is described as "wor [ ... ]



Programming Tribes
14/08/2014

Why is it that certain groups exhibit what you might call inessential characteristics. It is as if you suddenly encountered a group of music fans who all had red hair. What has red hair to do with tha [ ... ]


More News

Last Updated ( Sunday, 19 February 2012 )
 
 

   
RSS feed of news items only
I Programmer News
Copyright © 2014 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.