Re: Changes to Euphoria

new topic     » goto parent     » topic index » view thread      » older message » newer message

Thoughts inspired by Jason and Jeremy's discussion...

Things in life are often a trade off...

Programmers develop habits as well as use idioms of a particular language.
Working with a small team of programmers on a huge project I can often tell
which member of my team wrote a particular section of code by how it's
written.  If I got my way, my ability to do this would lessen which is a loss.

So what am I looking to get to compensate for this loss?

I'm looking for a cleaner code that is easier to read with understanding.
The quicker you get comprehension the less you are stressed.  Making the
programmers job easier.  Idioms shared make comprehension easier too.

You can achieve much of this by the minimalist approach.

Take GOTO's verses structured code as a first example.  GOTO allows a 
programmer to express themselves very individually (making it easier for
me to tell who wrote the code) while structured code isn't so individual.
The structure tends to enforce a likely similar looking code.  And it's
generally quicker to comprehend (especially in a long block of code.)
Structures have a beginning so you know you're in a structure.  Even if the
code scrolls of the end of the page, you already know the eventuality.

With GOTO all you see at the beginning of a loop is a label.  That label
doesn't tell you, you are about to enter a loop.  Your comprehension will
require you to examine more code.

You could also minimize by taken out the structure, just use GOTO's
everywhere.  It's largely a matter of taste, but I prefer using structured
code.  YMMV.

I'd like to talk about loops.  You may think I'm just in love with my idea
(which I admit is partly true) but there are good reasons for my proposal.
I don't believe any on this forum will have any trouble judging the merits
or speaking their mind about it.  Some may even oppose an idea not for the
idea itself but because of who proposes it (which I think is a rather sad
thing.)

It's been noted that FOR loops are an addition to Euphoria which originally
had just while loops.  I've used FOR loops so much that I don't give it a
thought usually about whether they should be included or not, but thinking
minimally (don't include what you don't need) I realize there's a good
reason for not having them.  Let me start with the while loop and get back
to the for.

while (1)
   ...
end while

I would claim that quicker comprehension occurs with this construct...

Loop
   ...
End Loop

Both are infinite loops.  Yes, it's not much quicker to comprehend, we're
not dolts after all, but after examining thousands of lines of code, by 
3am I betcha that it becomes a bit more significant.

I would also claim (without support, just my INTJ assertiveness again) that
comprehension is better when Loop is used to describe Loop, rather than any
other _____ is a loop.  Call me crazy.

Now, how about getting out of the loop?  Some language provide a plethora
of ways and are thinking of new ways all the time no doubt (programmers are
such a creative bunch after all.)  The fact that sometimes you need to get
out of loops and the beginning, the end, the middle has led to repeat, until,
etc.  But for a minimalist the answer is right there, IF.  You need something
like EXIT to be used with the IF, but IF eliminates the need for any 
additional unneeded keywords because you can put the IF test anywhere in the
loop; beginning, middle and end.  Exit tells you immediately that you are
leaving the loop you are currently in.  Exit 12, on the other hand, is an
offramp in New Jersey I think!

What about FOR.  What does FOR add to the game that LOOP doesn't give you
already?  FOR gives you an INDEX.  What a great idea.  But perhaps
if a minimalist were trying to add an implicit INDEX he or she might have
realized you don't need to add FOR at all!

Loop
   ...
End Loop

There it is, did you see it?  Looks like anticomprehesion time, doesn't it?
Never fear, I'll get back to that in a moment.

FOR gives you more than just INDEX.  You can tell where to start, where to
end and how much to increment by.

For LOOP to have a start you'd have to do something like this...

Loop from 5

End Loop

Well why not?  This also gives us something else...

Loop
  ...
End Loop

...under the covers can become...

:Loop
   ...
GOTO Loop

And now quicker comprehension because the lack of from indicates no INDEX
at all.  It does however require the idiom  Loop from 1, but I don't think
that's such a big deal.  Idioms foster comprehension too.

Other languages use STEP where Euphoria uses BY...  I really like BY.  I
don't know why, I just do.  So we keep it...

Loop from 10 by 5

As long a we understand the INDEX is implicit (with only Loop for loops that
comprehension will come rathe quickly.  We don't have any other type of loop
to cause confusion.)

But how about the end of the loop?  With FOR I specify the end in the
declaration.  We minimalist don't need it.  We already have IF (cond) Exit.

Again I would restate that use of a single loop construct would make
comprehension quicker and would be reinforced with each subsequent use.

I stated my case for the two issues I've brought up before (somebody got
a fire extinguisher handy???)

Am I in love with my ideas.  Sure, why not?  Can I live with rejection.
Yeah, I suppose.  I'll just go into a corner and sulk for awhile.... blink

The biggest problem is that taken up my proposal requires change.  Change
is not easy.  No, better to say, change is hard.  One of the really annoying
things about me is that time often proves me right; by then the sun has
cooled, the earth has left it's orbit and the guys I was fighting with (in 
the friendly fashion that programmers do) has left the company.

But it's not about me.  So please consider the merits regardless of the
source.

I would also argue that a minimalist approach makes for a better compiler
or interpreter but we'd all agree on that, so where's the fun?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu