Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #24619
| From | stephenXXX@mpeforth.com (Stephen Pelc) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Request for comments on a first forth program |
| Organization | MPE |
| Message-ID | <51ea7da3.812674010@news.demon.co.uk> (permalink) |
| References | <87wqomga80.fsf@pestilenz.org> |
| Date | 2013-07-20 12:18 +0000 |
On Fri, 19 Jul 2013 11:39:11 +0200, Christian Kellermann
<ckeen@pestilenz.org> wrote:
>I have been re-reading my books on Forth lately and decided to get into
>learning it finally. One of the first results have been attached to this
>article and I would like to hear your criticism about it. (If this is a
>faux pas on this list please ignore this request).
I have just come back from a week teaching a Forth course, so your
post is very relevant to me.
>It's a small and silly implementation of the BSD game robots. You ("@")
>have to escape some robots ("R") and win by luring them into holes
>("*").
You had to explain this to us because the text above is not in the
code! All programmers, not just Forth programmers, fail to understand
that source code can have a very long life. After ten years, the
original programmer has probably left. After 30 years, nobody can
remember the job. Program for your successors.
>Things that did surprise me:
>
>* Working with the stack is not hard at all
>* Debugging Forth words has been easier than anticipated. I did not use
> the gforth debugging facilities though.
>* A bad choice of data structures is punished more heavily in forth due
> to unnecessary stack juggling involved than in other programming
> languages.
The stack just needs practice and a willingness to use the keyboard.
Debugging only requires you to know how formal scientific method
is done. See
http://www.mpeforth.com/arena/ProgramForth.pdf
>What I don't like in my program:
>
>* The word names are probably way too verbose for forthers. Comming from
> scheme I am quite accustomed to lengthy names and could not help it so
> far.
>* Redundant code due to my ignorance of the forth metaprogramming
> facilities. I need to read up on these.
>* Unclear when to use cells or bytes as an access unit for accessing
> buffers.
>* What's the preferred coding style for longer words? Or is this a sign
> that my word is too convoluted and should be refactored?
>* The access words for the values seem too verbose, are these even
> necessary?
What I find difficult in most Forth programs stems from them being
bottom up. If you scan them from the top, you don't know why/where
you're going. Hence, a description of each word is "very good thing".
Further, I emphasise that writing the stack comment and description
*before* you start coding the word will save time - your code will
have fewer stack faults and you will be coding to a specification.
Your successors and readers will thank you.
>Also I have the general feeling that it could be rewritten to take up
>less words. I probably choose a bad data representation.
That's just experience with a language. I've seen production
code that's a lot worse.
Stephen
--
Stephen Pelc, stephenXXX@mpeforth.com
MicroProcessor Engineering Ltd - More Real, Less Time
133 Hill Lane, Southampton SO15 5AF, England
tel: +44 (0)23 8063 1441, fax: +44 (0)23 8033 9691
web: http://www.mpeforth.com - free VFX Forth downloads
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar
Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-07-19 11:39 +0200
Re: Request for comments on a first forth program Ron Aaron <rambamist@gmail.com> - 2013-07-19 13:04 +0300
Re: Request for comments on a first forth program rickman <gnuarm@gmail.com> - 2013-07-19 12:43 -0400
Re: Request for comments on a first forth program Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-07-19 05:28 -0500
Re: Request for comments on a first forth program m.a.m.hendrix@tue.nl - 2013-07-19 03:56 -0700
Re: Request for comments on a first forth program m.a.m.hendrix@tue.nl - 2013-07-19 04:00 -0700
Re: Request for comments on a first forth program rickman <gnuarm@gmail.com> - 2013-07-19 12:51 -0400
Re: Request for comments on a first forth program Christian Kellermann <ckeen@necronomicon.my.domain> - 2013-07-20 21:28 +0200
Re: Request for comments on a first forth program anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-22 15:43 +0000
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-07-24 20:00 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-07-25 10:37 +0200
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-07-26 00:00 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-07-26 09:34 +0200
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-07-25 21:40 -1000
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-07-27 20:16 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-07-29 10:09 +0200
Re: Request for comments on a first forth program m.a.m.hendrix@tue.nl - 2013-07-29 04:14 -0700
Re: Request for comments on a first forth program Andrew Haley <andrew29@littlepinkcloud.invalid> - 2013-07-29 07:49 -0500
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-07-29 15:32 -1000
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-07-31 17:50 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-07-31 13:23 +0200
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-07-31 18:05 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-08-01 12:53 +0200
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-08-01 09:58 -0500
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-08-01 20:42 -0700
Re: Request for comments on a first forth program Brad Eckert <hwfwguy@gmail.com> - 2013-08-04 18:53 -0700
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-08-04 22:05 -0500
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-08-04 20:54 -0700
Re: Request for comments on a first forth program Alex McDonald <blog@rivadpm.com> - 2013-08-05 05:50 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-08-05 22:14 +0200
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-08-06 21:11 -0700
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-08-01 01:04 -0500
Re: Request for comments on a first forth program albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-19 18:06 +0000
Re: Request for comments on a first forth program Christian Kellermann <ckeen@necronomicon.my.domain> - 2013-07-20 21:31 +0200
Re: Request for comments on a first forth program Christian Kellermann <ckeen@necronomicon.my.domain> - 2013-07-20 21:24 +0200
Re: Request for comments on a first forth program anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-22 15:32 +0000
Re: Request for comments on a first forth program Alex McDonald <blog@rivadpm.com> - 2013-07-19 06:49 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@necronomicon.my.domain> - 2013-07-20 21:34 +0200
Re: Request for comments on a first forth program Mark Wills <markrobertwills@yahoo.co.uk> - 2013-07-19 07:19 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@necronomicon.my.domain> - 2013-07-20 21:41 +0200
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-07-19 07:55 -1000
Re: Request for comments on a first forth program Christian Kellermann <ckeen@necronomicon.my.domain> - 2013-07-20 21:47 +0200
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-07-20 11:15 -1000
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-07-20 20:09 -0700
Re: Request for comments on a first forth program "Paul E. Bennett" <Paul_E.Bennett@topmail.co.uk> - 2013-07-19 19:36 +0100
Re: Request for comments on a first forth program albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-20 12:36 +0000
Re: Request for comments on a first forth program Christian Kellermann <ckeen@necronomicon.my.domain> - 2013-07-20 21:53 +0200
Re: Request for comments on a first forth program Coos Haak <chforth@hccnet.nl> - 2013-07-21 02:02 +0200
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-07-20 17:18 -1000
Re: Request for comments on a first forth program Ian Osgood <iano@quirkster.com> - 2013-07-23 16:07 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@necronomicon.my.domain> - 2013-07-20 21:48 +0200
Re: Request for comments on a first forth program stephenXXX@mpeforth.com (Stephen Pelc) - 2013-07-20 12:18 +0000
Re: Request for comments on a first forth program Christian Kellermann <ckeen@necronomicon.my.domain> - 2013-07-20 21:57 +0200
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-07-20 11:24 -1000
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-07-22 15:53 +0200
Re: Request for comments on a first forth program m.a.m.hendrix@tue.nl - 2013-07-22 08:06 -0700
Re: Request for comments on a first forth program albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-22 19:35 +0000
Re: Request for comments on a first forth program m.a.m.hendrix@tue.nl - 2013-07-23 00:41 -0700
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-07-23 12:00 +0200
Re: Request for comments on a first forth program albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-23 12:10 +0000
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-07-23 14:19 +0200
Re: Request for comments on a first forth program stephenXXX@mpeforth.com (Stephen Pelc) - 2013-07-24 09:27 +0000
Re: Request for comments on a first forth program anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-23 13:44 +0000
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-07-20 20:02 -0700
Re: Request for comments on a first forth program albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-21 03:36 +0000
Re: Request for comments on a first forth program hughaguilar96@yahoo.com - 2013-07-20 22:28 -0700
Re: Request for comments on a first forth program albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-21 10:31 +0000
Re: Request for comments on a first forth program rickman <gnuarm@gmail.com> - 2013-07-20 23:41 -0400
Re: Request for comments on a first forth program anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2013-07-22 15:36 +0000
Re: Request for comments on a first forth program Lars Brinkhoff <lars.spam@nocrew.org> - 2013-07-23 12:22 +0200
Re: Request for comments on a first forth program Christian Kellermann <ckeen@pestilenz.org> - 2013-07-23 13:44 +0200
Re: Request for comments on a first forth program albert@spenarnc.xs4all.nl (Albert van der Horst) - 2013-07-23 12:26 +0000
Re: Request for comments on a first forth program "Elizabeth D. Rather" <erather@forth.com> - 2013-07-23 07:10 -1000
Re: Request for comments on a first forth program stephenXXX@mpeforth.com (Stephen Pelc) - 2013-07-24 09:30 +0000
csiph-web