MilliForth-6502: The smallest Forth real programming language for 6502
github.com
github.com
1. I want to debug my assembly code with a REPL
2. I don't want abstraction, I want minimalism
3. I want to write solutions in the context of specific hardware
When you have all three, you have Forth's wheelhouse. Minimalism means you do get a sense of "seeing the Matrix" - the machine is controlled precisely to your specification. But as soon as you think that you can layer on a more abstract idiom, even those that are usually conventional in high level programming, it also reveals that it really won't help you do that. Either you DIY that abstraction, or you revert to the same load-store imperative paradigms you'd use for a large assembly program.
The answer everyone else is using is to add an operating system and an application language as a starting assumption, and then slowly grind through every issue caused by giving up control at the base layer to these more automatic systems.
I think there is a reasonable place for Forth as a runtime target for compiled code, but the style of code that it supports prefers "flat" designs, like dataflow/FBP languages, because of the explicit stack. Once you aim towards Algol and Lisp and start automating stack movements, the programs become coupled to that design and way of thinking.
The OS community generally understands in theory, although this is much less accepted in practice, that mechanism and policy should be separated as much as possible. Forth, operating systems, Smalltalk, etc. all converge on making programmed systems, if in substantially different contexts, and this becomes a question of layering abstractions. A Forth-like OS that would solve your problems is related to microkernels and exokernels. Minimality and simplicity is essential for foundational services.
That being said, Forth is great for “exploratory programming” of hardware. I rarely, but still sometimes bootstrap Forth for that reason.
How would you design a Forth interpreter to encourage more people to solve actual problems with it? :)
The issue as I see it, is that you have to have a model of the datastack in your head at all times. That's fine for your own code, but for other people's code, stack diagrams will only take you so far.
The ability to scan code, rather than reading it, allow you to mentally drill down when you are ready. Forth requires immersion.
Something like https://xorvoid.com/forsp.html I'm guessing is really the bridge. Something that allows variables without being too complex.
Offhand, anyone know of any good (either long stable, or better, well maintained and likely to persist) CPU emulators for Java? Something that does 'web assembly' might fit the task if it's reasonable to transpile a fake binary format into real WASM.
The first good search result I got was : https://github.com/dylibso/chicory : better than wasmer-java for this use case since it doesn't depend on native binaries.
Relating this back to the topic. It would be interesting to have to, at least copy in someone else's if not, write your own Forth interpreter to help bootstrap computers.
https://github.com/agsb/milliForth-6502/blob/main/scrs/jones...
I'd always wanted to play with the 6809 and it really is a slick little 8 bit cpu.
Note that what you're describing is directly threaded code; traditional FORTH uses indirect threaded code: http://www.complang.tuwien.ac.at/forth/threaded-code.html
the 6309 with its extensions... even more so
I did have some good times with my 6502, as well as a dalliance with Forth… but I don’t really miss it when I’m playing with my 10 cent 32 bit RiskV chips and marvelling at the beauty of their ISA. It brings to mind a Joe Cocker song.
You can buy trainers with old chips like this, z80, CDP1802, 8080, 6509 etc.
The main advantage of the new SBCs is simplicity vs anything more modern and easier to deal with than a retro computer. The advantage of a retro computer is it has some intrinsic value and probably a large body of contemporary software.
[1] https://www.westerndesigncenter.com/ [2] https://wdc65xx.com/Single-Board-Computers
Ben Eater also had a video series about designing and making his own CPU from logic chips. He switched to 6502 likely because progressing up the stack, it started to become too big.
When I do a "microcontroller project" then I slap an ESP32, Arduino, or Pi Pico on the breadboard -- not a 6502.
Now, nothing prevents you from still using a 6502 based project for “real problems” as well, and it’s fun to use your pet project for something practical every once in a while, but that’s usually not the focus. The focus is learning, building, intentionally reinventing the wheel so to speak.
In my previous comment to you, I mentioned how Ben Eater made a self-designed CPU in his excellent video series, before switching to the 6502 to explore higher abstraction layers. In that case it may be more obvious that the focus was on designing the CPU itself, not on any a priori application use case for it.
Have you seen: https://wdc65xx.com/Single-Board-Computers