C to Forth Translator 
Author Message
 C to Forth Translator

Quote:

>I've got a situation where Forth seems like the appropriate
>language to use (compactness, speed, et. al.), but a user
>community that is reluctant to learn Forth (they would not
>use the Forth-based facility very often).  Is there a
>program out there which would allow them to write C code
>perhaps with restrictions) and translate it to Forth?

This is I deal with fairly often and there are several
answers, none of which may be obvious until you have
done it a couple of times. Much of the answer depends on
the application, so my solutions my be taken with a
grain of salt if they don't apply.

Solution 1:
Forth is wonderful for custom scripting languages. What the
user sees does not have to look like Forth at all. Making
your application prefix instead of postfix is practical with
a little effort.

The amount of effort depends on whether the user can write
new "macros" (words to those in the know:-) or simply execute
predefined operations. For example, the normal Forth way
of opening a database for example might be:

     my_database db_open

but what the user types could be:

     open my_database

It is not too difficult to define a simple language or lexicon
of phrases for the user to do his/her thing with interactively.
Allowing the same sort of thing in colon definitions is a pain,
but doable.

Solution 2:
Use a Forth written in C. Mine (Until) has been described as
a Reverse Polish Small-C on several occasions. Until includes
most of the C String and I/O libraries and many C  system'
functions as Forth primitives. They take the same calling
sequences as the C equivalent. I have found this hook into
existing C knowledge to be useful in dragging reluctant C
programmers into Forth via Until several times.

This sort of thing can be done with any of the current crop
of Forth-in-C compilers (ThisForth, PFE, etc.) I believe. It
is already done in Until.

Solution 3:
This is really used in combination of solutions 1 and 2. Never
ever use the *F* word. My primary customer would not bless
using Forth because of perceptions, even with successful
large applications. These perceptions mainly revolve around "It's
difficult to find Forth Programmers". The reality is "It's
difficult to find Good Programmers". And the two issues get
confused. I have never had problems getting new programmers
up to speed and productive that were *Good* (4 or 5 over the
years).

Now that "scripting" languages are the rage, and we are using
several, they have no problem using one more "scripting" language
for the text processing applications I write.

By the way Forth is not the only computer domain where simply
using the "whatever" word provokes the same sort of negative
reaction even when it provides an excellent solution.

Hope this helps!

Norm Smith



Tue, 13 Jan 1998 03:00:00 GMT  
 C to Forth Translator

Quote:

>I've got a situation where Forth seems like the appropriate
>language to use (compactness, speed, et. al.), but a user
>community that is reluctant to learn Forth (they would not
>use the Forth-based facility very often).  Is there a
>program out there which would allow them to write C code
>perhaps with restrictions) and translate it to Forth?

This is I deal with fairly often and there are several
answers, none of which may be obvious until you have
done it a couple of times. Much of the answer depends on
the application, so my solutions my be taken with a
grain of salt if they don't apply.

Solution 1:
Forth is wonderful for custom scripting languages. What the
user sees does not have to look like Forth at all. Making
your application prefix instead of postfix is practical with
a little effort.

The amount of effort depends on whether the user can write
new "macros" (words to those in the know:-) or simply execute
predefined operations. For example, the normal Forth way
of opening a database for example might be:

     my_database db_open

but what the user types could be:

     open my_database

It is not too difficult to define a simple language or lexicon
of phrases for the user to do his/her thing with interactively.
Allowing the same sort of thing in colon definitions is a pain,
but doable.

Solution 2:
Use a Forth written in C. Mine (Until) has been described as
a Reverse Polish Small-C on several occasions. Until includes
most of the C String and I/O libraries and many C  system'
functions as Forth primitives. They take the same calling
sequences as the C equivalent. I have found this hook into
existing C knowledge to be useful in dragging reluctant C
programmers into Forth via Until several times.

This sort of thing can be done with any of the current crop
of Forth-in-C compilers (ThisForth, PFE, etc.) I believe. It
is already done in Until.

Solution 3:
This is really used in combination of solutions 1 and 2. Never
ever use the *F* word. My primary customer would not bless
using Forth because of perceptions, even with successful
large applications. These perceptions mainly revolve around "It's
difficult to find Forth Programmers". The reality is "It's
difficult to find Good Programmers". And the two issues get
confused. I have never had problems getting new programmers
up to speed and productive that were *Good* (4 or 5 over the
years).

Now that "scripting" languages are the rage, and we are using
several, they have no problem using one more "scripting" language
for the text processing applications I write.

By the way Forth is not the only computer domain where simply
using the "whatever" word provokes the same sort of negative
reaction even when it provides an excellent solution.

Hope this helps!

Norm Smith



Tue, 13 Jan 1998 03:00:00 GMT  
 C to Forth Translator

Quote:

> Solution 1:
> Forth is wonderful for custom scripting languages. What the
> user sees does not have to look like Forth at all. Making
> your application prefix instead of postfix is practical with
> a little effort.

 [snip snip ]
Quote:

> Solution 3:
> This is really used in combination of solutions 1 and 2. Never
> ever use the *F* word. My primary customer would not bless
> using Forth because of perceptions
... [snip ]

> Now that "scripting" languages are the rage, and we are using
> several, they have no problem using one more "scripting" language
> for the text processing applications I write.

I think this is a helpful comment, but I remember some people had
m{*filter*}objections to bringing in Forth under a different name.

