|
|
Up |
|
|
  |
Author: gavinogavino Date: Jun 3, 2008 13:13
does the ease of using the forth commands grow with time?
I have a headache trying to remember them all......it seems like i
play a guessing game with trying to sort out my calcualtions on the
stack until I finally get it.....but a week later I've no clue how i
even got the word workign...it just does......is thsi normal?
|
| |
|
| | 60 Comments |
|
  |
Date: Jun 3, 2008 14:14
gavino wrote:
> does the ease of using the forth commands grow with time?
Definitely.
> I have a headache trying to remember them all......it seems like i
> play a guessing game with trying to sort out my calcualtions on the
> stack until I finally get it.....but a week later I've no clue how i
> even got the word workign...it just does......is thsi normal?
I would give a qualified yes. By that I mean once you have a new Forth
word working and fully tested, then it is quite common (at least for me)
to later forget exactly *how* it works. But I don't care. I am
confident that it does its job as intended. I guess it's a form of
information hiding and I see nothing wrong with that. But, here's the
qualification: You really should be able to go back and understand
words you have written without too much effort.
|
| Show full article (1.33Kb) |
|
| | no comments |
|
  |
Author: Robert MillerRobert Miller Date: Jun 3, 2008 19:47
> does the ease of using the forth commands grow with time?
I hope so, and I think that is starting to happen for me.
Although I had some experience with FORTH about thirty years ago
anything at a detail level was long forgotten. So I am in
learning mode again.
> I have a headache trying to remember them all......it seems like i
> play a guessing game with trying to sort out my calcualtions on the
> stack until I finally get it.....but a week later I've no clue how i
> even got the word workign...it just does......is thsi normal?
From one newbie to another FWIW:
Comments, comments, and more comments. I break my code into
'phrases' whose stack effects I can manage in my head and then list
what is on the stack after each phrase. It takes a little extra effort
but I don't have any problem understanding what I wrote a couple
of months ago. By the time I have the code working, often several of
these phrases have morfed into factors. Often a comment line
suggests a factor.
|
| Show full article (1.24Kb) |
| no comments |
|
  |
Author: The TinkererThe Tinkerer Date: Jun 3, 2008 20:14
gavino gmail.com> wrote:
> does the ease of using the forth commands grow with time?
You do get used to it. It took me a while. I am a touch typist. To me
the typing is automatic. I think something and it appears on screen. So
when I wanted to dump a region of memory, I would have already typed the
word 'dump' before I began thinking about the parameters. Which meant
stack underflow messages every time I issued what seemed like a normal
straight-forward command.
> I have a headache trying to remember them all......it seems like i
I found "Starting Forth" by Leo Brodie a good read, but not a
particularly good reference book. It is not always obvious where to look
for things you vaguely remember reading but can't remember what he was
talking about when he mentioned them.
> play a guessing game with trying to sort out my calcualtions on the
> stack until I finally get it...
Do you mean get it to work? or "get it" as in suddenly understanding
what was previously baffling?
I am still a beginner at forth, and that stack without labels and its
reverse syntax nearly drove me nuts when I first started using it.
|
| Show full article (3.01Kb) |
| no comments |
|
  |
Author: Elizabeth D RatherElizabeth D Rather Date: Jun 3, 2008 22:19
gavino wrote:
> does the ease of using the forth commands grow with time?
> I have a headache trying to remember them all......it seems like i
> play a guessing game with trying to sort out my calcualtions on the
> stack until I finally get it.....but a week later I've no clue how i
> even got the word workign...it just does......is thsi normal?
Learning Forth is a different process from learning most programming
languages, because of (a) the stack, and (b) the enormous command set.
In some respects it's like learning a new human language: you have to
develop a lot of vocabulary before you can express yourself effectively.
As others in this thread have said, the two keys are:
1. Comments! Every word needs a comment (the conventional place is just
after the name) describing what the word expects on the stack and what
it leaves there. In addition, a brief description of what it does, and
comments inside the word showing what various phrases are accomplishing,
all help. For newbies like yourself, the practice of putting one short
phrase per line and then a comment showing what's on the stack at the
end of that phrase is very helpful.
|
| Show full article (2.60Kb) |
| no comments |
|
  |
