Few things can spark more religious fervour amongst programmers than the mention of a goto statement. PHP has stepped into the middle of the firefight by announcing that it will be implementing goto functionality in version 5.3.

There is plenty of discussion surrounding PHP's decision, with PHP founder Rasmus Lerdorf defending the move, stating it is no different than breaking to a label and that it will not be an unlimited goto (it will not let jumps into loops or switches).

Despite Lerdorf's assurances, the wailing and moaning continues relentlessly. Why is this? To understand, one must realise that the vast majority of programmers have been taught that goto is considered harmful, is a bad idea and will bring pestilence to the land if used. Most students are happy to accept this, generally based on the experience of writing ridiculous spaghetti code in BASIC, so they move onto structured programming and eventually object-orientated programming.

This happens for very good reasons; a maturing programmer has more chance to get themselves in a bind by being unstructured and it is generally better for maintainability and understanding to avoid goto.

By going against the goto grain, PHP is challenging a tenet upon which the foundation of modern programming is built. The size of the challenge is only compounded by the fact that the change is occurring in version 5.3 of the language, a long time after the language muffed but eventually reached satisfactory attempts at implementing objects, and appears to be a step backward.

xkcd says it best on bad uses of goto (Click image to enlarge)(Goto image by xkcd, CC2.5)

Here's a shock for the young, blindly-accepting-articles-of-faith type of programmer that has never had to use a goto: most high-level languages implement a form of goto, you just know them as break, switch and continue. And that most-revered of code projects, the Linux kernel, makes extensive use of the goto statement and is written in C — the most respected of languages.

What is good enough for Linus and the team of kernel hackers should be good enough for Rasmus and his clan of web developers.

It's true that goto is a dangerous weapon and in the hands of the inexperienced it's a devastatingly head-scratching weapon of spaghetti creation, but in the right hands it can remove the maze of nested branching structures nicely.

What does this all mean for PHP? Not much. Those programmers adverse to using goto will continue to avoid it at all costs (no one is forcing them to use it), quality programmers will be able to use it well and sparingly, and the bad programmers that create spaghetti will do so even more now that they can use the statement.

But they were going to create bad programs anyway, goto simply made it easier for them to get into a mess. They'll learn eventually.

Related Topics:

About Chris Duckett

Some would say that it is a long way from software engineering to journalism, others would correctly argue that it is a mere 10 metres according to the floor plan.During his first five years with CBS Interactive, Chris started his journalistic advent...

Full Bio

Some would say that it is a long way from software engineering to journalism, others would correctly argue that it is a mere 10 metres according to the floor plan.During his first five years with CBS Interactive, Chris started his journalistic adventure in 2006 as the Editor of Builder AU after originally joining the company as a programmer.Leaving CBS Interactive in 2010 to follow his deep desire to study the snowdrifts and culinary delights of Canada, Chris based himself in Vancouver and paid for his new snowboarding and poutine cravings as a programmer for a lifestyle gaming startup.Chris returns to CBS in 2011 as the Editor of TechRepublic Australia determined to meld together his programming and journalistic tendencies once and for all.In his free time, Chris is often seen yelling at different operating systems for their own unique failures, avoiding the dreaded tech support calls from relatives, and conducting extensive studies of internets — he claims he once read an entire one.