Which Forth to start porting from?
Asked Answered
D

7

27

I'm looking to develop a new Forth system, aimed at making game development easier on one or possibly several retro console platforms. I'm something of a Forth beginner, and need your help deciding which Forth codebase to start porting from.

I'm basically looking for the merits / disadvantages of particular Forths vs each other. I've read the source to JonesFORTH as well as both praise and criticism of it, and discussions on ANS forth, and have unfortunately been left feeling rather confused. The Forth community, from what I can tell, seems to be fairly brutally divided along the standards-compliance issue, with very good arguments made by both camps as to why the standard is both a good, and a terrible, thing. However I cannot seem to find good practical advice on what exactly the standard changes, other than a general sense that it makes things more complicated and bloaty than they perhaps need to be.

I'm hoping to make development easier for programmers and hobbyists currently scared off by the prospect of developing in assembly or C, so I'm leaning towards a more simple Forth, but I really don't know enough about Forth yet to make an educated decision.

Delores answered 8/7, 2010 at 16:29 Comment(0)
I
9

I'm kind of where you are right now. I've been casually reading up on Forth for a while and also think it has a lot of potential--maybe for scripting too. However, I am nowhere near an authority, but here are my thoughts.

First of all, Forth seems to be the ultimate programmable programming language--even more than lisp. To that end, I'm not sure how much C or assembly you'll need to code. I was leaning more towards developing vocabularies in Forth itself. After all, that's how it's supposed to be used.

Second, of the implementations I've tried, I like Gforth and Pforth the best.

Which ones are you using?

Finally, here is a list of online forth reading I've discovered:

  • Starting Forth
  • Thinking Forth
  • Forth Primer
  • Forth Language
  • Forth Tutorials
  • Pforth Tutorial
  • Gforth Manual
  • Begin Forth
  • WikiForth
  • OLPC Forth
  • Lets Build a Compiler
  • Have you found any others?

    Israelisraeli answered 15/7, 2010 at 18:0 Comment(0)
    S
    5

    A basic Forth system is very small and can quickly be implemented. I think the following page will be very useful for you: "A sometimes minimal Forth compiler and tutorial for Linux / i386 systems". It is a linear tutorial on bootstrapping a Forth system!

    Be sure to implement the defining words (words executing at compile time). That is where the power of Forth comes from; making it truly extensible.

    I haven't actually tried it, but I once settled for bigFORTH as it is one of the few Forths with an open source license. It is also actively maintained; for instance there was a release earlier this year.

    I have collected a set of annotated links about Forth over the past few years. Some of it is hard to find stuff.

    Regarding the standards talk: this is a 20 year old discussion. I think it is more important to actually do something instead of talking: implement software, provide killer examples, writing documentation, invite other to participate, etc. Charles Moore has since moved on and done Forth chips, machineForth and ColorFORTH. If you search for "machineForth" and "ColorFORTH" in the annotated list of links it is possible to find some interesting articles and statements. Charles Moore also has a blog now.

    Swarts answered 20/7, 2010 at 20:28 Comment(0)
    S
    4

    One thing you might want to try as a first step is to write a Forth interpreter in some higher level language like Java, C++, Python, etc. It will lack the main benefits of a machine-level Forth: speed and compactness, but by writing your own virtual machine, you'll gain an understanding of the different types of threading, etc., used in various flavors of Forth.

    Most new Forth implementations are basically started by looking at the CPU as a virtual machine anyway -- so making an explicit virtual machine is not knowledge wasted when it comes times to move from an interpreted version to a machine-code version. Also, you'll have a blueprint of your own code to cross-reference when building the machine version.

    If, however, you are really, really comfortable with machine code, you can probably skip the above step and just port one of the standards directly.

    As far as standards, I'd pick some standard, but stay minimal to start with. If you need to go beyond a standard in terms of things other than user-defined words, you can always grow towards that -- either standard or non-standard -- as implementation needs dictate. One of the coolest things about Forth is that it's so simple you can re-write the entire compiler easier than you can re-write some of the Forth code you'll be running on it, lol.

    Sweep answered 28/7, 2010 at 21:48 Comment(0)
    S
    2

    I recommend hunting up eForth, the one Ting wrote. Kind of a modern FIG forth in some ways. He has a kernel written in C, but eForth kernels/systems have already been ported to many platforms/cpus most have assembly kernels/cores. However, there's this cool kinda-forth called Factor. It started out as 'just for games' and ended up in a wild and fun corner of the programming language world

    Signify answered 21/7, 2010 at 20:16 Comment(0)
    K
    2

    Gameduino, a game development platform on top of Arduino, has a minimal forth CPU (J1 forth) running inside.

    In addition to the Verilog source code of J1 forth, there is also a PC simulator, a compiler written in google go, here by Serge Zaitsev.

    J1 is already implemented in Xilinx FPGA. It is also possible to "simulate" the J1 CPU on any modern MCU.

    Kern answered 19/10, 2013 at 13:10 Comment(0)
    E
    2

    Regarding ANSI compatibility, if you're using Forth for your own application you can leave out anything that you don't need, or even change things you don't like. Indirect threaded Forths are among the most compact on 16 bit processors ( no more on 64-bitters). So this is probably the way to go.

    The famility of indirect threaded Forth's called FIG-Forth are still educative material. jonesforth is an example of Forth's that go on in the same vein. I myself am the author of ciforth that was one of the inspirations for jonesforth and of yourforth, that is probably worth your while because it tries to explain the reasons for designing things the way they are. Ting's eforth (all over the place) and Camelforth are good examples too. gforth with its detour via c and its bulk is less valuable to you.

    One general advice, if you need a code word (coded in assembler, not Forth, the lowest level) you're better off stealing it, then reimplementing. Code for a say 32 bit by 16 bit divide on all but the most obscure processors is bound to be found somewhere. So collect a few Forth's that are implemented on the processor you're using.

    You must select a processor and that will lock you in pretty much Then you can just use one of the Camelforth's (because it is there for most popular processors) and start with your application. If you're not quite happy you can modify it to become your own Forth. If you're on the 6809 or the Renesas processor, or an 16 bit i86 you can use my ciforth as a starting point.

    Enumeration answered 9/2, 2015 at 22:0 Comment(0)
    T
    1

    I know this is an old question but for the record, another great forth to start of with is "ff" (Felix forth).

    There is the assembly version which is written in x86 (NASM) and ARM (gas) here.

    And the more recent versions written with an assembler created in the forth itself from the creators own page.

    Taryn answered 18/1, 2019 at 5:8 Comment(0)

    © 2022 - 2024 — McMap. All rights reserved.