15 comments

  • vincent-manis 9 hours ago
    This is the latest in a very honourable tradition. My first encounter with it was with Martin Richards's BCPL system in 1972. The compiler generated a hypothetical ISA called OCODE, from which backends generated pretty good native code for Titan-2 and System/360, among others. One of those backends generated INTCODE, which was an extremely reduced ISA, for which an interpreter could be easily written (I wrote one in Fortran). Richards also provided the BCPL compiler and runtime library in INTCODE, so you could quickly have BCPL running interpretively. Then you could use this interpretive version to bootstrap a native-code backend implementation. Put this all together, and you now have a very easy compiler port.

    Wirth's Pascal-P compiler of 1974(?) used the same idea, also in aid of a highly portable compiler. I have never been able to find out whether this was an independent invention, or whether Wirth was influenced by Richards's work.

    Of course, the JVM and CLR are descendents of this, but they build a very complex structure on the basic idea. Writing an implementation of one of these virtual machines is not for the faint of heart.

    So I think Bedrock can be very useful as a compiler target, if nothing else. However, I must agree with some of the other commenters that the 64KiB address space makes it very much of a niche tool. Come up with a 32-bit variant that's not much more complicated, and I think you have a winner.

    • kragen 2 hours ago
      Wirth did it before BCPL in EULER, but virtual machines of various kinds predate EULER; Schorre's META-II output a textual assembly language for a fictitious processor, and Short Code predated that, but was intended to be written by hand. Simulators for one real computer on another were already commonplace by the 01960s, so that you could keep running your programs for an obsolete machine, and I don't remember anyone specifically saying so, but I would assume that designers of planned computers were writing such simulators for their designs by the end of the 01950s.
    • ripe 8 hours ago
      Regarding the 64kB limit: I notice that an implementation can provide the programmer an optional memory block of up to 64MB, IIUC:

      https://benbridle.com/projects/bedrock/user-manual/memory-de...

    • mikestaas 6 hours ago
      Wouldn't the 32-bit variant just be WebAssembly?
      • kragen 2 hours ago
        No, the WebAssembly spec is over 200 pages.
        • lifthrasiir 1 hour ago
          Not to disagree, but WebAssembly intentionally does contain two equivalent descriptions (prose vs. mathematical) and two different formats (binary vs. text), plus a completely independent redefinition of IEEE 754 (!). The true size would be more like around 100 pages, where the instruction definitions would take about a half of them if my prediction from the table of contents is close enough. Maybe highly desugarable "WebAssembly Zero" might be defined and would be a good fit once SpecTec can produce a working modular interpreter.
  • treetalker 10 hours ago
    I'm not steeped in computer science, so please pardon me if the following are dumb questions.

    > Programs written for Bedrock can run on any computer system, so long as a Bedrock emulator has been implemented for that system.

    Isn't that true of any program? As long as the language that the program is written in is implemented on the system, any (valid?) program in that language will run on that system?

    • bottom999mottob 5 minutes ago
      In theory, if a program is written in a high-level language and you have a correct implementation (interpreter, compiler, runtime) of that language on a new system, then the program should be able to run there.

      In practice, this is not always so straightforward, especially as you move closer to machine-level details or consider compiled binaries.

      Many compiled programs are built for a specific architecture (x86, ARM, etc.). They won’t run on a different architecture unless you provide either: A cross-compiler (to generate new native code for that architecture), or an emulator (which mimics the old architecture on the new one)

    • obscure-enigma 10 minutes ago
      moreover, once "it can run anywhere" is defined, you can't run it anywhere
    • Wowfunhappy 7 hours ago
      Based on the OP, I think the idea is that it's very easy to port this emulator to a new system.
    • Walf 4 hours ago
      Not quite. Programs normally need to be compiled per system type, and sometimes per system, due to differences in the OSes' versions, APIs and hardware. The idea behind this type of emulator is that you need compile it only once, and the emulator takes care of those differences for you. The Bedrock program would always ‘see’ the same OS and hardware.
  • Animats 2 hours ago
    There's Open Firmware, which runs on a portable Forth interpreter. That was supposed to be a standard for board setup code. But proprietary systems won out. It was too open.
  • willguest 9 hours ago
    I made a bedrock onion of death: https://paste.pictures/FgqbwUTCY8.png

    Couldn't have done it without you

  • kragen 2 hours ago
    I like things like this.

    One of the big differences from Uxn is the introduction of undefined behavior; by design, you can break it, unlike Stanislav's legos. So presumably Bedrock programs, like C programs, will do different things on different implementations of the system. That's not fatal to portability, obviously, just extra write-once-debug-everywhere work.

  • kosmavision 8 hours ago
    For people curious about the differences between this and Uxn (as I was): https://benbridle.com/articles/bedrock-differences-from-uxn....
    • tromp 34 minutes ago
      > each pixel having both a foreground and a background colour

      how does that work?

      • pjc50 6 minutes ago
        I thought this might be like the ZX spectrum, but that covers each 8x8 block with a foreground and background colour; "sprites" are then bitmaps over that. This does say two colours per pixel, which is confusing.
  • ChuckMcM 4 hours ago
    Fun stuff Ben! Nicely done. I'm building a simple terminal that talks over a SPI port or IIC port and this looks like it would be a fun demo to run on it.
  • nxobject 10 hours ago
    This is fantastic! As someone who's used PICO-8 in after-school STEM enrichment classes (and has evaluated uxn), one of the frustrations that my students have always had is easy I/O and persisting state -- for saving/loading game progress and settings, of course. The clipboard and registry devices seem like a good fit.

    I hope you stick with this!

  • WantonQuantum 7 hours ago
    Love this! Takes me back to the literal 8-bit computers of the 80s when it was much easier to learn to program with, for example, BASIC built into the operating system.
  • behrlich 9 hours ago
    > I designed Bedrock to make it easier to maintain programs as a solo developer.

    Can you say more? I really love this idea but can’t think of any practical use case with 65k of memory. What programs are you now more easily maintaining with Bedrock? To what end?

  • great_psy 8 hours ago
    I have not delved to deep in the code, but is there any functional differences it has over Java other than the size ?

    Presumably Java would also be pretty tiny if we wrote it in bytecode instead of higher lever Java.

    • teraflop 7 hours ago
      The Java bytecode instruction set actually has a quite complicated specification: https://docs.oracle.com/javase/specs/jvms/se8/html/

      Which means implementations also have to be correspondingly complicated. You have to handle quite a few different primitive data types each with their own opcodes, class hierarchies, method resolution (including overloading), a "constant pool" per class, garbage collection, exception handling, ...

      I would expect a minimal JVM that can actually run real code generated by a Java compiler to require at least 10x as much code as a minimal Bedrock VM, and probably closer to 100x.

  • untech 10 hours ago
    Love it, I think it's very cool! I am not sold on its "everlasting" promise yet, but as an addition to the family of "fantasy" platforms seems very solid.
  • szczepu 9 hours ago
    My immediate reaction was, "oh, like Uxn!" but then of course I read it was originally a fork of Uxn. I love these 'toy' OSes, the more the better.
  • tines 8 hours ago
    Why 8 bit?
    • kragen 2 hours ago
      That puzzled me too, since it's a fork of Uxn, a 16-bit architecture.
  • lastdong 9 hours ago
    The demos are surprisingly fun!