从哪个 Forth 开始移植?

发布于 2024-09-08 08:49:31 字数 583 浏览 3 评论 0 原文

我正在寻求开发一个新的 Forth 系统,旨在使游戏开发变得更容易在一个或可能多个复古控制台平台上。我是一个 Forth 初学者,需要您的帮助来决定从哪个 Forth 代码库开始移植。

我基本上是在寻找特定 Forth 之间的优点/缺点。我已阅读 JonesFORTH 的来源以及对其的赞扬和批评以及关于 ANS 的讨论,不幸的是,我们感到相当困惑。据我所知,Forth 社区似乎在标准合规问题上存在相当残酷的分歧,两个阵营都就为什么该标准既是好事又是坏事提出了很好的论据。然而,我似乎无法找到关于标准到底发生了什么变化的良好实用建议,除了一般意义上的标准,它使事情变得比他们可能需要的更加复杂和臃肿。

我希望让目前被汇编或 C 语言开发前景吓倒的程序员和爱好者的开发变得更容易,所以我倾向于更简单的 Forth,但我真的对 Forth 还不够了解,还无法做出一个受过教育的决定。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

单调的奢华 2024-09-15 08:49:31

我和你现在的情况差不多。我已经随意阅读 Forth 一段时间了,并且认为它有很大的潜力——也许对于脚本编写也有很大的潜力。然而,我远非权威,但这是我的想法。

首先,Forth 似乎是终极的可编程编程语言——甚至超过了 lisp。为此,我不确定您需要编写多少 C 或汇编代码。我更倾向于在 Forth 本身中开发词汇。毕竟,这就是它应该如何使用的。

其次,在我尝试过的实现中,我最喜欢 Gforth 和 Pforth。

您正在使用哪些?

最后,这是我发现的在线第四阅读列表:

  • 出发
  • 思考
  • Forth 入门
  • Forth 语言
  • Forth 教程
  • Pforth 教程
  • 第四本手册
  • 开始吧
  • WikiForth
  • OLPC Forth
  • 让我们构建一个编译器
  • 你还发现其他人吗?

    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?

    娇女薄笑 2024-09-15 08:49:31

    一个基本的Forth系统非常小,并且可以很快实现。我认为以下页面对您非常有用:“A 有时最小的 Forth 编译器和教程对于 Linux / i386 系统”。这是一个关于引导 Forth 系统的线性教程!

    确保实现定义字(在编译时执行的字)。这就是Forth力量的来源;使其真正可扩展。

    我实际上并没有尝试过,但我曾经选择过 bigFORTH ,因为它是少数拥有开源许可证的 Forth 之一。它也得到积极维护;例如,今年早些时候发布了一个版本。

    在过去的几年里,我收集了一组关于 Forth 的带注释的链接。有些东西很难找到。

    关于标准的讨论:这是一个有 20 年历史的讨论。我认为实际做一些事情比空谈更重要:实施软件、提供杀手级示例、编写文档、邀请其他人参与等等。查尔斯·摩尔此后继续前进并完成了Forth 芯片, machineForthColorFORTH。如果您在带注释的链接列表中搜索“machineForth”和“ColorFORTH”,则可以找到一些有趣的文章和声明。
    Charles Moore 现在也有一个博客

    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.

    分分钟 2024-09-15 08:49:31

    作为第一步,您可能想要尝试的一件事是用一些更高级的语言(如 Java、C++、Python 等)编写 Forth 解释器。它缺乏机器级 Forth 的主要优点:速度和紧凑性,但通过通过编写自己的虚拟机,您将了解 Forth 的各种风格中使用的不同类型的线程等。

    无论如何,大多数新的 Forth 实现基本上都是从将 CPU 视为虚拟机开始的——因此,当从解释版本转移到机器代码版本时,制作显式虚拟机并不是浪费知识。此外,您还将拥有自己的代码蓝图,以便在构建机器版本时进行交叉引用。

    但是,如果您真的非常熟悉机器代码,您可能可以跳过上述步骤,直接移植其中一个标准。

    就标准而言,我会选择一些标准,但一开始就保持最低标准。如果您需要在用户定义的单词以外的方面超越标准,那么您始终可以根据实现需求的要求,朝着标准或非标准的方向发展。 Forth 最酷的事情之一是它非常简单,您可以更轻松地重写整个编译器,而不是重写将在其上运行的一些 Forth 代码,哈哈。

    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.

    与之呼应 2024-09-15 08:49:31

    我建议寻找 eForth,Ting 写的那一篇。在某些方面有点像现代图。他有一个用 C 编写的内核,但 eForth 内核/系统已经被移植到许多平台/CPU,大多数都有汇编内核/核心。然而,有一个很酷的东西叫做 Factor。它最初只是为了“游戏”,最终却进入了编程语言世界的一个狂野而有趣的角落

    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

    禾厶谷欠 2024-09-15 08:49:31

    Gameduino,一个基于 Arduino 的游戏开发平台,内部运行着一个最小的第四个 CPU(J1) 。

    除了J1 fort的Verilog源代码外,还有一个PC模拟器,一个用 google go 编写的编译器,此处,由 Serge Zaitsev 编写。

    J1 已在 Xilinx FPGA 中实现。还可以在任何现代 MCU 上“模拟”J1 CPU。

    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.

    花想c 2024-09-15 08:49:31

    关于 ANSI 兼容性,如果您在自己的应用程序中使用 Forth,则可以省略任何不需要的内容,甚至更改您不喜欢的内容。间接线程 Forth 是 16 位处理器上最紧凑的处理器之一(64 位处理器上不再如此)。所以这可能是要走的路。

    间接螺纹 Forth 系列称为Fig-Forth 仍然是教育材料。琼斯福斯是福斯的一个例子,也是同样的风格。我本人是 ciforth 的作者,它是 jonesforth 和 yourforth 的灵感之一,这可能值得你花时间,因为它试图解释设计事物的原因。
    Ting 的 eforth(到处都是)和 Camelforth 也是很好的例子。 gforth 绕道 c,它的体积对你来说没有什么价值。

    一个一般建议是,如果您需要一个代码字(用汇编程序编码,而不是 Forth,最低级别),您最好窃取它,然后重新实现。除最不起眼的处理器之外的所有处理器上的 32 位乘 16 位除法代码肯定会在某个地方找到。因此,收集一些在您正在使用的处理器上实现的 Forth。

    您必须选择一个处理器,这将把您锁定在很大程度上然后您可以只使用 Camelforth 之一(因为它适用于最流行的处理器)并开始您的应用程序。如果您不太满意,您可以修改它以成为您自己的 Forth。如果您使用的是 6809 或 Renesas 处理器,或者 16 位 i86,您可以使用我的 ciforth 作为起点。

    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.

    晨与橙与城 2024-09-15 08:49:31

    我知道这是一个老问题,但根据记录,另一个伟大的开头是“ff”(菲利克斯向前)。

    这里有用 x86 (NASM) 和 ARM (gas) 编写的汇编版本。

    最新版本是用创建者在第四个版本中创建的汇编程序编写的 自己的页面

    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.

    ~没有更多了~
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文