Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
11–20 of 20 posts
Re: Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
#12Re: Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
#13@nineties, I'm curious why you included things like 'mul', 'divmod', 'and', 'or' in the initial instruction set? These can all be composed, so would make your initial ELF binary a bit smaller.
I’d bet it was just because those are easy; there is a machine instruction to compute them. Might as well use it and have one less subroutine to define later.
In case of mod and divmod, implementing them with add, sub and loop has a serious performance issue. Replacing it with shift operations, bit operations, add, sub and loops could be an option.
Re: Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
#14bootstrap.fs is a thing of beauty https://github.com/nineties/planckforth/blob/main/bootstrap.... It starts off looking like line noise (the very simple interpreter defined in hex) and gradually turns into the forth we know and love. Fantastic!
"Before I can explain anything, I have to implement the ability to explain things and then explain that I just added the ability to explain things."
Re: Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
#15Re: Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
#16Re: Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
#17Does the "metacircular" part just mean that the compiler can use definitions it's already compiled in the current pass?
So in this case, the base implementation starts with support for only a subset of the Forth language, picked for being either essential or much more performant when implemented "natively" in the binary. A subset of this subset is then used to construct support for the rest of the language. This is very typical for Forth- and Lisp-like languages.
Re: Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
#18So
kHtketkltkltkotk tkWtkotkrtkltkdtk!tk:k0-tQ
is wrong. The below is correct. kHtketkltkltkotk tkWtkotkrtkltkdtk!tk:k0-tk0k0-QRe: Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
#19Does the "metacircular" part just mean that the compiler can use definitions it's already compiled in the current pass?
No, it more or less means that a language is described in (part of) the language itself. And before you ask, no, it's not quite the same as self-hosting (good question though). The latter is more associated with compilers that can take a source file and produce another compiler. The former is often more like an interpreter that provides support for part of a language, but those part are enough to define support for t…
I recommend Moving Forth [1] for the full explanation. (That's the part that addresses metacompliers, the rest is still quite a great book.)
Re: Show HN: PlanckForth – Bootstrapping an interpreter from handwritten 1kb binary
#20bootstrap.fs is a thing of beauty https://github.com/nineties/planckforth/blob/main/bootstrap.... It starts off looking like line noise (the very simple interpreter defined in hex) and gradually turns into the forth we know and love. Fantastic!
I love that the first thing added is support for comments, followed by a comment explaining that we just added comments and how it did so. "Before I can explain anything, I have to implement the ability to explain things and then explain that I just added the ability to explain things."
[1] https://github.com/nornagon/jonesforth/blob/master/jonesfort...
[2] https://github.com/nornagon/jonesforth/blob/master/jonesfort...