The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

goto by perldude2002-06-11 09:00:28
  "...considered harmful" by HadEnuf 2002-06-11 09:46:16
Yes, I've read "just a wee bit" :^) of Edsger Dijkstra, over the years, and he's more-or-less always been on the mark; but something tells me you've never written a state machine running on "bare metal" in hard, real time.

There are a few (if very few) legitimate uses for GOTO--mostly for exception handling--outside of embedded work. Some types of state machines qualify; but most, thankfully, reduce to a case structure, wrapped in a loop.

In the embedded world, it gets a little different: sometimes there's no other way to squeeze out the few (or even few hundred) bytes needed to fit into your microcontroller's ROM, without going to a much larger, and significantly more expensive part. (If $0.007 per unit makes a big difference across 1,000,000 units, imagine what a difference of $3.60 does.) The same may apply if you're running low on RAM (which in microcontrollers, may be 256 bytes or far less [I've worked with one 4-bitter that had only 64 *digits* {nybbles} of RAM])--not all applications have the luxury of "plenty of memory".

I remember a chassis-bus message handler, in an automotive HVAC control, that required jumps from the end of every branch of a massive case structure, to one of a handful of "common tail" sequences, in order to fit into the available ROM and execution time (it was in an interrupt handler). Jumping directly to each tail section saved some 300 bytes. Since this was written in assembler (where a GOTO looks no different from a "structured" language construct), this wasn't a big deal, anyway. Had it been written in 'C', for example, it would still have required 'goto': the sheer number of cases and the multiple tail sections would have foiled any optimizer I have yet seen.

Remember, this is a case where we had to cram everything into a 16kB ROM, or go to much more expensive 32kB part, when we were going to make *millions* of units...the annual cost of going to the larger part would have exceeded the salary of the entire development team!

Fortunately, outside of embedded development, clarity and ease of maintenance can usually take priority over raw efficiency of the implementation. For example, I'd never write a compiler "by hand", given the possibility of using 'lex' and 'yacc'.

--
HadEnuf?
[ Reply ]
    so is that the 0.01% time then? by Epiphany02002-06-11 10:06:45
      Yes, though it's more than 0.01%... by HadEnuf2002-06-11 10:31:06
        fair enough by Epiphany02002-06-11 10:49:34

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)