The Dewy programming language

Run a Dewy example

These programs were compiled to WebAssembly during the site build. Choose one and run it in a fresh sandbox.

Precompiled programs

Hello, Dewy

printl"Hello, Dewy!"

Expected stdout: Hello, Dewy!

Ready

Independent array values

let original = [20 22]
let copy = original
copy[0] = 99
printl(original[0]+original[1])

Expected stdout: 42

Ready

Grapheme lengths

let word = "café"
printl"{word}: {word.length}"

Expected stdout: café: 4

Ready

Paddle

Source
# Build with the experimental source core. The platform library supplies
# the window, input, font, renderer, frame loop, and native/web backends.
$runtime_checks
from p"paddle_model.dewy" import fresh, advance

let world = fresh()

update = (dt:float64):>void => {
    advance(@world min(dt 0.05) mouse_pos().x)
}

draw = ():>void => {
    clear(rgb(0.025 0.045 0.08))
    rect(20.0 100.0 1240.0 2.0 rgb(0.15 0.25 0.35))
    rect(20.0 660.0 1240.0 2.0 rgb(0.15 0.25 0.35))
    circle(vec2(world.position.x world.position.y) 12.0 rgb(1.0 0.7 0.3))
    rect(world.paddle-80.0 632.0 160.0 12.0 rgb(0.3 0.9 0.8))
    text("DEWY / PADDLE" vec2(32.0 24.0) 32.0 rgb(0.85 0.95 1.0))
    text("Move the mouse to keep the ball in play" vec2(32.0 68.0) 18.0 rgb(0.5 0.65 0.75))
    text("Returns: {world.score}    Misses: {world.misses}" vec2(820.0 35.0) 22.0 rgb(0.3 0.9 0.8))
}

Source and companion modules

Move the pointer to keep the ball in play. This game is compile-checked; browser graphics and input need their own checks.

Ready

About this playground

This page runs the shipped programs. It does not compile arbitrary edits. Install the current compiler for your own code. Separate WebAssembly checks record exact expected stdout for terminal examples under Node; Paddle has check/build coverage.