TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Jonesforth – A sometimes minimal FORTH compiler and tutorial (2007)

52 pointsby jcla1over 9 years ago

5 comments

rwmjover 9 years ago
2007 actually. Anyway, ask me anything!<p>The project comes in two parts. The first part is linked above. The second part is written in FORTH -- or rather, a subset of FORTH initially that builds up and adds features as it goes along: <a href="https:&#x2F;&#x2F;github.com&#x2F;nornagon&#x2F;jonesforth&#x2F;blob&#x2F;master&#x2F;jonesforth.f" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nornagon&#x2F;jonesforth&#x2F;blob&#x2F;master&#x2F;jonesfort...</a> Try scrolling down the file, and notice how the comment syntax changes from \ (backslash) to (...) (parentheses), then notice that parenthesis-comments are implemented just before the style change. There&#x27;s a lot more stuff like that, although that&#x27;s the most noticeable thing for beginners.
评论 #10187806 未加载
评论 #10188477 未加载
评论 #10188032 未加载
评论 #10188439 未加载
评论 #10188443 未加载
PaulHouleover 9 years ago
Back in the 1980&#x27;s I had a TRS-80 color computer which was running a Unix-clone operating system called OS-9, this was multi-tasking and multi-user so I could log into my Coco with a DEC Correspondent printing terminal.<p>I wrote a FORTH implementation for the 6809 in about 3k lines of assembly code which included the language plus the &#x27;standard library&#x27;. Instead of the &#x27;standard&#x27; Forth I&#x2F;O, there was an interface to Unix-style file-handle based I&#x2F;O. It used subroutine threading so that FORTH compiled directly to 6809 code and the part that did dynamic dispatch used self-modifying code to shave off a few cycles.<p>FORTH is an interesting part of the story about why LISP didn&#x27;t take off on 1980&#x27;s microcomputers, partly because if you wanted a LISP on an 8-bit micro, you could get much of the way there with FORTH in a footprint even smaller than BASIC.
rudaover 9 years ago
This is <a href="https:&#x2F;&#x2F;github.com&#x2F;ruda&#x2F;jonesforth-macintel" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ruda&#x2F;jonesforth-macintel</a> the port I did to Macintosh i386.
Someoneover 9 years ago
Read it once more, and it was a good way to remind me of how fun programming was before we had megabyte libraries and dozens of layers of abstraction.<p>I also noticed something that made me smile:<p><i>&quot;There is no generally agreed syntax for this, so I&#x27;ve gone for the syntax mandated by the ISO standard&quot;</i><p>You won&#x27;t read that in the source code of a C, pascal, or Fortran compiler, and there basically is only one forth standard, but historically, many implementations know better than to follow it. That is both a good and a bad thing.<p>On the plus side, it is extremely flexible, but the price one pays for that is that there is barely any code reuse because every system is different.<p>For systems on which Forth shines, that isn&#x27;t a problem. There, you do not include that 400 byte floating point library &quot;as is&quot;, but take the source, remove the 2% of it that you do not need, and tweak a few calls to make them smaller at the price of performance because you don&#x27;t have 400 bytes to waste on a bloated floating point package. You don&#x27;t <i>program in</i> Forth, you <i>write a</i> forth.
paulsmithover 9 years ago
How hard would it be to port this to x86_64? Offhand I&#x27;m guessing the alignment, register names (eXX -&gt; rXX), changing any relative offset from 4 to 8, and syscall convention. Any other hidden landmines?
评论 #10188150 未加载