From: Joe Fischer on
On Wed, <rod.speed.aaa(a)gmail.com> wrote:

>Joe Fischer <joe(a)westpointracing.com> wrote
>> What can possibly be wrong with using a machine instruction?
>
>It makes the code hard to read.

That depends on where the jump GOes TO
in the code. It is sad that the opinion of one or a
few early programmer teachers would put a taboo
on programming style.

Line number BASIC code usually was poor
programming style. And the GOTO was often
used just because the programmer didn't plan
the structure and ran out of room. :-)

But that doesn't give a teacher a good
enough reason to mark a paper in a way that
can affect the student for the rest of her life.

Joe Fischer

From: Rod Speed on
Morris Dovey <mrdovey(a)iedu.com> wrote
> <nicksanspam(a)ece.villanova.edu> wrote

>> I use BASIC for calcs and TMY2 simulations. Readability is important,
>> and floating point and log and trig functions. The platform cost
>> isn't important for design calcs, but low cost and low power are
>> important for things like a smart whole house fan controller.

> Readability is more or less a matter of writing
> code to be readable, regardless of language.

Yes, but dinosaur Basic is harder to produce clean readable code
with, so that doesnt happen in practice with amateurs like Nick.

> Here's a transliteration of one of your recent snippets:

> #include <stdio.h>
> #include <math.h>

> int main(void)
> { double panes, sun, loss;

> for (panes=1; panes<=10; panes++)
> { sun = 1000 * pow(0.9, panes);
> loss = 24 * (70 - 30) / panes;
> printf("%.0lf %8.4lf\n", panes, sun - loss);
> }
> return 0;
> }

> Following the Borland example, some implementations of C
> (for CPUs without FPUs) include emulation code. I've written
> a couple of software floating point libraries in C to do basic
> operations (add, subtract, multiply, divide, square root, and
> sine/cosine) and they're not exactly socket surgery.

> For one-off projects, none of this probably matters very much.

The ones handed out to others are just the ones that
need to be readable, if only to check the logic etc.

Corse he should be using a spreadsheet, not a progamming language.

> OTOH, if the object is to produce large quantities
> and to achieve performance objectives while using
> a slower uC, then the savings can be huge.

That has nothing to do with whether code is readable or not.


From: Joe Fischer on
On Tue, "Morris Dovey" <mrdovey(a)iedu.com> wrote:

>"Joe Fischer" <joe(a)westpointracing.com> wrote:
>| That overlooks the fact that the BASIC text file
>| source code is easier to use by anyone with a copy
>| of a BASIC interpreter, and easier to change parameters,
>| in the shortest possible source code, ___without___
>| compiling.
>
>That's only true if one ignores C interpreters (I do.)

I tried to learn C for 20 years and didn't know
there was a C interpreter available. :-)

>| Compiled programs are good for certain things,
>| line number BASIC has it's merits, one being the
>| ability for a user to change it easy.
>
>Integrated development environments (IDEs) make this a non-argument.
>They allow making a source change and clicking on a "RUN" button to
>automatically compile, link edit, and execute quicker than you can
>type "RUN".

I think I was using the first IDE compiler in the
early 1980s (if it was Borland Turbo Pascal 2.x).

>| But there are BASIC compilers that don't
>| need the RUNxxxxx support files, although that
>| defeats the purpose of writing source code that
>| can be translated to human understanding of
>| the calculations.
>
>True; but also a non-argument. If it's written to be readable, then it
>will be.

Right, almost any construct can be made hard
to read, but it is more difficult in line number BASIC
to make it hard to read. In C, it can be made so
that nobody but the programmer understands it,
but this is partly because in C, the included modules
must be understood by the person reading the code.
In line number BASIC, that is not a factor.

>| When doing any energy calculations, it
>| helps to be able to work directly with the source
>| code and an interpreter.
>
>This pre-supposes that the person writing the code has, at best, an
>incomplete understanding of the problem. A person who understands the
>problem and the tools being used implements the solution directly.

