home *** CD-ROM | disk | FTP | other *** search
/ ftp.pasteur.org/FAQ/ / ftp-pasteur-org-FAQ.zip / FAQ / computer-lang / forth-faq / part1 next >
Encoding:
Internet Message Format  |  2000-07-05  |  24.7 KB

  1. Path: senator-bedfellow.mit.edu!bloom-beacon.mit.edu!howland.erols.net!news.pbi.net.MISMATCH!cyclone-transit.snfc21.pbi.net!131.119.28.147!su-news-hub1.bbnplanet.com!paloalto-snh1.gtei.net!paloalto-snf1.gtei.net!news.gtei.net!newsfeed.stanford.edu!sn-xit-03!supernews.com!sn-inject-01!corp.supernews.com!sabik.taygeta.com!jon
  2. From: jdv@forth.org (J. D. Verne)
  3. Newsgroups: comp.lang.forth,comp.answers,news.answers
  4. Subject: comp.lang.forth FAQ: General Information (1 of 7)
  5. Supersedes: <forth-faq-1-960119042@forth.org>
  6. Followup-To: comp.lang.forth
  7. Date: Tue, 04 Jul 2000 11:42:56 GMT
  8. Organization: The Forth Interest Group
  9. Lines: 603
  10. Approved: news-answers-request@MIT.EDU
  11. Expires: 08 Aug 00 11:44:02
  12. Message-ID: <forth-faq-1-962711042@forth.org>
  13. Reply-To: faq@forth.org (FAQ maintainers list)
  14. Keywords: FAQ FORTH FIG
  15. X-Complaints-To: newsabuse@supernews.com
  16. Distribution: world
  17. Originator: jon@sabik.taygeta.com
  18. Xref: senator-bedfellow.mit.edu comp.lang.forth:58496 comp.answers:41430 news.answers:186959
  19.  
  20. Posted-By: auto-faq 3.3 (Perl 5.004)
  21. Archive-name: computer-lang/forth-faq/part1
  22. Posting-Frequency: Monthly.  A how-to-find-the-FAQ article is posted weekly.
  23.  
  24.   comp.lang.forth Frequently Asked Questions (1/6): Gen-
  25.   eral/Misc
  26.   M. Anton Ertl, anton@mips.complang.tuwien.ac.at
  27.  
  28.   ____________________________________________________________
  29.  
  30.   Table of Contents:
  31.  
  32.   1.      Acknowledgements
  33.  
  34.   2.      comp.lang.forth FAQs
  35.  
  36.   3.      General Questions
  37.  
  38.   3.1.    What is Forth?
  39.  
  40.   3.2.    Where does the name Forth come from?
  41.  
  42.   3.3.    Why and where is Forth used?
  43.  
  44.   3.4.    Hang on, isn't Forth out of date now?
  45.  
  46.   3.5.    Is Forth faster or smaller than C?
  47.  
  48.   3.6.    What language standards exist for Forth?
  49.  
  50.   3.7.    What is an RFI?
  51.  
  52.   3.8.    Are there Coding Standards for Forth?
  53.  
  54.   3.9.    I have trouble managing the stack. Should I use global
  55.   VARIABLEs?
  56.  
  57.   3.10.   What is the Forth Interest Group?
  58.  
  59.   3.11.   Who is Chuck Moore and what is he doing?
  60.  
  61.   4.      Flame baits
  62.  
  63.   4.1.    Commercial vs. free Forth systems
  64.  
  65.   4.2.    Free Forth systems are bad for Forth.
  66.  
  67.   4.3.    Blocks vs. files
  68.  
  69.   4.4.    LOCALS|
  70.  
  71.   5.      Miscellaneous
  72.  
  73.   5.1.    Where can I find a C-to-Forth compiler?
  74.  
  75.   5.2.    Where can I find a Forth-to-C compiler?
  76.  
  77.   5.3.    RECORDS in Forth?
  78.  
  79.   5.4.    Why does THEN finish an IF structure?
  80.  
  81.   5.5.    What is threaded code? What are the differences between the
  82.   different threading techniques?
  83.  
  84.   5.6.    Has anyone written a Forth which compiles to Java bytecode?
  85.  
  86.   5.7.    What about translating Java bytecode to Forth?
  87.  
  88.   5.8.    How about running Forth without OS?
  89.  
  90.   5.9.    How about writing an OS in Forth?
  91.   ______________________________________________________________________
  92.  
  93.   1.  Acknowledgements
  94.  
  95.   This FAQ is based on previous work by Gregory Haverkamp, J. D. Verne,
  96.   and Bradford J. Rodriguez.
  97.  
  98.   2.  comp.lang.forth FAQs
  99.  
  100.   The comp.lang.forth FAQ is published in seven parts, corresponding to
  101.   these seven sections.  This part is the General/Misc FAQ, where the
  102.   questions not covered in the other FAQs are answered. The parts are:
  103.  
  104.   o  General questions <http://www.complang.tuwien.ac.at/forth/faq/faq-
  105.      general.html>
  106.  
  107.   o  Online resources <http://www.faqs.org/faqs/computer-lang/forth-
  108.      faq/part2/>
  109.  
  110.   o  Forth vendors <http://www.faqs.org/faqs/computer-lang/forth-
  111.      faq/part3/>
  112.  
  113.   o  Forth systems <http://www.faqs.org/faqs/computer-lang/forth-
  114.      faq/part4/>
  115.  
  116.   o  Books, periodicals, tutorials <http://www.faqs.org/faqs/computer-
  117.      lang/forth-faq/part5/>
  118.  
  119.   o  Forth groups & organizations <http://www.faqs.org/faqs/computer-
  120.      lang/forth-faq/part6/>
  121.  
  122.   o  ANS Forth <http://dec.bournemouth.ac.uk/forth/ans/faq.html>
  123.  
  124.      You can get the text versions of these FAQs at
  125.      <ftp://ftp.forth.org/pub/Forth/FAQ/>.
  126.  
  127.   These FAQs are intended to be a brief overview of the tools and
  128.   information available for the new FORTHer.  For a historical
  129.   reference, programming paradigms, and deep technical information try
  130.   some of the listed references.  For general questions on the Usenet,
  131.   or the methods used to get this information, try these other Usenet
  132.   groups:
  133.  
  134.   o  news.announce.newusers
  135.  
  136.   o  news.newusers.questions
  137.  
  138.   o  news.announce.important
  139.  
  140.   3.  General Questions
  141.  
  142.   3.1.  What is Forth?
  143.  
  144.   Forth is a stack-based, extensible language without type-checking.  It
  145.   is probably best known for its "reverse Polish" (postfix) arithmetic
  146.   notation, familiar to users of Hewlett-Packard calculators: to add two
  147.   numbers in Forth, you would type  3 5 +  instead of 3+5.  The
  148.   fundamental program unit in Forth is the "word": a named data item,
  149.   subroutine, or operator. Programming in Forth consists of defining new
  150.   words in terms of existing ones.  The Forth statement
  151.  
  152.   ______________________________________________________________________
  153.   : SQUARED  DUP * ;
  154.   ______________________________________________________________________
  155.  
  156.   defines a new word SQUARED whose function is to square a number (mul-
  157.   tiply it by itself).  Since the entire language structure is embodied
  158.   in words, the application programmer can "extend" Forth to add new
  159.   operators, program constructs, or data types at will.  The Forth
  160.   "core" includes operators for integers, addresses, characters, and
  161.   Boolean values; string and floating-point operators may be optionally
  162.   added.
  163.  
  164.   3.2.  Where does the name Forth come from?
  165.  
  166.        The name FORTH was intended to suggest software for the
  167.        fourth (next) generation computers, which Moore saw as being
  168.        characterized by distributed small computers.  The operating
  169.        system he used at the time restricted file names to five
  170.        characters, so the "U" was discarded.  FORTH was spelled in
  171.        upper case until the late 70's because of the prevalence of
  172.        of upper-case-only I/O devices.  The name "Forth" was gener-
  173.        ally adopted when lower case became widely available,
  174.        because the word was not an acronym.
  175.  
  176.   Rather, Colbourn, and Moore: The Evolution of Forth
  177.   <http://www.forth.com/Content/History/History1.htm>, in: History of
  178.   Programming Languages (HOPL-II), ACM Press/Addison-Wesley 1996.
  179.  
  180.   Note: Forth is not a 4GL (language for programming database
  181.   applications).
  182.  
  183.   3.3.  Why and where is Forth used?
  184.  
  185.   Although invented in 1970, Forth became widely known with the advent
  186.   of personal computers, where its high performance and economy of
  187.   memory were attractive.  These advantages still make Forth popular in
  188.   embedded microcontroller systems, in locations ranging from the Space
  189.   Shuttle to the bar-code reader used by your Federal Express driver.
  190.   Forth's interactive nature streamlines the test and development of new
  191.   hardware. Incremental development, a fast program-debug cycle, full
  192.   interactive access to any level of the program, and the ability to
  193.   work at a high "level of abstraction," all contribute to Forth's
  194.   reputation for very high programmer productivity.  These, plus the
  195.   flexibility and malleability of the language, are the reasons most
  196.   cited for choosing Forth for embedded systems.
  197.  
  198.   3.4.  Hang on, isn't Forth out of date now?
  199.  
  200.   One of the best answers came from Brad Rodriguez
  201.   <mailto:bj@forth.org>. You can find the full version at
  202.   <http://www.complang.tuwien.ac.at/forth/faq/why-forth>. In short,
  203.   Forth's advantages are that it's comprehensible, small, interactive,
  204.   fast, extensible, and makes it easy to work at a high level of
  205.   abstraction.
  206.  
  207.   BTW, this question came from someone comparing a 10+ year old Forth
  208.   system with the latest version of Borland C++. His system was really
  209.   out of date, but also with respect to current Forth systems.
  210.  
  211.   3.5.  Is Forth faster or smaller than C?
  212.  
  213.   Not in itself. I.e., if you translate a C program literally into
  214.   Forth, you will see a slow-down (e.g., a factor 4-8 with Gforth, a
  215.   threaded-code system; for typical native-code systems you will see a
  216.   factor of 1-3). Similarly, there is no inherent size advantage in
  217.   Forth. For details see
  218.   <http://www.complang.tuwien.ac.at/forth/performance.html>.
  219.  
  220.   However, there are many reports of cases where Forth programs beat
  221.   others in size and/or speed. My guess is that the added flexibility of
  222.   Forth helps programmers produce faster and/or smaller programs.
  223.  
  224.   3.6.  What language standards exist for Forth?
  225.  
  226.   An American National Standard for Forth, ANSI X3.215-1994, is accepted
  227.   worldwide as the definitive Forth standard ("ANS Forth").  This
  228.   standard also has been blessed as international standard (ISO/IEC
  229.   15145:1997).
  230.  
  231.   IEEE Standard 1275-1994, the "Open Firmware" standard, is a Forth
  232.   derivative which has been adopted by Sun Microsystems, HP, Apple, IBM,
  233.   and others as the official language for writing bootstrap and driver
  234.   firmware. See  <http://playground.sun.com/1275/home.html>.
  235.  
  236.   Prior Forth standards include the Forth-83 Standard and the Forth-79
  237.   Standard issued by the Forth Standards Team.  The earlier FIG-Forth,
  238.   while never formally offered as such, was a de facto "standard" for
  239.   some years.
  240.  
  241.   "FORTH STANDARDS  Published standards since 1978 are Forth 79 and
  242.   Forth 83 from the Forth Standard Team, and ANS Forth - document
  243.   X3.215-1994 - by the X3J14 Technical Committee.  The most recent
  244.   standard, ANS Forth, defines a set of core words and some optional
  245.   extensions and takes care to allow great freedom in how these words
  246.   are implemented.  The range of hardware which can support an ANS Forth
  247.   Standard System is far wider than any previous Forth standard and
  248.   probably wider than any programming language standard ever. See web
  249.   page  <ftp://ftp.uu.net/vendor/minerva/uathena.htm> for latest
  250.   details. Copies of the standard cost $193, but the final draft of ANS
  251.   Forth is free and available (subject to copyright restrictions) via
  252.   ftp..." --Chris Jakeman, apvpeter.demon.co.uk
  253.  
  254.   The (un)official ANS Forth document is available in various formats at
  255.   <http://www.taygeta.com/forthlit.html> and at
  256.   <ftp://ftp.uu.net/vendor/minerva/x3j14/>. The format I like best is
  257.   the HTML version <http://www.taygeta.com/forth/dpans.html>.
  258.  
  259.   To get yourself on the ANS-Forth mailing list, consult the various
  260.   README files at  <ftp://ftp.uu.net/vendor/minerva/x3j14/>.
  261.  
  262.   Two unofficial test suites are available for checking conformance to
  263.   the ANS Standard Forth:
  264.  
  265.   o  John Hayes has written a test suite to test ANS Standard Systems
  266.      (available through  <http://www.taygeta.com/forth.html>).
  267.  
  268.   o  JET Thomas has written a test suite to test ANS Standard Programs:
  269.      <ftp://ftp.forth.org/pub/Forth/ANS/stand4th.zip>
  270.  
  271.   There is also an ANS Forth FAQ
  272.   <http://dec.bournemouth.ac.uk/forth/ans/faq.html> that explains the
  273.   standardization process.
  274.  
  275.   3.7.  What is an RFI?
  276.  
  277.   A Request For Interpretation. If you find something in the standard
  278.   document ambiguous or unclear, you can make an RFI, and the TC
  279.   (technical committee), that produced the standard, will work out a
  280.   clarification. You can make an RFI by mailing it to greg@minerva.com
  281.   and labeling it as RFI. The answers to earlier RFIs are available at
  282.   ftp://ftp.uu.net/vendor/minerva/x3j14/queries/. They are also
  283.   integrated in the HTML version of the standard
  284.   <http://www.taygeta.com/forth/dpans.html>.
  285.  
  286.   3.8.  Are there Coding Standards for Forth?
  287.  
  288.   Leo Brodie's book Thinking Forth gives some advice; a short excerpt is
  289.   now available online <http://www.forth.org/forth_style.html>. Forth
  290.   shops have rules for their coding. Paul Bennet has published those of
  291.   his company; you can find them on
  292.   <http://www.forth.org/forth_coding.html>.
  293.  
  294.   3.9.  I have trouble managing the stack. Should I use global VARI-
  295.   ABLEs?
  296.  
  297.   No. There are better alternatives:
  298.  
  299.   o  Keep on trying to use the stack. Reorganize (refactor) your words.
  300.      One day you will get the knack for it. Elizabeth Rather
  301.      <mailto:erather@forth.com> writes:
  302.  
  303.        The basic skill required for comfortable, efficient Forth
  304.        programming is good stack management.  It's hard for newcom-
  305.        ers to learn, since it isn't a skill required in other lan-
  306.        guages, which all require the use of variables for practi-
  307.        cally everything.  Having taught literally hundreds of
  308.        courses over the last 25 years, I've seen newcomers wrestle
  309.        with this, and have developed exercises (similar to those in
  310.        Starting Forth) to help.  It seems to be a skill rather like
  311.        riding a bicycle: wobbly & scary at first, then suddenly a
  312.        "switch is thrown" in the brain and it seems comfortable and
  313.        natural ever after.
  314.  
  315.   Andrew Haley writes in Message-ID: <7k8lln$q3c$1@korai.cygnus.co.uk>:
  316.  
  317.        Try writing all of your code using definitions one, or at
  318.        most two lines long.  Produce a stack digram for each word
  319.        showing its inputs and its outputs.  If you ever need an
  320.        "intermediate" stack diagram to see what's going on, split
  321.        your word at that point into two words.  By doing this, you
  322.   may test each half of the word on the command line, checking
  323.   the stack each time.  Do not use PICK and ROLL.
  324.  
  325.   Once you get the hang of writing code in this way you can
  326.   relax these rules, but it's much better to get used to this
  327.   style first.
  328.  
  329.   o  Use the return stack.
  330.  
  331.   o  Use locals.
  332.  
  333.   o  Use data structures in memory, and pass pointers to it on the
  334.      stack.
  335.  
  336.   o  One area that has been mentioned often as troublemaker is graphics
  337.      programming. Take a look at how Postscript handles this: They do
  338.      indeed have a global state to avoid stack management problems, but
  339.      you can access this state only through certain words.
  340.  
  341.   3.10.  What is the Forth Interest Group?
  342.  
  343.   The Forth Interest Group "FIG" was formed in 1978 to disseminate
  344.   information and popularize the Forth language, and it remains the
  345.   premier organization for professional Forth programmers.  FIG
  346.   maintains a Web page at  <http://www.forth.org/forth.html>, with a
  347.   more complete introduction to the Forth language, and links to the Web
  348.   pages of many Forth vendors.
  349.  
  350.   3.11.  Who is Chuck Moore and what is he doing?
  351.  
  352.   Chuck Moore discovered (as he puts it) Forth (for historical
  353.   information read The Evolution of Forth
  354.   <http://www.forth.com/Content/History/History1.htm>).  He later went
  355.   on to apply his design philosophy to hardware design and designed a
  356.   number of processors well-suited for executing Forth: Novix 4016,
  357.   Shboom, uP20, uP21, F21, i21, ...
  358.  
  359.   He also explored new ideas and refined his earlier ideas on software
  360.   and Forth: his cmForth for the Novix has been quite influential.  His
  361.   latest developments are Color Forth and Machine Forth.
  362.  
  363.   Machine Forth is a simple virtual machine consisting of 27
  364.   instructions.  It is implemented in hardare in uP21 and the following
  365.   chips, but has also been implemented in software on the 386 as simple
  366.   native-code system.  Some of the differences from ANS Forth are that
  367.   each stack entry contains an extra carry bit, and that there is
  368.   register A for accessing memory (instead of addressing through the top
  369.   of stack).
  370.  
  371.   4.  Flame baits
  372.  
  373.   Some statements spawn long and heated discussions where the
  374.   participants repeat their positions and ignore the arguments of the
  375.   other side (flame wars). You may want to avoid such statements.
  376.  
  377.   Here, I present some regularly appearing flame baits and the positions
  378.   you will read (so you don't have to start a flame war to learn them).
  379.  
  380.   4.1.  Commercial vs. free Forth systems
  381.  
  382.   "You get what you pay for. With a commercial Forth you get commercial
  383.   documentation and support. We need commercial Forth systems or Forth
  384.   will die."
  385.  
  386.   "I have had good experiences with free Forths. I cannot afford a
  387.   commercial Forth system. I want source code (some commercial vendors
  388.   don't provide it for the whole system). Examples of bad support from
  389.   commercial software vendors. Without free Forth systems Forth will
  390.   die."
  391.  
  392.   4.2.  Free Forth systems are bad for Forth.
  393.  
  394.   "Anyone can write a bad Forth and give it away without documentation
  395.   or support; after trying such a system, nobody wants to work with
  396.   Forth anymore. Free Forths give Forth a bad name. Free Forths take
  397.   business away from the vendors."
  398.  
  399.   "Many people learned Forth with fig-Forth. There are good free Forths.
  400.   Most successful languages started with (and still have) free
  401.   implementations. Languages without free implementations (like Ada,
  402.   Eiffel and Miranda) are not very popular [There are free Ada and
  403.   Eiffel implementations now]."
  404.  
  405.   4.3.  Blocks vs. files
  406.  
  407.   The discussions on this topic are much cooler since Mike Haas has
  408.   dropped from comp.lang.forth.
  409.  
  410.   "Everyone is using files and all third-party tools are designed for
  411.   files. Files waste less space. Blocks lead to horizontal, unreadable
  412.   code. Blocks make Forth ridiculous."
  413.  
  414.   "We are not always working under an operating system, so on some
  415.   machines we don't have files. We have very nice block editors and
  416.   other tools and coding standards for working with blocks (e.g., shadow
  417.   screens)."
  418.  
  419.   4.4.  LOCALS|
  420.  
  421.   Everyone who mentions using LOCALS| gets the following flame from me:
  422.  
  423.   LOCALS| is bad because the locals are ordered contrary to the stack
  424.   comment convention. I.e.:
  425.  
  426.   ______________________________________________________________________
  427.   : foo ( you can read this -- ... )
  428.    LOCALS| this read can you | ... ;
  429.   ______________________________________________________________________
  430.  
  431.   The following locals syntax is better and widely used:
  432.  
  433.   ______________________________________________________________________
  434.   : foo { you can read this -- ... }
  435.    ... ;
  436.   ______________________________________________________________________
  437.  
  438.   You can find an implementation of this syntax in ANS Forth at
  439.   <http://www.complang.tuwien.ac.at/forth/anslocal.fs>
  440.  
  441.   5.  Miscellaneous
  442.  
  443.   5.1.  Where can I find a C-to-Forth compiler?
  444.  
  445.   Parag Patel <mailto:parag@pinhead.parag.codegen.com> writes:
  446.  
  447.        We, (CodeGen, Inc. <http://www.codegen.com>) sell a C-to-
  448.        Fcode compiler.  Well, it actually generates IEEE-1275 Forth
  449.        that then must be run through a tokenizer.
  450.  
  451.        Really, it generates pretty ugly Forth code.  It's easy to
  452.        generate lousy Forth, but it's very difficult to generate
  453.        nice clean optimized Forth.  C and stack-based languages
  454.        don't mix too well.  I end up faking a C variable stack-
  455.        frame using a Forth $frame variable for local vars.
  456.  
  457.   Stephen Pelc <mailto:sfp@mpeltd.demon.co.uk> writes:
  458.  
  459.        MPE has produced a C to stack-machine compiler. This gener-
  460.        ates tokens for a 2-stack virtual machine. The code quality
  461.        is such that the token space used by compiled programs is
  462.        better than that of the commercial C compilers we have
  463.        tested against. This a consequence of the virtual machine
  464.        design.  However, to achieve this the virtual machine design
  465.        has local variable support.
  466.  
  467.        The tokens can then be back end interpreted, or translated
  468.        to a Forth system. The translater can be written in high
  469.        level Forth, and is largely portable, except for the target
  470.        architecture sections.
  471.  
  472.        These are not shareware tools, and were written to support a
  473.        portable binary system.
  474.  
  475.   5.2.  Where can I find a Forth-to-C compiler?
  476.  
  477.   An unsupported prototype Forth-to-C compiler is available at
  478.   <http://www.complang.tuwien.ac.at/forth/forth2c.tar.gz>. It is
  479.   described in the EuroForth'95 paper
  480.   <http://www.complang.tuwien.ac.at/papers/ertl&maierhofer95.ps.gz>.
  481.   Another Forth-to-C compiler is supplied with Rob Chapman's
  482.   <mailto:rc@compusmart.ab.ca> Timbre
  483.   <http://www.compusmart.ab.ca/rc/Timbre/timbre.htm> system.
  484.  
  485.   5.3.  RECORDS in Forth?
  486.  
  487.   Many packages for data structuring facilities like Pascal's RECORDs
  488.   and C's structs have been posted. E.g., the structures of the Forth
  489.   Scientific Library ( <http://www.taygeta.com/fsl/fsl_structs.html>) or
  490.   the structures supplied with Gforth
  491.   <http://www.complang.tuwien.ac.at/forth/struct.fs>.
  492.  
  493.   5.4.  Why does THEN finish an IF structure?
  494.  
  495.   Some people find the way THEN is used in Forth unnatural, others do
  496.   not.
  497.  
  498.   According to Webster's New Encyclopedic Dictionary, then" (adv.) has
  499.   the following meanings:
  500.  
  501.        2b: following next after in order ... 3d: as a necessary
  502.        consequence (if you were there, then you saw them).
  503.  
  504.   Forth's THEN has the meaning 2b, whereas THEN in Pascal and other pro-
  505.   gramming languages has the meaning 3d.
  506.  
  507.   If you don't like to use THEN in this way, you can easily define ENDIF
  508.   as a replacement:
  509.  
  510.   ______________________________________________________________________
  511.   : ENDIF  POSTPONE THEN ; IMMEDIATE
  512.   ______________________________________________________________________
  513.  
  514.   5.5.  What is threaded code? What are the differences between the dif-
  515.   ferent threading techniques?
  516.  
  517.   Threaded code is a way of implementing virtual machine interpreters.
  518.   You can find a more in-depth explanation at
  519.   <http://www.complang.tuwien.ac.at/forth/threaded-code.html>.
  520.  
  521.   5.6.  Has anyone written a Forth which compiles to Java bytecode?
  522.  
  523.   Paul Curtis <mailto:paul.curtis@ra-ltd.demon.co.uk> writes:
  524.  
  525.   The JVM, although a stack machine, can't really be used to compile
  526.   Forth efficiently.  Why?  Well, there are a number of reasons:
  527.  
  528.   o  The maximum stack depth of a called method must be known in
  529.      advance. JVM Spec, p. 111
  530.  
  531.   o  JVM methods can only return a single object to the caller.  Thus, a
  532.      stack effect ( n1 n2 -- n3 n4 ) just isn't possible.
  533.  
  534.   o  There is no direct support for unsigned quantities.
  535.  
  536.   o  CATCH and THROW can't be resolved easily; you need to catch
  537.      exceptions using exception tables.  This doesn't match Forth's
  538.      model too well.  JVM Spec, p. 112
  539.   o  You'd need to extend Forth to generate the attributes required for
  540.      Java methods.
  541.  
  542.   o  There is no such thing as pointer arithmetic.
  543.  
  544.   o  You can't take one thing on the stack and recast it to another
  545.      type.
  546.  
  547.   o  You can't manufacture objects out of raw bytes.  This is a security
  548.      issue.
  549.  
  550.   o  There is no support for the return stack.
  551.  
  552.   That said, it is possible to write something Forth-like using JVM
  553.   bytecodes, but you can't use the JVM stack to implement the Forth
  554.   stack.  ...
  555.  
  556.   If you're serious, try getting Jasmin and programming directly on the
  557.   JVM.
  558.  
  559.   5.7.  What about translating Java bytecode to Forth?
  560.  
  561.   Some of the non-trivial pieces in translating JavaVM to Forth, that we
  562.   have identified, are:
  563.  
  564.   o  garbage collection
  565.  
  566.   o  threads
  567.  
  568.   o  control structures (branches->ANS Forth's seven universal control
  569.      structure words)
  570.  
  571.   o  exceptions
  572.  
  573.   o  subroutines (JavaVM does not specify that a subroutine returns to
  574.      its caller)
  575.  
  576.   o  JavaVM makes the same mistake as Forth standards up to Forth-83: It
  577.      specifies type sizes (e.g., a JavaVM int is always 32-bit). A few
  578.      operators have to be added to support this.
  579.  
  580.   o  The native libraries (without them JavaVM can do nothing).
  581.  
  582.   5.8.  How about running Forth without OS?
  583.  
  584.   A Forth system running on the bare hardware is also known as a native
  585.   system (in contrast to a hosted system, which runs on an OS).  Don't
  586.   confuse this with native-code systems (which means that the system
  587.   compiles Forth code to machine code); hosted native-code systems exist
  588.   as well as native threaded-code systems.
  589.  
  590.   In the beginning Forth systems were native and performed the functions
  591.   of an OS (from talking to hardware to multi-user multi-tasking).  On
  592.   embedded controllers Forth systems are usually still native.  For
  593.   servers and desktops most Forth-systems nowadays are hosted, because
  594.   this avoids the necessity to write drivers for the wide variety of
  595.   hardware available for these systems, and because it makes it easier
  596.   for the user to use both Forth and his favourite other software on the
  597.   host OS.  A notable exception to this trend are are the native systems
  598.   from Athena.
  599.  
  600.   5.9.  How about writing an OS in Forth?
  601.  
  602.   Native Forth systems can be seen as OSs written in Forth, so it is
  603.   certainly possible.  Several times projects to write an OS in Forth
  604.   were proposed.  Other posters mentioned the following reasons why they
  605.   do not participate in such a project:
  606.  
  607.   If you want to write an OS in Forth for a desktop or server systems,
  608.   the problems are the same as for native Forth systems (and any other
  609.   effort to write a new OS): the need to write drivers for a wide
  610.   variety of hardware, and few applications running on the OS.
  611.  
  612.   To get around the application problem, some posters have suggested
  613.   writing an OS that is API or even ABI compatible with an existing OS
  614.   like Linux.  If the purpose of the project is to provide an exercise,
  615.   the resulting amount of work seems excessively large; if the purpose
  616.   is to get an OS, this variant would be pretty pointless, as there is
  617.   already the other OS.  And if the purpose is to show off Forth (e.g.,
  618.   by having smaller code size), there are easier projects for that, the
  619.   compatibility requirement eliminates some of the potential advantages,
  620.   and not that many people care about the code size of an OS kernel
  621.   enough to be impressed.
  622.  
  623.