[HN Gopher] Fitting a Forth in 512 Bytes
___________________________________________________________________
Fitting a Forth in 512 Bytes
Author : stevekemp
Score : 92 points
Date : 2021-06-11 19:44 UTC (3 hours ago)
(HTM) web link (niedzejkob.p4.team)
(TXT) w3m dump (niedzejkob.p4.team)
| dingosity wrote:
| people talking about how cool FORTH is. @cblum made his own
| sector forth. this is my tribe. i honestly thought there were no
| stack fans left in the world, thanks for proving me wrong.
| stcredzero wrote:
| "To compile a kernel, you need a running kernel."
|
| Why? I guess it depends on how you define "kernel." But to be
| able to do a batch process like compilation, you can get away
| with a little.
| NieDzejkob wrote:
| Workarounds exist, like for every other example I mentioned. I
| am mostly referring to the commonly used dependency graph.
| spicybright wrote:
| I'm guessing by kernel he meant any program that can host other
| programs in some way.
|
| Can you clarify what batch process means in this case?
|
| I /think/ the authors definition of a kernel is a program that
| can host other programs in some way.
|
| A video game on a boot sector can't do that (even though it
| likely would have it's own kernel to function), but some kind
| of input loop to write memory could.
| stcredzero wrote:
| The old Apple II+ I had as a kid only did one process at a
| time. For an OS, it basically had what amounted to a REPL for
| Microsoft BASIC.
|
| You don't need to host another program to compile something.
| All you need to do is to read data off disk, then write other
| data back.
| Someone wrote:
| And what would do that "read data off disk, then write
| other data back", if not a program? Even if you use a
| monitor
| (https://en.wikipedia.org/wiki/Machine_code_monitor) to
| write a program, that's still a program.
|
| The only way to avoid that is to hand-punch a tape or
| something like that (with lots of practice and patience, it
| may be possible to program a small PROM or write an early
| floppy by hand)
| kstrauser wrote:
| On a Commodore 64, the kernal [sic] was similar to the BIOS
| on a PC, with display and keyboard handlers, IO routines,
| etc. When you first turned on the machine, _something_ had
| to say "** COMMODORE 64 BASIC V2 **", and that something
| was the kernal.
| hyperhopper wrote:
| I find it amusing how often trying to do complex tasks with
| simple constraints, always ends up back at stack based languages.
| Probably why the stack based turing machine is academically
| important.
| NieDzejkob wrote:
| I suppose that prior art influences things. In my case, I went
| "a separate text editor won't fit, I need a REPL", and that
| basically filtered to just Forth and Lisp. It would be
| interesting to see what subset of Lisp would fit in a
| bootsector, but I wouldn't get my hopes up.
| q-big wrote:
| > Probably why the stack based turing machine is academically
| important.
|
| A Turing machine is not stack-based, but tape-based. A pushdown
| automaton (PDA) is stack-based.
| cblum wrote:
| Gonna plug my own sectorforth here:
| https://github.com/cesarblum/sectorforth
|
| The linked post is really impressive. The author went way beyond
| what I did. I'm especially impressed by the I/O stuff.
| na85 wrote:
| Man, Forth is such a cool language. It really captures (what I
| perceive to be) the "hacker mentality" of powerful but simple
| tools, without much overt concern for polish/slick interfaces.
|
| I mean I know a lot of foundational code of yesteryear was hacked
| together in C, but C lacks a certain ineffable cachet in my view.
| A cachet that Forth definitely has.
___________________________________________________________________
(page generated 2021-06-11 23:00 UTC)