Live data from Hacker News

Collapse OS – Why Forth?

collapseos.org

111–120 of 172 posts

Re: Collapse OS – Why Forth?

#112
post #103

I want to learn forth now. Where can I find a modern usable forth that works well on windows to make real programs? Does such a thing even exist?

You can do just fine with the free versions of SwiftForth and VFX Forth as long as you don't mind that they are 32bit only.

If you end up liking it and want 64bit, you can buy iForth for 100 EUR. It's what I use.

These are all amazing optimizing compilers.

If you care about OSS: Don't waste your time with GForth. If you want something simple that you can hack yourself, take a look at pforth.

Re: Collapse OS – Why Forth?

#113
post #59

Earlier quoted context omitted.

- It's tiny and dead simple to implement - It sits very close to assembly - It allows high-level programming like in C - The concept of pushing/popping things onto/off the stack is a relatively straightforward programming model when done consistently One of the old competitors to the likes of UEFI and uBoot is OpenFirmware (also known as OpenBoot), for which the primary UI is a Forth shell; OpenFirmware was the BIOS…

Also works great with graphics. PostScript is similar to Forth.

I got into Forth recently - using Gnu Forth - but got bogged down at my inability to do graphics. There are hardly any Forth programming videos of any kind online, besides the "101" kind, but I found one by a guy who managed to get graphics/windows going, I think with GForth. (Can't find it on youtube now.) Looked mega-complicated. So lately back into Tcl/Tk, which also satisfies my "bizarre, powerful and very cool language" itch but actually makes graphics/windows super-easy. I do think Forth is awesome though!

After getting into Forth I got into PostScript, which does have most of the Forth fun/freedom taken out of it. It's not usable for GUI-type programming is it?

Re: Collapse OS – Why Forth?

#114
post #38
post #25

Earlier quoted context omitted.

For me this is slightly into Poe's Law territory: Is this actual prepper mindset, or tongue-in-cheek?

Thanks. I'd never heard of that law before. I think he's serious. I'll appreciate his work both pre and pos civilisation collapse. I like his software aesthetic too. Maybe I'm getting old, maybe I'm seeking more control, maybe the world has come needlessly complex, but there's a certain appeal about returning to more manageable days, where it was possible to fit a software and hardware system in your brain, and your…

I liked playing the Fallout games, I grew up with 8 bit machines, so I'm all in at using a post-apocalyptic scenario as a setup for a though experiment tech stack. In a "ha ha only serious" manner.

But on the other hand, real preppers scare the effing s out out of me.

Re: Collapse OS – Why Forth?

#115

Earlier quoted context omitted.

Seems like an IR would make sense here. Perhaps a stack-based one. If you need a compact program representation, that doesn't mean you have to use FORTH as your source language.

I think the argument against a custom IR is that once you start optimising your IR for compactness you'll probably end up near Forth in the design space anyway. As you say perhaps making the IR stack-based. Once you're at that point you may as well just use Forth, especially since it's got a proven ability to work in these kinds of resource contrained, self-hosting/self-bootstrapping environments.

> you'll probably end up near Forth in the design space anyway

Good point. Related to this, FORTH can be treated as a target platform for compilers, although I don't think there are many mature compilers that do this.

I wonder if CollapseOS will ever seriously target heavyweight platforms like x64 (and not just through emulation with libz80). I suppose that's out scope, but it would open the door to JIT.

> you may as well just use Forth

Presumably it could be a little more compact if a less human-readable variation were used, no? FORTH uses DROP and THEN, which could be shortened at the cost of readability.

Re: Collapse OS – Why Forth?

#116

If this gets you interested in z80 hardware, I would recommend building an RC2014: https://rc2014.co.uk/ I built an RC2014 after CollapseOS was posted last year, and thoroughly enjoyed it. I ended up adding a front panel, complete with switches and lights, to allow toggling in and executing code without a ROM, and also wrote a HTTP/1.0 server for CP/M (which was an enormous headache for lots of different reasons). Ne…

I love this project, and check in on it every few months. I particularly like the idea of scavenging hardware: > With a copy of this project, a capable and creative person should be able to manage to build and install Collapse OS without external resources (i.e. internet) on a machine of her design, built from scavenged parts with low-tech tools. I'd be interested in trying to build my own proof-of-concept, but my ha…

Definitely read (at least the first chapters of) the Z80 cpu manual: http://z80.info/zip/z80cpu_um.pdf

It gets a bit dry when it gets to the bit that documents the individual instructions, but the overview before that point is well worth reading.

Once you've done that and you're trying to write code, this page is a good reference for the instructions: http://clrhome.org/table/

To build a scavenged machine, you'll need a Z80 CPU, a clock source (I think an RC oscillator would be the simplest working setup?), probably some sort of ROM, an SRAM, some sort of IO device (probably a Z80 SIO/2 for serial), and a 5V power supply. I think that should be all that is required. Then you need to load your code into the ROM at address 0.

Then you can connect the SIO to a USB serial cable (e.g. FTDI) and communicate with your Z80 using a modern PC.

I can't remember if the SIO/2 needs external address decoding logic, maybe you could cope without it if you are happy for it to use up every address?

But building an RC2014 would be easier and more likely to result in a working machine, and would give you almost all the knowledge required to build a scavenged one later if you still want to.

Re: Collapse OS – Why Forth?

#117

The weird thing about history is that it only makes sense backwards. Someone 500 years in the future might think of this as the Gutenberg printing press. It is often difficult to appreciate the magnitude of actions in the present.

Why should they think that? The gutenberg press was used in the real world. There are lots of OS being used in the real world for real work. So why should someone in 500 years think this is more relevant, than for example Linux? And if there is a real collapse, then I also do not really believe everyone makes a run for collapseOS. There are other options: all the ones, tinkerers and hackers use already today.

We don't know how history will pan out. Just wanted to share the weird feeling I sometimes have about current events. For all we know, post-collapse technology could be based off QMX reverse-engineered from luxury vehicles. It's just fun to think about how events can have that unexpected butterfly effect. I sometimes catch myself with the implicit belief that we are "late" in the story of history. But given the possible expanse of time, we might be the "hunter-gatherers" of a civilization we cannot even begin to comprehend. This might just be the second of the dark ages.

Re: Collapse OS – Why Forth?

#118

Forth is Lisp, but with composition as the basic operator instead of application. The result, of course, is a wildly different language but one which inspired the same degree of fanaticism among its adherents in their search for simplicity and elegance. A truly under appreciated language imho.

I rather disagree with your first sentence. Forth is not Lisp, nor is Prolog or APL Lisp, and none of these languages are one short conceptual leap away from the others. Even a very rudimentary Forth can express concepts which have only hazy correspondences in a Lisp, like words which twiddle the return stack or yield a variable number of results on the parameter stack. I find it misleading at best to casually intima…

What Forth and Lisp have in common is that they're interactive language construction sets. You don't just write domain code the way you do in C. You invent a language that matches the domain and use that to solve the problem. Don't like the syntax? Change it. Don't like the conditional statement? Invent a new one. Don't like the compiler? Improve it.

These kinds of operations are behind the curtain in C but they're accessible to everybody in Forth and Lisp.

Re: Collapse OS – Why Forth?

#120

Earlier quoted context omitted.

Why not say "Every ~~Forth~~ program is its own DSL for accomplishing its work."? For moderately complicated programs in any language you choose, it can take a long time to grok how the literal code relates to solving the conceptual problem. No language can build in every abstraction, and no programmer has time to learn them all. I think you are close to part of an answer, but it isn't because Forth and Lisp expect o…

To be fair, it is very common for Forth programmers to redefine the interpreter as they go. You literally change the language in your program. That's a very different expectation for other kinds of languages.

> You literally change the language in your program. That's a very different expectation for other kinds of languages.

I wonder about that. A few weeks back I read about a coroutines implementation in C, using plain C and lots of intricate preprocessor definitions:

https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html

There are similar examples in just about any language out there. People use whatever tools the language ecosystem provides to change the language to fit some problems better. Some languages are easier to change and extend, some are harder, but that doesn't stop people from trying to do this anyway.

I think there's a level of familiarity with the language above which changing it is a natural thing to do. It can take years before you learn a "normal" language well enough to be able to do this, but with Forth, Scheme, Prolog, and the like, you're basically required to do this from the get-go. My intuition is that these languages simply target advanced, already experienced programmers, while completely ignoring the beginners. So it's more of the optimization for a different user-base, IMO. That would also explain how these languages are still alive, despite their communities being very small for the last 50 years.

Post reply on HN