top | item 38861600

(no title)

NWoodsman | 2 years ago

Sage is a programming language with a low level virtual machine based on a Turing tape. The sage virtual machine has a read/write head and a single register. The read/write head moves around the tape, and uses the register as an accumulator. All worldly input is done through a single instruction, and all worldly output is done through a single instruction. Functionality which cannot be achieved with any algorithm, such as using an operating system’s system calls to write to persistent memory, is also done through two instructions: one for sending values to the virtual machine’s foreign function interface, and one for receiving. The goal of the virtual machine is to allow algorithms to be expressed in the same time complexity as they would on x86, but with the smallest possible number of instructions. This allows sage code to be maximally portable: sage’s core instruction set could be implemented in hardware much easier than any modern architecture due to its very small pool of opcodes and their simplicity

This is an interesting snippet from your website, did this project intentionally start out as an attempt to design around a Turing machine? Or is it just safe to say that all languages executing on a stack with no heap are Turing machines?

discuss

order

adamthekiwi99|2 years ago

Thanks for the great question, and for checking out the project! This project started out because I noticed some really interesting properties about compiling brainfuck-like programming languages while writing high level language compilers that targeted these brainfuck-like backends.

This is the work that inspired Sage: Harbor (https://github.com/adam-mcdaniel/harbor). My goal with Sage was to take everything that makes a brainfuck-like programming language easy to compile, while also keeping all the time complexity and optimizations of regular algorithms. So, in that sense, it started out as an attempt to design around a Turing machine -- I wanted this to be a dialect of brainfuck. The VM doesn't use any stack operations, just operations on a tape pointer + an accumulator!