Unknown
μDewy (udewy or "micro-dewy") is a strict subset of the Dewy Programming Language I developed while taking a break from working on the full Dewy compiler. The main idea was to strip out features from Dewy until basically the simplest useful subset remained. The μDewy compiler is relatively small, and a bootstraped version written in μDewy is maintained in parallel to the python implementation of the compiler. Well-formed μDewy programs can be compiled by the full Dewy compiler, and will have the same behavior.
From a semantic perspective, μDewy is pretty similar to the B programming language:
μDewy"s main quirks stem from aiming to be a strict subset of the full Dewy language:
transmute operator (in Dewy transmute converts a type without modifying the underlying bits. Since μDewy doesn"t have types, transmute is pure documentation that helps bridge low level μDewy behavior to higher level Dewy)true=-1, false=0 (needed soand/or support both bitwise and logical modes without tracking types)The current reference implementation lives in the dewy-lang repo and can target Linux x86_64, wasm32 (a single HTML page with embedded WASM), RISC-V, and AArch64. There is also a VS Code extension for syntax highlighting.
A hello world using the stdlib looks like this:
import p"../stdlib/core.udewy"
import p"../stdlib/capabilities/host.udewy"
import p"../stdlib/io.udewy"
let main = ():>void => {
printl("Hello, world!")
return void
}
Without the stdlib you are talking to the host more directly. On Linux that is a write syscall; in the browser playground the same idea uses a host log builtin:
# SYS_WRITE and STDOUT are builtin constants provided by the x86_64 backend
let main = ():>int => {
let msg:int = "Hello from udewy!\n"
let len:int = __load__(msg - 8)
__syscall3__(SYS_WRITE STDOUT msg len)
return 0
}
FizzBuzz is a bit more of the language at once — loops, conditionals, and a tiny helper:
let printed:bool = false
let print = (s:string):>void => {
printed = true
__host_log__(s __load__(s - 8))
return void
}
let main = ():>int => {
let i:int = 1
loop i <=? 20 {
printed = false
if i % 3 =? 0 { print("Fizz") }
if i % 5 =? 0 { print("Buzz") }
if not printed { __log_int__(i) }
print("\n")
i = i + 1
}
return 0
}
And a Fibonacci loop, one of the examples shipped with the playground:
let puts = (s:string):>void => {
__host_log__(s __load__(s - 8))
return void
}
let puti = (i:int):>void => {
__log_int__(i)
return void
}
let main = ():>int => {
let i:int = 0
let i0:int = 0
let i1:int = 1
loop i <? 100 {
puts("fib(")
puti(i)
puts(") = ")
puti(i0)
puts("\n")
i = i + 1
i1 = i0 + i1
i0 = i1 - i0
}
return 0
}
The really awesome thing about μDewy is that it supports targeting wasm32 (spitting out a single
file containing the entire program). This makes it extremely simple to build applications that run directly in the users"s browser. Having the bootstrapped version of the compiler written in μDewy also made it trivial to build a web hosted version of the compiler (powering the playground below).html
An in-browser playground that compiles udewy to WebAssembly and runs it. You can edit the source, pick from a few built-in examples, and press Run. The compiler itself is a udewy program compiled to WASM. Open the full page demo.
In order to showcase μDewy"s capabilities (and also as a hard case for stress testing new LLMs as they came out), I would periodically have LLMs try to build a clone of the 3D F-Zero games from scratch in μDewy. In general all models fail this task pretty consistently. Only with much hand holding and refinement was Claude-Fable able to produce this current version. Same source compiles natively (SDL) or to WASM for the browser. Open the full page demo.
Slime volleyball, the classic game from primary school. Implemented completely in μDewy play against the CPU or add a second player. switch stages to change the gravity Open the full page demo.