10 comments

  • chirsz1 hour ago
    SBus peripherals use the Forth language in their PROMs to initialize themselves[1].<p>[1] <a href="https:&#x2F;&#x2F;docs.oracle.com&#x2F;cd&#x2F;E19957-01&#x2F;802-3239-10&#x2F;sbusandfc.html#11274" rel="nofollow">https:&#x2F;&#x2F;docs.oracle.com&#x2F;cd&#x2F;E19957-01&#x2F;802-3239-10&#x2F;sbusandfc.h...</a>
    • DonHopkins1 hour ago
      Good call! (Whether it&#x27;s a directly threaded, indirectly threaded, subroutine threaded, token threaded, Huffman threaded, or string threaded call.)<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Threaded_code#Token_threading" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Threaded_code#Token_threading</a><p>Mitch Bradley created OpenFirmware. It started at Sun as OpenBoot (informally &quot;SunForth&quot;) on the SPARCstation 1 in 1989, was standardized as IEEE 1275-1994, and was renamed OpenFirmware at that time. Its lineage runs back through Mitch&#x27;s earlier Forthmacs (Bradley Forthware, early 80s), which ran on 68k Macs, Sun-2&#x2F;3, Atari ST, and Amiga. Mitch credits Henry Laxen and Michael Perry&#x27;s F83 and Glen Haydon&#x27;s MVP-Forth as the public-domain ancestors.<p>The metacompiler can target many platforms, word sizes, CPUs, and threading models, and produce stripped ROMable images. It can build the kernel as direct-threaded (DTC), indirect-threaded (ITC), subroutine-threaded (STC), or token-threaded (TTC), with 16, 32, or 64 bit cells. Shipping kernels are DTC native code with cell-sized xt pointers: 32 bit on the original SPARC and PowerPC machines, 64 bit on modern PPC64, SPARC64, and ARM64 builds.<p>Peripheral expansion cards ship a separate, portable, variable-byte token format called FCode. The kernel interprets FCode at boot&#x2F;probe time and recompiles it on the fly into the live native dictionary. After probe, FCode-loaded drivers run as ordinary native Forth words. That two-stage design (fast native runtime, portable FCode transport) is what let Sun ship one card PROM image that worked across CPU generations.<p><a href="https:&#x2F;&#x2F;github.com&#x2F;MitchBradley" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;MitchBradley</a><p><a href="https:&#x2F;&#x2F;github.com&#x2F;MitchBradley&#x2F;openfirmware" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;MitchBradley&#x2F;openfirmware</a><p>FCode was designed for SBus on the SPARCstation 1, with cross-CPU portability built in. Sun&#x27;s earlier and contemporary buses were not interchangeable with SBus (Sun-2 used Multibus, Sun-3 used VMEbus, the Sun386i &quot;Roadrunner&quot; used AT-bus), so the cross-architecture payoff arrived later, when IEEE 1275-1994 standardized OpenFirmware and PCI allowed FCode in option ROMs. After that, the same expansion-card PROM image could boot on Sun SPARC, Apple PowerPC Macs, IBM PowerPC servers (CHRP), and the OLPC XO.<p>Interview with Mitch Bradley (he&#x27;s like the Woz of Forth):<p><a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20120118132847&#x2F;http:&#x2F;&#x2F;howsoftwareisbuilt.com&#x2F;2008&#x2F;03&#x2F;27&#x2F;interview-with-mitch-bradley-firmware-olpc&#x2F;" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20120118132847&#x2F;http:&#x2F;&#x2F;howsoftwar...</a><p>In parallel with the OpenBoot work, Mitch also developed an extremely portable C-based Forth (the public version is &quot;C Forth 93&quot;). It runs a switch-threaded inner interpreter over packed tokens, with configurable cell width (16, 32, or 64 bit) and configurable token width (pointer-sized by default, 16 bit with the T16 build flag for tight flash budgets), plus a small hand-rolled FFI built around a fixed-arity 12-argument marshalling trampoline driven by a format string. It is now the embedded variant used in OLPC&#x27;s OpenFirmware and in PlatformIO targets including RP2040, Teensy, ESP32, ESP8266, and STM32:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;MitchBradley&#x2F;cforth" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;MitchBradley&#x2F;cforth</a><p>OpenFirmware even has its own song:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=b8Wyvb9GotM" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=b8Wyvb9GotM</a><p>More on Mitch, OpenFirmware, and CForth:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21822840">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=21822840</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33681531">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=33681531</a><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=38689282">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=38689282</a>
      • anthk18 minutes ago
        I ran EForth under the Subleq from Howe R.J at <a href="https:&#x2F;&#x2F;github.com&#x2F;howerj&#x2F;muxleq" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;howerj&#x2F;muxleq</a> (the subleq one) first at QuickJS (trivial tasks, almost a 1:1 map from the C code, made in a hurry) and under... jsinterp.py from the infamous yt-dlp but using arrays instead of printing functions. But... if yt-dlp&#x27;s &quot;mini-JS&quot; implements some captcha input functions... you can add I&#x2F;O with ease and run EForth with what they call (not me) a &quot;Not totally functional interpreter&quot;.<p>Not totally... until people there run the 110 rule program, Conway&#x27;s Life, Subleq+EForth...
  • magnat1 hour ago
    Some other examples:<p>- ACPI configuration for power management and platform stuff [1]<p>- Bitcoin transactions [2]<p>- TrueType fonts [3]<p>[1] <a href="https:&#x2F;&#x2F;wiki.osdev.org&#x2F;AML" rel="nofollow">https:&#x2F;&#x2F;wiki.osdev.org&#x2F;AML</a><p>[2] <a href="https:&#x2F;&#x2F;en.bitcoin.it&#x2F;wiki&#x2F;Script" rel="nofollow">https:&#x2F;&#x2F;en.bitcoin.it&#x2F;wiki&#x2F;Script</a><p>[3] <a href="https:&#x2F;&#x2F;learn.microsoft.com&#x2F;en-us&#x2F;typography&#x2F;opentype&#x2F;spec&#x2F;tt_instructions" rel="nofollow">https:&#x2F;&#x2F;learn.microsoft.com&#x2F;en-us&#x2F;typography&#x2F;opentype&#x2F;spec&#x2F;t...</a>
    • m13248 minutes ago
      Since ACPI was mentioned, let&#x27;s not forget about EFI!<p><a href="https:&#x2F;&#x2F;uefi.org&#x2F;specs&#x2F;UEFI&#x2F;2.10&#x2F;22_EFI_Byte_Code_Virtual_Machine.html" rel="nofollow">https:&#x2F;&#x2F;uefi.org&#x2F;specs&#x2F;UEFI&#x2F;2.10&#x2F;22_EFI_Byte_Code_Virtual_Ma...</a>
  • superjan1 hour ago
    How about the infamous iOS hack with a VM implemented in a JBIG2 PDF? <a href="https:&#x2F;&#x2F;projectzero.google&#x2F;2021&#x2F;12&#x2F;a-deep-dive-into-nso-zero-click.html" rel="nofollow">https:&#x2F;&#x2F;projectzero.google&#x2F;2021&#x2F;12&#x2F;a-deep-dive-into-nso-zero...</a>
  • pratikdeoghare3 hours ago
    There is one in golang regular expressions <a href="https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp2.html" rel="nofollow">https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp2.html</a><p>I guess that is why you say re.Compile.
    • rhdunn3 hours ago
      That goes back to Ken Thompson&#x27;s NFA regex interpreter from 1968 [1], [2], [3]. Note: that whole regex series by Russ Cox [4] is great.<p>[1] <a href="https:&#x2F;&#x2F;dl.acm.org&#x2F;doi&#x2F;10.1145&#x2F;363347.363387" rel="nofollow">https:&#x2F;&#x2F;dl.acm.org&#x2F;doi&#x2F;10.1145&#x2F;363347.363387</a> -- Programming Techniques: Regular expression search algorithm<p>[2] <a href="https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp1.html" rel="nofollow">https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp1.html</a> -- Regular Expression Matching Can Be Simple And Fast<p>[3] <a href="https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp2.html" rel="nofollow">https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;regexp2.html</a> -- Regular Expression Matching: the Virtual Machine Approach<p>[4] <a href="https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;" rel="nofollow">https:&#x2F;&#x2F;swtch.com&#x2F;~rsc&#x2F;regexp&#x2F;</a> -- Implementing Regular Expressions
      • kqr1 hour ago
        I second the Russ Cox recommendation. I read that ages ago and that was what made me realise some theory could actually be useful in practice.
    • pjc503 hours ago
      All regular expressions are deterministic final automata <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Deterministic_finite_automaton" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Deterministic_finite_automaton</a> (finally, a use for my CS course); the extent to which that counts as a virtual machine varies. Some of the regex syntaxes extend it in ways which don&#x27;t fit in a DFA and do count as a VM; Perl-compatible RE used to be popular (e.g. in Exim).
      • titzer1 hour ago
        It&#x27;s easier to construct NFAs directly from regular expression definitions (rather than DFAs) because implementing the choice operator is easier. We can convert from NFA to DFA with worst-case exponential blowup.
      • anthk2 hours ago
        Inded:<p><a href="https:&#x2F;&#x2F;wiki.xxiivv.com&#x2F;site&#x2F;rewriting.html" rel="nofollow">https:&#x2F;&#x2F;wiki.xxiivv.com&#x2F;site&#x2F;rewriting.html</a>
    • sureglymop3 hours ago
      Interesting. Not that surprising that it works like this. But isn&#x27;t it a little surprising that things like regexes, printf syntax and other DSLs aren&#x27;t mostly handled and parsed at compile time in 2026?
      • pjc502 hours ago
        Kind of language-dependent since regexes are normally specified as strings and most languages are pretty weak at &quot;run this code at compile time&quot;. One of the things Rust users are fond of.<p>C# is in the middle on this one, where specific features get compile-time support and regex is one of them: <a href="https:&#x2F;&#x2F;www.devleader.ca&#x2F;2026&#x2F;05&#x2F;03&#x2F;c-regex-performance-generatedregex-compiled-nonbacktracking-and-timeout" rel="nofollow">https:&#x2F;&#x2F;www.devleader.ca&#x2F;2026&#x2F;05&#x2F;03&#x2F;c-regex-performance-gene...</a><p>I have also built a C# source generator myself (XML parser generator), but the developer experience is a bit of a hill to climb compared to what it could be.
  • ivankelly3 hours ago
    Quake had it’s own vm also
  • self_awareness2 hours ago
    RarVM was used in a previous version of the format, newest RAR has removed it, and RarV5 doesn&#x27;t have a VM.
  • omeid23 hours ago
    This list is entirely incomplete without mentioning Java Card.<p>There is a tiny Java Bytecode VM in an insanely large list of places, you can find some of them here:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;crocs-muni&#x2F;javacard-curated-list" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;crocs-muni&#x2F;javacard-curated-list</a> <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Java_Card" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Java_Card</a>
  • ignoramous3 hours ago
    TikTok shipping XOR cipher&#x27;d bytecode &amp; interp is right up there: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=34109771">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=34109771</a>
    • pjc503 hours ago
      VM for obfuscation is a whole thing. Denuvo has a particularly complicated one <a href="https:&#x2F;&#x2F;connorjaydunn.github.io&#x2F;blog&#x2F;posts&#x2F;denuvo-analysis&#x2F;" rel="nofollow">https:&#x2F;&#x2F;connorjaydunn.github.io&#x2F;blog&#x2F;posts&#x2F;denuvo-analysis&#x2F;</a><p>Other game examples using VMs not for obfuscation: Z-machine and SCUMM-VM.
  • anthk2 hours ago
    yt-dlp&#x27;s jsinterp.py<p><a href="https:&#x2F;&#x2F;jxself.org&#x2F;compiling-the-trap.shtml" rel="nofollow">https:&#x2F;&#x2F;jxself.org&#x2F;compiling-the-trap.shtml</a><p>I&#x27;ve got subleq+eforth (<a href="https:&#x2F;&#x2F;github.com&#x2F;howerj&#x2F;muxleq" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;howerj&#x2F;muxleq</a>) running in JS which is dead simple to do. No input but I could output ASCII mapping values to an array.<p><a href="https:&#x2F;&#x2F;esolangs.org&#x2F;wiki&#x2F;Subleq" rel="nofollow">https:&#x2F;&#x2F;esolangs.org&#x2F;wiki&#x2F;Subleq</a><p>So, yes. yt-dlp runs propietary Youtube JS code defying the original purpose.
  • dsecurity493 hours ago
    [flagged]