[HN Gopher] Fitting a Forth in 512 bytes (2021)
___________________________________________________________________
Fitting a Forth in 512 bytes (2021)
Author : whereistimbo
Score : 66 points
Date : 2024-10-26 00:47 UTC (22 hours ago)
(HTM) web link (compilercrim.es)
(TXT) w3m dump (compilercrim.es)
| Jun8 wrote:
| Forth has been sitting on my list of cool thing to learn when I
| have time for the past 20 yrs or so. What would be a compelling
| use case and setup?
| mananaysiempre wrote:
| One compelling use case is getting a REPL on any
| microcontroller with a UART and, say, >=64K RAM (I remember
| lbForth[1] being particularly portable, and there are other
| implementations you could use as well).
|
| I don't know if you'd want to have that be your first
| experience with the Forth itself, though: there's inherent
| fiddliness involved in bringing up hardware; the win is that
| Forth doesn't really add any of its own once you're vaguely
| familliar with the internals. If you can get it to boot and
| send and receive bytes, you can get an interactive Forth on it
| --or if the available resources don't permit that, on an
| imaginary machine spanning it and your PC (a "tethered" Forth).
|
| [1] https://github.com/larsbrinkhoff/lbForth
| zabzonk wrote:
| Some of the things I learned from implementing a FORTH on a
| CP/M box back in the early 1980s were
|
| - writing Z80 assembler
|
| - using the assembler and linker
|
| - getting a clue about how the CP/M file system worked (it
| didn't, very well)
|
| - writing a number of utilities (VT52 emulator, PacMan clone &
| stuff) in FORTH, which was fun
|
| - macro programming at compile/runtime using things like
| BUILDS/DOES
|
| It's a lot of fun and you don't need to invest much time in it
| to get things done.
| simne wrote:
| Forth is known for extremely compact representation of code,
| and very portable, because standard have very few registers and
| work on stack machine. Unfortunately all these at cost of slow
| execution and not easy to make serious projects (hard to deal
| with large codebase chaos, but read more).
|
| So it definitely, platform for slow embedded applications,
| keyword Arduino, may be Raspberry.
|
| Sure, compactness is huge advantage in some other cases, for
| example, known boot loader shell for UEFI is written on Forth,
| so you could write applications for it (and yes, for this use
| case any modern motherboard except Apple).
|
| For large codebase works, some Forth people learn Scheme and
| technically switched to Lisp programming paradigm. Yes, it
| interest phenomena, Lisp techniques work with Forth good enough
| if developer disciplined enough. Sure, Lisp will open for you
| whole new world.
| astrobe_ wrote:
| Application scripting. Single file, low footprint,
| straightforward script/application interface. Can help with
| debugging.
| irq-1 wrote:
| Is there a Forth made for scripting/embedding in an
| application?
| IAmLiterallyAB wrote:
| I have a side project to try to make an extreme minimal size
| compiler for a Forth inspired language and implementation. It's a
| compiler that generates a Forth like interpreter and byte code.
| The bytecode is huffman encoded. Nothing works yet but its an
| idea.
| 082349872349872 wrote:
| Have you seen ColorForth? Moore huffman encoded (or similar)
| his character set, so he could do dictionary lookup with just
| REPNZ SCAS.
| dang wrote:
| Discussed at the time:
|
| _Fitting a FORTH in 512 bytes_ -
| https://news.ycombinator.com/item?id=27468698 - June 2021 (57
| comments)
___________________________________________________________________
(page generated 2024-10-26 23:04 UTC)