Since then I have thought a little about that.
  -- I think some of us want to have Forth accepted under its own
   name as a matter of principle.  I find this rather like the cyclists
   who insist on riding on the main road, when a perfectly good
   cycleway has been built alongside (they argue that cyclists
   should have equal rights with other traffic to use the main road).
   At the very least, it is a non-commercial goal which reduces the
   possibilities to use Forth commercially.
 -- Some of us feel that renaming Forth for the occasion is like
   telling a lie (i.e. less than the truth).  My experience was that
   my customers did not know what a computer language was, so that
   neglecting to tell them that I was using Forth was like neglecting
   to tell them that I preferred Mobil Superlube for the car that I
   used to drive to their site.  But they could smell a crusade a mile
   away, and didn't want to be a guinea pig for advancing anyone's
   non-commercial goals.  I.e. they wanted rational suppliers as a
   basis for trust.
 -- Does your customer have any *right* to dictate to you your choice
   of programming tools (usually on the basis on his neighbour's son's
   best friend's gossip from the latest buzzword milieu, e.g. 1st year
   engineering school before any practical exercises have been
   completed) ?  So, why raise the issue at all ?
 -- Isn't the idea of choosing a language a little out of date ?  Don't
   we choose paradigms or methodologies nowadays ?  Don't we choose
   toolboxes and workbenches, and components ?

I don't think it is a problem in getting acceptance for Forth that we
"reinvent the wheel" a little too often.  Anyone can see that using
existing libraries and other stuff has its drawbacks and can be very
time-consuming, at least with a little experience people realize that.

That is the sort of criticism that my clients have never made.  I think
it is designed unconsciously to get us to respond in a time-wasting way
that has no commercial purpose.

Serious customers that aren't out to cripple you psychologically or
make you into their slave, and who are not themselves CS professionals,
should be open to any well-reasoned account you may choose to give
about your methods, that you tailor to their interests and perceptions.

I don't remember IBM ever calling anything by its CS-accepted
terminology -- they seem to have had a marketing principle of always
inventing their own name for everything (e.g. "PC" instead of
"microcomputer", "adapter" instead of "card").  The most powerful
marketing technique is to own a word in your prospective customer's
head.  I am sure "Forth" is sacred to Forth Inc. but I don't think
there is any brand equity for the rest of us in the name itself, in fact
I read repeated reports in this NEWS forum that the brand equity
in the name is negative.  Of course, we do need to be able to find
each other, so maybe the name helps for that.




Wed, 14 Jan 1998 03:00:00 GMT  
 C to Forth Translator
Quote:


>> Solution 1:

> [snip snip ]

>> Solution 3:
>> This is really used in combination of solutions 1 and 2. Never
>> ever use the *F* word. My primary customer would not bless
>> using Forth because of perceptions
>... [snip ]

>> Now that "scripting" languages are the rage, and we are using
>> several, they have no problem using one more "scripting" language
>> for the text processing applications I write.

>I think this is a helpful comment, but I remember some people had
>m{*filter*}objections to bringing in Forth under a different name.

>Since then I have thought a little about that.
>  -- I think some of us want to have Forth accepted under its own
>   name as a matter of principle.  I find this rather like the cyclists
>   who insist on riding on the main road, when a perfectly good
>   cycleway has been built alongside (they argue that cyclists
>   should have equal rights with other traffic to use the main road).
>   At the very least, it is a non-commercial goal which reduces the
>   possibilities to use Forth commercially.
> -- Some of us feel that renaming Forth for the occasion is like
>   telling a lie (i.e. less than the truth)

  To those who I can get to listen for two minutes, I usually use Norm's
"scripting language" approach, and say the future
belongs to "semantic", rather than "syntactic"
languages, and that while Forth isn't the first
semantic language ( I think Lisp might be), it is the
best available, & with a standard.

  To those listeners who aren't glazed over at this point,
I try to sneak in the meaning of a semantic language:

  + where data and program are indistinguishable,
  + a "parser" doesn't have to know the whole language,

therefore, Forth is the only computer language where the possiblity
exists that any English (say) text may be a legitimate program,
and _not_ just some program's data.  Parse that idea!

   At this point, the usual success stories may be enumerated.



Fri, 16 Jan 1998 03:00:00 GMT  
 C to Forth Translator
Regarding the pros and cons of 'fessing up to using Forth --

I think much depends upon the context.  When dealing with prospective
customers who just have a problem they want solved, I agree that
dragging in language issues muddies the waters in ways in which the
cust. may be ill-equpped and understandably reluctant to become
involved.  Best to focus on solving the problem (how, how long, how
much, etcl).  Also, we've had good success with high-level products such
as EXPRESS (see message posted elsewhere on c.l.f today) aimed at folks
who don't want to think of themselves as programmers at all.  In neither
of these cases do we bring up Forth unless asked directly.

However, when dealing with actual software development tools, such as in
conversation with someone looking for an embedded system development
environment, I believe there's advantage to be gained in having a known,
standard language that's currently used by major players in the field
(names dropped according to what this particular field is) rather than
some unknown euphemistic substitute.



Fri, 16 Jan 1998 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. C->FORTH FORTH->C Translators

2. CS people in Forth?

3. CS People in Forth?

4. Forth in CS

5. Believe or not, Forth in CS!

6. Forth and CS

7. Where does FORTH belong in CS and Academia?

8. to CS: or not to CS: in F-PC assembler

9. Forth to C translator

10. FORmula TRANslator for ANS Forth now ready.

11. FORmula TRANslator for ANS Forth now ready.

12. Job: Forth to C translator

 

 
Powered by phpBB® Forum Software