Show HN: Ruscal: A Turbo Pascal to Rust Transpiler JJ Behrens released Ruscal, a Turbo Pascal to Rust transpiler written by Claude Code Opus with help from Claude Code Fable, installable via `cargo install ruscal` at version 0.7.0. Ruscal emits a small Cargo project for each Pascal program so old Turbo Pascal code, including graphics and Turbo Pascal 3.0 turtle graphics programs, builds and runs natively on modern computers, and it supports bidirectional calls between Pascal and Rust plus reading and converting legacy binary data files to and from JSON. The tool matters because it lets developers keep editing Pascal and re-transpile, or transpile once and continue in Rust, while preserving Turbo Pascal's wrapping integer arithmetic via `overflow-checks = false`. Ruscal is a fairly-complete and well-tested Turbo Pascal to Rust transpiler, so that you can more easily run your old Turbo Pascal programs on modern computers. Ruscal writes a small Cargo project for each program so you can build and run your old Turbo Pascal code natively. - You can continue editing the Turbo Pascal code and transpile it every time. - You can transpile your Turbo Pascal code to Rust once and then edit the Rust going forward. - You can run your old Turbo Pascal programs even if they use graphics, and port older Turbo Pascal 3.0 turtle graphics programs with a couple of small changes. - You can call out to Rust from a Turbo Pascal program. - You can call into Turbo Pascal from a Rust program. - You can read old binary data files written by Turbo Pascal. - You can also translate those files to and from JSON. - There's even a pretty printer for reformatting your Turbo Pascal code. Ruscal was written by Claude Code Opus with help from Claude Code Fable and JJ Behrens. By the way, Ruscal is pronounced "rust-CAL", with the stress on "CAL", as in "Pascal". You need a Rust toolchain see Requirements requirements . Install Ruscal from crates.io; you don't need this repository: cargo install ruscal Then, next to your program hello.pas here : js program Hello; var Name: string; begin Write 'What is your name? ' ; ReadLn Name ; WriteLn 'Hello, ', Name, ' ' ; end. ruscal run hello.pas translate it to Rust, build it and run it ruscal emit hello.pas just print the Rust run puts a small Cargo project in out/hello/ and runs it see Usage usage . A program finds its units' source files next to it. Declare the routine external , and name the Rust file that has it with {$L ...} , as Turbo Pascal linked assembly. greet.pas : js program Greet; {$L greet.rs} procedure SayHello const Name: string ; external; begin SayHello 'Turbo Pascal' ; end. and greet.rs , next to it: use ruscal runtime::prelude:: ; pub fn say hello name: &PString { pwriteln "Hello, ", name, ", from Rust " ; } ruscal run greet.pas prints Hello, Turbo Pascal, from Rust . A Pascal string is a PString in Rust; ruscal emit greet.pas shows the signature each external routine needs. Calling Rust from Turbo Pascal https://github.com/jjinux/ruscal/blob/main/docs/calling rust.md has the rest. In your Rust project, add Ruscal's runtime, and Ruscal itself to translate the Pascal when it builds both the same version : cargo add ruscal runtime@=0.7.0 cargo add --build ruscal@=0.7.0 --no-default-features and in Cargo.toml , let Pascal's integer arithmetic wrap around, as it did in Turbo Pascal: profile.dev overflow-checks = false Write the Pascal as a unit, pascal/greeter.pas : js unit Greeter; interface procedure SayHello const Name: string ; function Square N: Integer : Integer; implementation procedure SayHello const Name: string ; begin WriteLn 'Hello, ', Name, ', from Turbo Pascal ' ; end; function Square N: Integer : Integer; begin Square := N N; end; end. translate it in build.rs : fn main { ruscal::build::library "pascal/greeter.pas" .unwrap ; } and call it from src/main.rs : ruscal runtime::include library greeter ; use ruscal runtime::prelude::PString; use ruscal runtime::{RuntimeError, call}; fn main - Result< , RuntimeError { // Runs the units' initialization parts. let units = call greeter::GreeterContext::new ?; // call turns a Pascal runtime error into an Err . call || greeter::say hello &PString::from "Rust" ?; let n = call || greeter::square 12 ?; println "12 squared is {n}, says Pascal" ; Ok } cargo run prints Hello, Rust, from Turbo Pascal and 12 squared is 144, says Pascal . Calling Turbo Pascal from Rust https://github.com/jjinux/ruscal/blob/main/docs/embedding.md has the rest. Clone the repository to run its examples: git clone https://github.com/jjinux/ruscal.git cd ruscal If you can open a window on Linux, that needs the packages under Requirements requirements , try turtle graphics press a key after each drawing : cargo run -p ruscal -- run examples/ruscal/turtles.pas Or, needing only a terminal, try a Game of Life written in Turbo Pascal in 1997 follow its menu; to quit while it runs, press p , then 5 , then Enter : cargo run -p ruscal -- run examples/life.pas Examples examples lists the rest: an airport simulation, a clock, tic-tac-toe and more. My first programming language was Borland's Turbo Pascal running in DOS or Windows 3.1. I've always thought that Pascal was the Python of its day in that it was a really pleasant language to code in and was great for newbies. I had all these Turbo Pascal programs that I had written as a student, but I had no easy way to run them. I'm really inspired by the idea of creating a native compiler, but there's hardly a point now that LLVM exists. I also wanted a chance to play with Rust a bit more and to use Claude. Hence, my project to transpile Turbo Pascal code to Rust. If you have some old Turbo Pascal code lying around, give it a try - Rust 1.88 or later the crates use the 2024 edition and its let chains , from rustup https://rustup.rs/ , with rustfmt rustup component add rustfmt , which tidies the generated Rust; without it the Rust still works, unformatted. - macOS or Linux developed on macOS; CI runs on Linux . On Linux, Graph programs need the X11 and Wayland development packages for their window: libx11-dev libxcursor-dev libxkbcommon-dev libwayland-dev on Debian or Ubuntu. - Graph programs open a 640x480 window or draw without one: see RUSCAL GRAPH=headless under Environment variables environment-variables . From the repository root: Transpile, build and run a program. The Cargo project goes in out/