4 comments

  • upghost7 hours ago
    Very interesting stuff. Apparently this is the implementation: <a href="https:&#x2F;&#x2F;github.com&#x2F;dicpeynado&#x2F;prolog-in-forth" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dicpeynado&#x2F;prolog-in-forth</a><p>Thinking about the amount of thought and energy that went into this, back in 1987 -- mostly preinternet, pre-AI. Damn.<p>I feel really lucky that we get to build on things like this.
    • jhbadger6 hours ago
      There&#x27;s a great 1986 book &quot;Designing and Programming Personal Expert Systems&quot; by Feucht and Townsend that implements expert systems in Forth (and in the process, much of the capability of Prolog and Lisp).
      • racingmars5 hours ago
        Ha,you beat me to it! That book was my first thought when I saw this post. I have a copy sitting here on my bookshelf.<p>Just to expand on how bonkers this book is... they assume that everyone has easy access to a Forth implementation. So they teach you how to build a Lisp on top of it. Then they use the Lisp you just built to build a Prolog. Then, finally, they do what the topic of the book actually is: build a simple expert system on top of that Prolog.<p>I love it!
        • jhbadger3 hours ago
          To be fair, in the 1980s thanks to the Forth Interest Group (FIG), free implementations of Forth existed for most platforms at a time when most programming languages were commercial products selling for $100 or more (in 1980s dollars). It&#x27;s still pretty weird, but more understandable with that in mind.
  • tombert5 hours ago
    Forth is so interesting.<p>I&#x27;ve been doing a lot of Forth lately; it&#x27;s a kind of weird language, and it makes your brain think in a way that is very different than basically any other language out there. It allows you to work at effectively any of level of code, and allows you to easily &quot;lift&quot; low level code into high level.<p>I&#x27;ve been on&#x2F;off developing a Forth for the NES. It mostly works, but it&#x27;s still pretty buggy and I&#x27;m still learning how the PPU works so graphics will often get corrupted for things that are non-trivial, but even despite that, I was flabbergasted at how <i>easy</i> it was to get a Forth built for it, and even the decent performance I&#x27;ve been able to get when I compile it.<p>I don&#x27;t know that I have much desire to write Forth on modern hardware, but I am still glad I learned it just so I can work at a lower level in a high-ish level language, and I do think that &quot;learning to think in Forth&quot; is a skill that is something most developers should do.
  • dharmatech1 hour ago
    Two videos on how I explore JONESFORTH with GDB:<p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;E6OgXMJPd9U?si=Dxfla5fWloSpYtfQ" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;E6OgXMJPd9U?si=Dxfla5fWloSpYtfQ</a><p><a href="https:&#x2F;&#x2F;youtu.be&#x2F;giLsd-bik6A?si=HOwgyas2WqDsy4LA" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;giLsd-bik6A?si=HOwgyas2WqDsy4LA</a>
  • NetMageSCW6 hours ago
    I assisted a graduate student a long time ago in his implementation of the Warren Machine for compiling Prolog. At its core it was essentially a threaded interpreter.
    • wizzwizz45 hours ago
      Edit: I&#x27;m a silly-billy who doesn&#x27;t know what words mean. <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Threaded_code" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Threaded_code</a> is not a bad description of a large WAM program, although =&#x2F;2-inlining and peephole optimisation will turn some procedure clauses into quite sophisticated collections of pattern-matching and unification instructions, which represent a non-trivial computation. Does a tight loop operating over linked lists still count as threaded, if it <i>used</i> to be a tail-recursive procedure call? Or does the term refer instead to the program as a whole? (Probably the second one.)<p>---<p>I thought WAM was single-threaded? It does a lot of trickery to simulate &quot;fork, wait, and either kill parent or child&quot; with no copying and minimal rollback, but most of that trickery relies on the <i>absence</i> of threading, and will explode in the presence of such hubristic assumptions as &quot;once we&#x27;ve returned from a procedure, the old stack frame is freed and its memory can be re-used&quot;, &quot;a clean-up procedure will be run when we drop objects&quot;, and &quot;clean-up procedures do not need to be run when we drop objects&quot;.<p>I would be interested to see approaches that make it work in parallel. Even cheating with Unix and COW would be interesting: since Prolog predicates can have side-effects, a cut in an earlier branch would retroactively cancel the later branches you&#x27;ve eagerly executed in parallel. You&#x27;d either have to deal with that somehow (maybe with IO monads?), or invent some notion of (dependent?) purity and then ensure procedures in the <i>dynamic procedure database</i> remain correctly tagged with their purity, <i>transitively</i> (i.e., including all possible callees, unto the deepest generation). I&#x27;m not confident the speed-up would be worth the overhead, for most programs.
      • Jtsummers5 hours ago
        Threaded interpreters are different than multithreading:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Threaded_code" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Threaded_code</a><p><a href="https:&#x2F;&#x2F;archive.org&#x2F;details&#x2F;R.G.LoeligerThreadedInterpretiveLanguagesTheirDesignAndImplementationByteBooks1981" rel="nofollow">https:&#x2F;&#x2F;archive.org&#x2F;details&#x2F;R.G.LoeligerThreadedInterpretive...</a> - book on the topic