Skip to content

Repository files navigation

DynaLOGO

A new implementation of the LOGO programming language, written in Rust.

DynaLOGO's syntax closely follows UCBLogo, extended with dynaturtles — turtles that have velocity as well as position, with real-time collision detection and event "demons" — as described in Seymour Papert's Mindstorms and realized in Atari LOGO and MicroWorlds LOGO.

TO SPACESHIP
  TELL 0
  SETSHAPE "ship
  SETSPEED 20
  WHEN TOUCHING [0 1] [EXPLODE]
  WHEN EDGE [BOUNCE]
END

DynaLOGO native turtle window

Goals

  • UCBLogo compatibility — rich syntax and a broad compatibility surface, including dynamic scope, templates, macros, property lists, file/workspace tools, Atari LOGO-inspired helpers, and UCBLogo-accurate error messages.
  • Dynaturtles — velocity-bearing turtles, SETSPEED/SETVELOCITY, WHEN TOUCHING/WHEN EDGE collision demons, BOUNCE/WRAP/FENCE edge modes.
  • Performance — bytecode VM (not a tree-walker), fixed 60 Hz simulation tick decoupled from rendering, struct-of-arrays turtle storage, spatial-hash collision. Target: 1,000 colliding dynaturtles at 60 Hz.
  • Live — the REPL and the simulation run concurrently; typing never freezes moving turtles.

Workspace layout

  • crates/dynalogo-core — lexer, parser, bytecode compiler, VM, values, the dynaturtle sim engine, and both native/cooperative runtime utilities
  • crates/dynalogo — native frontend: window, turtle rendering, and REPL

dynalogo-core is headless and has no graphics dependencies.

Documentation

Running DynaLOGO

Terminal REPL

cargo run -p dynalogo --bin dynalogo

Useful commands:

  • help / help "fd — show embedded interactive help
  • apropos "turtle — search help topics
  • cargo run -p dynalogo --bin dynalogo -- --eval 'print sum 2 3'
  • cargo run -p dynalogo --bin dynalogo < examples/square.lgo

Native turtle window

cargo run -p dynalogo --bin dynalogo-window

The window frontend keeps a small command log at the bottom and renders turtle lines on a centered Cartesian canvas. The startup log suggests HELP / APROPOS examples, and the prompt supports command editing with Left/Right, Home/End, Backspace, Delete, and Up/Down command history.

Browser demo (WASM)

DynaLOGO includes a browser-oriented macroquad build of dynalogo-window and an in-page REPL demo shell. The GitHub Pages deployment workflow is currently manual-only and no-op while a GitHub-hosted release-mode WASM linker failure is investigated.

You can validate the browser build locally with:

rustup target add wasm32-unknown-unknown
cargo build -p dynalogo --bin dynalogo-window --target wasm32-unknown-unknown

The committed demo shell lives in web/index.html. When Pages deployment is re-enabled, the workflow should copy that shell, the compiled dynalogo-window.wasm, and the example .lgo files into the published site artifact. The shell includes a grouped example gallery dropdown covering every program in examples/, plus a Starter snippet; picking one and pressing "Load Example" fills the REPL textarea for "Run in Demo". It also includes a small browser-side shape editor for building PUTSH / SETSHAPE commands against the current shape registry.

See docs/browser-demo.md for a full local-serving walkthrough and an honest list of what differs from the native window (mainly: no real file I/O, and audio may need a user gesture first).

WASM/core status

dynalogo-core also builds for wasm32-unknown-unknown and exposes a cooperative runtime designed to be advanced from a browser render loop such as requestAnimationFrame.

You can validate the core build with:

cargo check -p dynalogo-core --target wasm32-unknown-unknown

Current feature snapshot

Implemented today:

  • TO ... END procedures with dynamic scope and recursion
  • Core control: REPEAT IF IFELSE RUN RUNRESULT REPCOUNT
  • Richer v0.3 control: TEST IFTRUE IFFALSE CATCH THROW ERROR WAIT
  • Library control structures: FOR WHILE UNTIL DO.WHILE CASE COND
  • Lists/words: FIRST BUTFIRST LAST BUTLAST FPUT LPUT SENTENCE LIST WORD
  • Data utilities: COUNT ITEM EMPTYP EQUALP MEMBERP
  • Arithmetic, infix operators, comparisons, and boolean logic
  • Variables and property lists: MAKE THING LOCAL PPROP GPROP PLIST REMPROP
  • Arrays and templates: ARRAY SETITEM LISTTOARRAY ARRAYTOLIST MAP FILTER REDUCE FOREACH APPLY CASCADE CASCADE.2 TRANSFER
  • Macros: .MACRO .DEFMACRO MACROP MACRO? MACROEXPAND
  • File/outside-world helpers: LOAD SAVE EDIT OPENREAD OPENWRITE OPENAPPEND READWORD READCHAR READLIST READLINE DRIBBLE ERF CATALOG KEYP JOY PADDLE TIMEOUT SETCURSOR SETENV CT; native builds can EDIT "program.lgo through $EDITOR/$VISUAL (or Notepad on Windows) and evaluate the edited source
  • Static turtle graphics: FD BK LT RT SETXY SETPOS SETH HOME CS PU PD PE PX PN SETPN PC SETPC SETC SETBG SETPENSIZE SETSP SETSCRUNCH SETLABELHEIGHT LABEL HT ST POS HEADING XCOR YCOR
  • Dynaturtle shape surface: SETSHAPE SHAPE PUTSH GETSH, registry-backed custom-outline rendering, the browser shape editor, and $EDITOR-driven EDSH

Remaining compatibility notes now live in the reference and compatibility docs; see docs/reference-manual.md, docs/ucblogo-compatibility.md, and docs/atari-logo-validation.md.

Example programs

See examples/ for runnable programs.

Classic turtle examples:

  • square.lgo — the smallest turtle demo
  • flower.lgo — procedures + repeated drawing
  • spiral.lgo — arithmetic, variables, and looping

Dynaturtle examples:

  • shape_parade.lgo — animated turtle / dog / ship shapes
  • dogs_in_the_park.lgo — collision-driven barking with WHEN and TOOT
  • spaceship_thrust.lgo — ship-thrust / inertia sketch
  • bouncing_ball.lgo — collision-based bouncing demo
  • orbit_simulation.lgo — orbit-style multi-body trails
  • pong_demons.lgo — a small collision-demon pong sketch

Releases

Download the latest prebuilt packages from the GitHub Releases page. Packages include both the dynalogo terminal REPL and dynalogo-window native turtle frontend. See the Getting Started installation guide for extraction and first-run commands.

Tagged pushes (v*.*.*) trigger a GitHub Actions workflow that builds native dynalogo/dynalogo-window binaries for Linux, macOS (arm64), and Windows and attaches them to a GitHub Release. See docs/release-process.md for the build matrix and known limitations (no code signing/notarization, no installers).

Status

The 1.0 release is suitable for experimenting with core Logo, static turtle graphics, Computer Science Logo Style examples, and dynaturtle programs. See ROADMAP.md for the historical version plan, PLAN.md for the architecture, docs/getting-started.md for onboarding, and docs/primitive-inventory.md for a snapshot of the currently implemented primitive surface.

Versioning

See docs/versioning.md for the version policy and changelog process, and CHANGELOG.md for what's changed.

License

MIT — see LICENSE.

About

A UCBLogo-compatible LOGO implementation in Rust with dynaturtles (velocity, collision demons) from Mindstorms/Atari LOGO

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages