Re: Goto - finally
- From: The Natural Philosopher <tnp@xxxxxxxxxxxxxxx>
- Date: Fri, 26 Jun 2009 13:15:08 +0100
sheldonlg wrote:
phpCodeHead wrote:Ah, exactly what a real time scheduler does thousands of times a second..On Jun 24, 9:26 am, Jerry Stuckle <jstuck...@xxxxxxxxxxxxx> wrote:Mason Barge wrote:
I understand the term procedural code, I understand the term OO, and Ihttp://en.wikipedia.org/wiki/Structured_programming
understand spaghetti. What do you mean by "structural"?
[...]
Since I just code little pages on my own -- and some of them are quiteI hope you don't have to read it six months or a year from now. Or,
complex (again, I understand the term "spaghetti code" although I
prefer to think of mine as "angel hair pasta code") -- I don't have to
worry about other peeps reading it.
even worse, try to fix it. Such code is hard to understand and even
harder to maintain.
And I've asked this question a dozen times, but still . . . do youYou have that backwards. Java was created as an OO language BECAUSE OO
think OOP has sufficient benefits for me, given the info above, to
spend the time to learn and employ it? I've about decided "no", but
then, what if I wanted to get some outside fee work someday?
I really don't much like it. I have a sneaking suspicion that its
primary reason for existence is all the Java programmers who feel
naked without it.
was so popular, even then. There were many OO languages before Java -
C++ and Smalltalk being the most recognized. OO techniques had caught
on already and were proving their power.
And I agree with asdf - learn about it so you can make an intelligent
choice.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@xxxxxxxxxxxxx
==================
Seriously, are we still arguing this?
http://www.cs.utexas.edu/~EWD/transcriptions/EWD02xx/EWD215.html
IMHO, technically speaking, anytime a program "breaks" from operating
on sequential statements, say, when a method is called, are we not
"going to" some other "labeled" (the function/method) name on some
other line of code somewhere?
For crying out loud, code, with all of its complexities, will never
NOT be "spagetti-like". Get over it.
No, it is not the same. Calling a function is aaying "do this block of code, and stay where you are at the next instruction". In other workds, calling a function is in-line coding. You might want to look at it as a line of pseudo-code that is actually implemented. It is just that rather than repeat it in-line many times, we have it in a separate place. It still is inline code. This differs from spaghetti code with the uni-directional goto statement with its jump to some arbitrary label -- never to return to the calling spot.
Are multi tasking OS'es spaghetti code: No. Does every single if then else statement result on an assembler level GOTO . Yes.
So since the structured methods use gotos all the time, the issue is to hide them from humans. Well Jerry, mostly, since he gets a pain in his...thing.. when he sees one. And his humanity is questionable.
The ELSE statement implicitly means a GOTO. Every time you write ELSE it really means 'the preceding IF statement must make an _unconditional_ jump to the end of this else statement'.
So there cant be an efficiency problem with the GOTO. Its a human problem.
WE simply moved from
CMP BRANCH NOT EQUAL LABEL1
...
...
JMP LABEL2
LABEL1:
...
...
...
LABEL2:
...
...
to if {} else {}
For example.
You can make huge gains in assembler using GOTOS.
Consider a typical C compatible subroutine exit which tends to [pop the registers its used and then rturn..
say it pops FOUR registers and does a RET.
A minimum of 5 bytes of code usually.
Whereas a JMP STANDARD RET is 3 bytes in a 16 bit computer.
SO you can save two bytes per subroutine..I had to actually do that years ago to cram more functionality into a ROM..
Of course the tradeoff is that it breaks pipelining in a modern processor, and today ROM RAM and the like is cheap..and trained monkeys are expensive, arrogant and stupid.
Hence 'structured programming' to make one monkeys shit look like every other monkeys shit, in the hope they will be able to recognise it and actually read it when one monkey is off sick from a surfeit of bananas.
Fundamentally different.
Not really.
Its just different brains..like 'go up 5 blocks, turn left three blocks, do 27 blocks up there and make a right by the oak tree, and then its the 17th house on the right. versus '1.76 km NNE on a bearing of 279 from here' or 'latitude 67.5, longitude 0.321'
All are accurate. One is longer to write, easier to follow if you dont have a map or GPS..
Spaghetti code is anyway not the worst thing there is. Uncommented blocks nested 27 deep are just as bad, as is a subroutine of indeterminate operation every line..
.
- Follow-Ups:
- Re: Goto - finally
- From: sheldonlg
- Re: Goto - finally
- References:
- Goto - finally
- From: Bill H
- Re: Goto - finally
- From: Erwin Moller
- Re: Goto - finally
- From: asdf
- Re: Goto - finally
- From: Mason Barge
- Re: Goto - finally
- From: Jerry Stuckle
- Re: Goto - finally
- From: phpCodeHead
- Re: Goto - finally
- From: sheldonlg
- Goto - finally
- Prev by Date: Re: PHP: determine if field has no characters but may contain spaces
- Next by Date: Re: Optimisation process
- Previous by thread: Re: Goto - finally
- Next by thread: Re: Goto - finally
- Index(es):
Relevant Pages
|