Stories
Slash Boxes
Comments

SoylentNews is people

SoylentNews is powered by your submissions, so send in your scoop. Only 18 submissions in the queue.
posted by Fnord666 on Wednesday June 10 2020, @02:57AM   Printer-friendly
from the a-new-OS-is-forth-coming dept.

It appears the leadership of Collapse OS have decided to switch from Z-80 to Forth. In this article, they explain their reasoning.

Collapse OS' first incarnation was written in Z80 assembler. One of the first feedbacks I had after it went viral was "why not Forth?". I briefly looked at it and it didn't seem such a great choice at first, so I first dismissed it. Then, I had what alcoholics refer to as a "Moment of clarity".

[...] The Z80 asm version of Collapse OS self-hosts on a RC2014 with a 5K shell on ROM, a 5K assembler binary loaded in RAM from SD card (but that could be in ROM, that's why I count it as ROM in my project's feature highlights) and 8K of RAM. That is, it can assemble itself from source within those resources.

[...] If I wanted to re-implement that assembler feature-for-feature in Forth, it would probably require much more resources to build. Even though higher level words are more compact, the base of the pyramid to get there couldn't compete with the straight assembler version. This was under this reasoning that I first dismissed Forth.

So, again, what makes Forth more compact than assembler? Simplicity. The particularity of Forth is that it begins "walking by itself", that is, implementing its own words from its base set, very, very early. This means that only a tiny part of it needs to be assembled into native code. This tiny part of native code requires much less tooling, and thus an assembler with much less features. This assembler requires less RAM.

What is more compact than something that doesn't exist? Even Z80 assembler can't beat the void.

That's how although Forth is not more compact that native code (duh!), a Forth Collapse OS achieves self-hosting with as much resources than its Z80 counterpart.


Original Submission

 
This discussion has been archived. No new comments can be posted.
Display Options Threshold/Breakthrough Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by maxwell demon on Thursday June 11 2020, @05:11AM

    by maxwell demon (1608) on Thursday June 11 2020, @05:11AM (#1006182) Journal

    but also, depending on a multi-megabyte kernel

    No. Those multi-megabyte kernels are the "compile everything in, just in case" distribution kernels. I strongly doubt a compiler would need anything that wasn't already in Linux 1.0 in its minimal configuration. Indeed, I suspect even the earliest released 0.x version had the ability to run a compiler.

    Unfortunately I couldn't find any data on the size of those early kernels. But then, even the earliest kernels had stuff that isn't strictly necessary for a compiler to run. For example, if you removed all the networking and multiuser code, I'm pretty sure you'd get a massive shrinkage of the kernel (it would no longer really be Linux, but the point is, it would still be able to run the compiler).

    --
    The Tao of math: The numbers you can count are not the real numbers.
    Starting Score:    1  point
    Karma-Bonus Modifier   +1  

    Total Score:   2