Author: Bernd PaysanBernd Paysan Date: Jun 4, 2008 00:56
Robert Miller wrote:
> I break my code into
> 'phrases' whose stack effects I can manage in my head and then list
> what is on the stack after each phrase.
Slightly wrong approach - give that phrase a name and a stack comment (i.e.
factor, factor, factor!). Especially if you are new to Forth, writing
one-line definitions is a must; writing long definitions is wrong even if
you aren't a newbee, but as beginner, you definitely can't handle them.
This then leads to the reputation of "Forth is unreadable".
|
| |
| 24 Comments |
|
  |
Author: Marcel HendrixMarcel Hendrix Date: Jun 4, 2008 01:50
Bernd Paysan wrote Re: frustration with starting forth
> Robert Miller wrote:
>> I break my code into
>> 'phrases' whose stack effects I can manage in my head and then list
>> what is on the stack after each phrase.
> Slightly wrong approach - give that phrase a name and a stack comment (i.e.
> factor, factor, factor!). Especially if you are new to Forth, writing
> one-line definitions is a must; writing long definitions is wrong even if
> you aren't a newbee, but as beginner, you definitely can't handle them.
> This then leads to the reputation of "Forth is unreadable".
IMHO, writing *very* short definitions does not automatically lead to
readable code. This is because the number of words and their possible
combinations explodes (Gavino) and, especially with badly chosen names,
endless confusion will result.
If names are chosen correctly, and words have no side-effects, then
one can disregard the 'how' and get along fine (Doug's observation).
|
| Show full article (2.02Kb) |
| no comments |
|
  |
Author: astrobeastrobe Date: Jun 4, 2008 03:42
> Isn't it strange that all beginners work on the stack so much with
> complicated expressions, and use long words that are impossible to test?
One possible reason is that they still use the metric of other popular
languages, where one page long functions or procedures are not
uncommon. I bet people coming from APL for instance don't make that
mistake.
> I wonder where they get these ideas. It's certainly not in any of the
> recommended text books. OTOH, the books don't normally show code that
> explains how to use it (ever saw a Forth word that gives usage
> information?).
Generally newbies (and sometimes others) are too much focused on the
supposed high cost of calls and returns, which incline them to inline
too much stuff. This is IMO a typical case of premature optimization.
Amicalement,
Astrobe
|
| |
| no comments |
|
  |
Author: Stephen PelcStephen Pelc Date: Jun 4, 2008 05:11
On Wed, 4 Jun 2008 10:50:01 +0200, mhx@iae.nl (Marcel Hendrix) wrote:
>OTOH, the books don't normally show code that
>explains how to use it (ever saw a Forth word that gives usage
>information?).
From the VFX Forth kernel sources, which generate the manual.
|
| Show full article (1.13Kb) |
| 19 Comments |
|
  |
|
|
  |
Author: Thomas PorninThomas Pornin Date: Jun 4, 2008 05:45
According to Marcel Hendrix :
> IMHO, writing *very* short definitions does not automatically lead to
> readable code. This is because the number of words and their possible
> combinations explodes (Gavino) and, especially with badly chosen names,
> endless confusion will result.
Writing very short definitions imply writing many of them, and, as such,
coming up with names for all of them. Finding names works on the
programmer imagination, which is a scarce resource.
In my opinion, one of the strong points of the stack-based syntax that
Forth use is precisely that it designates operands implicitely:
arguments for a word are passed on the stack, and thus obtained from
their position on the stack. This contrasts with other syntaxes such as
C, where names must be given to function arguments and temporaries.
Lifting the need for so many argument names allows the programmer to
allocate more brain space to the task of finding names for functions
(i.e. words), but this can be overdone, as always. This makes writing
very short definitions difficult (at least, that makes it difficult for
me).
--Thomas Pornin
|
| |
| no comments |
|
|
|
|