|
|
Up |
|
|
  |
Author: ilikemachinesilikemachines Date: Jul 28, 2008 12:07
After reading quite a bit about Forth, my interest is definitely
piqued! I have read that it is possible to hold the entire language
in your head at once! I've read that a Forth system comes with a
compiler, the editor, the runtime library, and the very operating
system itself! I've also read that all of this only takes up a few k
of memory!
- How much of this is true, and in what way and/or to what extent?
- Is it possible to compile native code, and how would one go about
it?
- Is the source code included (to study)?
- Which package is worth learning from the ground up? (and where can I
get it?)
|
| |
|
| | 47 Comments |
|
  |
Author: Aleksej SaushevAleksej Saushev Date: Jul 28, 2008 12:16
> After reading quite a bit about Forth, my interest is definitely
> piqued! I have read that it is possible to hold the entire language
> in your head at once! I've read that a Forth system comes with a
> compiler, the editor, the runtime library, and the very operating
> system itself! I've also read that all of this only takes up a few k
> of memory!
>
> - How much of this is true, and in what way and/or to what extent?
Not a "few". It depends a lot on what you're including into the system.
> - Is it possible to compile native code, and how would one go about
> it?
It is possible. The second part depends on the system.
> - Is the source code included (to study)?
It depends on the system, Forth isn't single-implementation language.
> - Which package is worth learning from the ground up? (and where can I
> get it?)
Prepare to get many different controversial responses.
To make things more interesting, I propose FIG Forth, eForth, and Pygmy.
|
| Show full article (1.02Kb) |
|
| | no comments |
|
  |
Author: ilikemachinesilikemachines Date: Jul 28, 2008 12:42
Thanks! I found source for eForth written in forth. Once I get forth
learned better, I'd like to comprehend the virtual machine as well as
I can. Is this a good tactic to becoming a good Forth programmer?
|
| |
| no comments |
|
  |
Author: Aleksej SaushevAleksej Saushev Date: Jul 28, 2008 12:50
> Thanks! I found source for eForth written in forth. Once I get forth
> learned better, I'd like to comprehend the virtual machine as well as
> I can. Is this a good tactic to becoming a good Forth programmer?
No. Write applications, not virtual machines.
Solve real problems, not virtual ones.
--
CE3OH...
|
| |
| no comments |
|
  |
Author: ilikemachinesilikemachines Date: Jul 28, 2008 12:59
Hmm... That's certainly true in other languages.
|
| |
| no comments |
|
  |
Author: Elizabeth D RatherElizabeth D Rather Date: Jul 28, 2008 19:12
> Thanks! I found source for eForth written in forth. Once I get forth
> learned better, I'd like to comprehend the virtual machine as well as
> I can. Is this a good tactic to becoming a good Forth programmer?
The best way to learn Forth is to use it to write programs. The best
way to learn to write better programs is to look at your programs and
figure out how to make them better (smaller, faster, more readable,
whatever your goal is).
In my advanced Forth courses we have a "course project" which is a
simple application that everyone has 3 days to write and test (between
lectures and specific problem set assignments). There's a prize for the
smallest compiled working program and for the most readable program
(class members get to vote). Students learn the "economics" of various
programming choices (what makes programs smaller, faster, more readable,
etc.) along with what it takes to write readable code (readable by their
classmates).
I'm not sure that learning how the virtual machine works helps, although
it's certainly interesting. Does knowing how an automobile engine works
make you a better driver?
|
| Show full article (1.55Kb) |
| no comments |
|
  |
Author: roger.levyroger.levy Date: Jul 28, 2008 19:18
On Jul 28, 3:50 pm, Aleksej Saushev wrote:
>> Thanks! I found source for eForth written in forth. Once I get forth
>> learned better, I'd like to comprehend the virtual machine as well as
>> I can. Is this a good tactic to becoming a good Forth programmer?
>
> No. Write applications, not virtual machines.
> Solve real problems, not virtual ones.
>
> --
> CE3OH...
|
| Show full article (1.91Kb) |
| no comments |
|
  |
Author: Aleksej SaushevAleksej Saushev Date: Jul 28, 2008 21:07
> On Jul 28, 3:50 pm, Aleksej Saushev wrote:
>>> Thanks! I found source for eForth written in forth. Once I get forth
>>> learned better, I'd like to...
|
| Show full article (1.51Kb) |
| no comments |
|
  |
Author: roger.levyroger.levy Date: Jul 28, 2008 22:30
On Jul 29, 12:07 am, Aleksej Saushev wrote:
>> On Jul 28, 3:50 pm, Aleksej Saushev wrote:
>>>> Thanks! I found source for eForth written in forth. Once I get forth
>>>> learned better, I'd like to comprehend the virtual machine as well as
>>>> I can. Is this a good tactic to becoming a good Forth programmer?
>
>>> No. Write applications, not virtual machines.
>>> Solve real problems, not virtual ones.
>
>> With the VM, you want to be a good stack juggler (know when you are
>> using too much of the stack! but at the same time get good at
>> visualizing what's currently on it and what the different stack words'
>> effect will be.) and, I think you want to "feature the stack", because
>> it reduces variable usage and can simplify your API's syntax. And also
>> its good to understand the special uses of the return stack such as R>
>> DROP, or R> EXECUTE ( or CALL ) because it lets you do some
>> potentially useful syntactical "tricks".
> ...
|
| Show full article (2.79Kb) |
| no comments |
|
  |
|
|
  |
Author: Coos HaakCoos Haak Date: Jul 29, 2008 08:04
Op Mon, 28 Jul 2008 22:30:00 -0700 (PDT) schreef roger.levy@ gmail.com:
> With R> you can say : VECTOR> R> 'VECTOR ! ; and voila, one-word
> callback definer. ( so you can say : DEFINE-VECTOR VECTOR>
> CODE ; ) It's a trick that relies on the workings of the stack but
> that's Forth. And if your system doesn't have R> for some reason you
> can always write it...
I can't think of any Forth that doesn't have >R and R>. Every Forth has at
least two stacks ;-)
But the word VECTOR> is not portable. I.e. some implementations might have
a different width for the data and return stacks. A portable use of >R and
R> is storing temporary values, not execution tokens.
I have an implementation (not my 16 bit CHForth) that inlines the code and
will not compile DEFINE-VECTOR correctly.
Use insted DEFER as is proposed in http://www.forth200x.org/deferred.html
|
| |
| no comments |
|
|
|
|