One of the more dreaded and despised functions in C/C++ or any programming languages is the GOTO statement. The very utterance of this word infuriates most trainers and their students, as good boys and girls, honestly believe them and refrain from using it thenceforth . Now how many of you / the trainers actually know the reason behind this . As a test try asking them or your friends who constantly nag and poke you in the eye every time you happen to use it.
Ok for the sake of history , the GOTO statement was downplayed by the eminent computer scientist Edsgar Dijkstra . Ya ! the same fellow you gave us the shortest path algorithm. In his hand-typed-on-his-typewriter - consecutively numbered technical notes, trip reports, insightful observations, and pungent commentaries, known collectively as "EWDs" for several dozen recipients in academia and industry he put that conviction into practice.
His explanation for the disparagement of the poor GOTO can be read from the E .W .Dijkstra archives at the utexas website HERE ! As you will find, his explanation is very geeky( it *has* to be geeky, he was a computer scientist ) and novices seldom understand his paper in the first or even 2nd trial of reading.
Recently I happened to read it ( was just curious ) and tried to make it as simple as I could. The major argument that he put forth was…
As a program is written in a programming language, the course of action of converting the program into its equivalent process flow ( the equivalent machine code instructions ) should be left to the machine compiler. The human mind should not intervene in the "process" , it is the machine's duty to produce the desired effect of the program written by the programmer as we, humans have some intellectual limitations and sometimes ,accidently are liable to force a fault . Its like “You do your job , let the machine do its ! ”
This is a rational and a wise programming practice according to Dijkstra and I agree with his doctrine .
He proceeds to give a fairly simple example of counting the number of people entering the room which can be read at the link given earlier to further fortify his paper.
So my fellow friends we are advised not to use the GOTO statement in the programming languages, next time someone pokes you, be sure to ask him/her and actually clarify his/her doubt about it !!
NOTE : ( The above opinions have been interpreted entirely by me on the basis of the original manuscript and might not be 100% correct. The readers are advised to read the original manuscript in its entirety. Do keep coming with your valuable comments and suggestions !! )
-> Why we shouldn’t use scanf() ( * !! * ) and void main(void) as a rational programmer ? coming soon ….
- Have fun and always try to implement good programming practices .
Vandit Khamker.
|








Post a Comment
Type away young fella !!