Improving Embedded Systems Code Quality Using Static Code Analysis

MrAl

Joined Jun 17, 2014
11,389
There are plenty of languages without an explicit goto but almost all have a language feature that does the same thing but with usually much less efficiency than a explicit goto. Engineers use goto and write code in languages with goto because we need things that work in actual systems vs some egg-head computer scientist in Canada writing a proof on goto alternatives in a new language.
So again we see your idea is better than everyone else's, but i dont think you need to disrespect people who dont agree with you. You can disagree without mocking it's easy to do :)
 

nsaspook

Joined Aug 27, 2009
13,079
So again we see your idea is better than everyone else's, but i dont think you need to disrespect people who dont agree with you. You can disagree without mocking it's easy to do :)
It's not my idea so it's not just a personal openion, it's something that actually works on real world problems for just about anyone into systems programming. I do respect egg-head computer scientists doing research but not their ability to deal with day to day low level systems programming.
 
Last edited:

MrAl

Joined Jun 17, 2014
11,389
It's not my idea so it's not just a personal openion, it's something that actually works on real world problems for just about anyone into systems programming. I do respect egg-head computer scientists doing research but not their ability to deal with day to day low level systems programming.
Hi,

Perhaps not but you've adopted the idea as your own that makes it yours as well as others and you assert it as true so in this context "idea" could be more universal.

But ive heard arguments from both sides over and over again and both sides make good points.
To me though programming has to involve at least some methodology or what might be called 'style'. Indents, lack of indents, etc., and some styles i really hate like when an author creates loops and has an open curly on the end of one line and the close curly at the beginning of another line which makes it harder to see where the block of code is contained unlike when the curlies always start at the beginning of any line such as:
function()
{
code;
};

instead of:
function() {
code;
};

I guess there are a lot of things like this that vary from person to person, what styles they adopt.
 

nsaspook

Joined Aug 27, 2009
13,079
This is my personal opinion. Styles are irreverent to the discussion about usage of GOTO and its unsafe equivalents in some aspects of programming. At the most basic level, hardware machine code level unconditional branches are used to express human code designs via a compiler for almost every HLL in existence. Surely humans can the handle the task of writing code with them too. I wrote lots of systems code in Modula-2 without the GOTO statement in the language so IMO I understand the issue from several sides. Gotos are not the problem. They never were. The problem is programmers.

This is not a style, this is just bad code.

C:
if (n >= 0) goto nonneg;
n = 0;
nonneg: ;
 

MrAl

Joined Jun 17, 2014
11,389
His argument was that using goto's leads to bad programming practices with sometimes hard to recognize structure. First a goto here, then a goto there, pretty soon It turns into McDonald's Farm with goto's everywhere :)

I ran into one particular program i was working on that wasnt a difficult program but not being able to use goto's made it hard to code. That was so long ago though im not sure if i could find it but mainly it had a lot of conditionals in it so it had to jump out of the layer in many different places.
It's interesting to look at an example like that and see what it takes to structure it more properly, so i'll try to find that example. Im talking 20 years back so i hope i can find it.

I've also run into multiple loops where if the inner loop conditional fails and wants to jump out of the outer loop then a variable has to be tested not just in the inner loop but in the outer loop(s) as well.
If the loops are three levels deep, then that means testing in the inner loop as usual but then testing in the next outer loop and then the last outer loop also in order to get out of the whole thing.
This was an argument FOR the use of goto's.

for k=1 to 10
for j=1 to 10
for i=1 to 10
if x=-1 then pass=0 exit
next i
if pass=0 then exit
next j
if pass=0 then exit
next k
So it took two more conditionals to get out of the inner loop when the goal was to exit if x=-1.
Otherwise it would have been just goto Final

for k=1 to 10
for j=1 to 10
for i=1 to 10
if x=-1 then goto Final
next i
next j
next k
Final:
DoSomethingElse()

It's a little interesting also that goto's bring in the need for labels too.
 

nsaspook

Joined Aug 27, 2009
13,079
Much of this madness comes from the need to help people that just shouldn't be serious programmers program. If you make a deeply padded cell with only one way in and only one way out they will be successful.
 
Top