←back to thread

221 points benbridle | 9 comments | | HN request time: 0.849s | source | bottom

Hey everyone, this is my latest project.

Bedrock is a lightweight program runtime: programs assemble down to a few kilobytes of bytecode that can run on any computer, console, or handheld. The runtime is tiny, it can be implemented from scratch in a few hours, and the I/O devices for accessing the keyboard, screen, networking, etc. can be added on as needed.

I designed Bedrock to make it easier to maintain programs as a solo developer. It's deeply inspired by Uxn and PICO-8, but it makes significant departures from Uxn to provide more capabilities to programs and to be easier to implement.

Let me know if you try it out or have any questions.

1. treetalker ◴[] No.44565729[source]
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?

replies(5): >>44566757 #>>44567597 #>>44569044 #>>44569078 #>>44576647 #
2. Wowfunhappy ◴[] No.44566757[source]
Based on the OP, I think the idea is that it's very easy to port this emulator to a new system.
3. Walf ◴[] No.44567597[source]
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.
replies(1): >>44576684 #
4. obscure-enigma ◴[] No.44569044[source]
moreover, once "it can run anywhere" is defined, you can't run it anywhere
replies(1): >>44569106 #
5. bottom999mottob ◴[] No.44569078[source]
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)

replies(1): >>44576017 #
6. bottom999mottob ◴[] No.44569106[source]
One-size-fits-all never fits everyone :)
7. kragen ◴[] No.44576017[source]
Yes, but it might do something different there, such as print an error message and exit.
8. benbridle ◴[] No.44576647[source]
You're right, it's technically true of any program, but it wouldn't necessarily be practical. Implementing CPython on a Gameboy Advance, for example, would be tedious and likely not entirely possible.

The purpose of Bedrock was to make a system that is easy to implement on as many computer systems as possible. I've got plans to make a working system from a 64KB RAM chip and a $2 PIC12F1572 8-bit microcontroller (2K memory, 6mW power, 8 pins), just to see how far down I can take it.

9. benbridle ◴[] No.44576684[source]
You've got it, yeah. It makes writing programs across different systems so much nicer, because you can just write your programs against a single tidy 'bedrock' abstraction of the file system, screen, networking, etc.