It assumes that the person using the sample code
is not a professional programmer, whether or not they
know much about energy or physics.

>| And there are even people who object to
>| just being the slave of the programmer and
>| just fill in the values when prompted, but
>| to each his own.
>
>"Slave of the programmer" describes an unhealthy environment.

It works for cases where the inputs are rigidly
required, in the source code posted here that may
not be true, for instance, the area may not be
described as a rectangle, and the code may need
to be changed, try that with a compiled program.

>In a
>healthy situation, the programmer is the slave of a functional
>specification. If your situation is different, you should be
>considering replacing either the person responsible for the
>specification or the programmer.

I don't think all programs can be written as strictly
well specified. Which is why line number BASIC was
popular, it allows jumping into the problem, and changing
things along the way.

All this does not even resemble large team projects
with a rigid specification.

A sample program in line number BASIC is perfect
for presenting to a wide range of users, who may need
to modify the code to fit a specific use, and one or two
GOTOs might actually make it more readable.

Joe Fischer

From: Dennis on
On Tue, 26 Dec 2006 21:31:13 -0500, Joe Fischer
<joe(a)westpointracing.com> wrote:

>On Wed, <rod.speed.aaa(a)gmail.com> wrote:
>
>>Joe Fischer <joe(a)westpointracing.com> wrote
>>> What can possibly be wrong with using a machine instruction?
>>
>>It makes the code hard to read.
>
> That depends on where the jump GOes TO
>in the code. It is sad that the opinion of one or a
>few early programmer teachers would put a taboo
>on programming style.
>
> Line number BASIC code usually was poor
>programming style. And the GOTO was often
>used just because the programmer didn't plan
>the structure and ran out of room. :-)
>
> But that doesn't give a teacher a good
>enough reason to mark a paper in a way that
>can affect the student for the rest of her life.

He remembered the lesson all these years later, didn't he? Props to
the teacher for making it stick! ;-)

I would ding a programmer's review if he used GOTOs indiscriminately,
regardless of how well his programs (seem to) work today. I've spent
enough time maintaining other's (poor) code down the road to know
better.


Dennis (evil)
--
"There is a fine line between participation and mockery" - Wally
From: Rod Speed on
Joe Fischer <joe(a)westpointracing.com> wrote
> Rod Speed <rod.speed.aaa(a)gmail.com> wrote:
>> Joe Fischer <joe(a)westpointracing.com> wrote
>>> dold(a)04.usenet.us.com wrote

>>>>> the fascist prof gave me an F on that program because I used a GOTO :-)

>>>> That statement deserves a smiley, because it's laughable.

>>> The concept that there is something wrong with GOTO is what is laughable,

>> Nope.

>>> there direct machine instructions for the 386 family that does precisely that.

>> Irrelevant.

>>> What can possibly be wrong with using a machine instruction?

>> It can make the code hard to read.

> That depends on where the jump GOes TO in the code.

Nope, its basically where it comes from.

It can produce more readable code in a very few specialised
situations, like when bailing to a general error handler etc, but
the problem is that while ever the language allows it, clowns
who dont understand what structured code is about inevitably
use it to write very messy and hard to read code instead.

> It is sad that the opinion of one or a few early programmer
> teachers would put a taboo on programming style.

Anyone with a clue can grasp the advantages of structured code.

You dont qualify obviously.

> Line number BASIC code usually was poor programming style.

Yes, because it encourages fools to write poorly structured code.

> And the GOTO was often used just because the programmer
> didn't plan the structure and ran out of room. :-)

Nope, its usually used by fools who wouldnt know what properly
structured code was if it bit them on their lard arses.

You do qualify there.

> But that doesn't give a teacher a good
> enough reason to mark a paper in a way that
> can affect the student for the rest of her life.

Mindlessly silly exaggeration.