And then there was Pascal, on the web!

22-08-2026



What have I gone and done now..

If, like me, you fondly remember Turbo Pascal 7, the blue editor, the blinking cursor, the way ClrScr and TextColor felt like magic... I stumbled across Pascal around 1992, when I saw a kid use Turbo Pascal 5 to write his own car game. It was so COOL!! And of course, I had been using GW-BASIC and QBASIC to write my own little games, but this Pascal thing was just next level. And the BGI graphics were amazing. And so fast, and just, wow. In 1994, I got my own, legit copy of Turbo Pascal 7, with manuals! I devoured the tutorials, learned everything I could about the language and spent the next decade having so much fun with it.

Turbo Pascal made way for Delphi, and Delphi and I had great commercial success for a while. Sure, I started using Java in 1999 for API development, but my UI development was almost exclusively done in Delphi. Still, during that time, I kept using Turbo Pascal 7 for fun. Building all kinds of DOS programs, from TSR's to graphic demos to simple text-mode applications.

Somewhere in 2025, I bought a book about the Odin programming language and wanted a project to build using Odin, so I could really explore this interesting systems programming language. Of course, I figured I needed to build a simple language interpreter. For a while, I struggled with it, because learning a new programming language can be challenging at times. But I was having fun, Odin does really live up to it's claim of being about the joy of programming. As I grew more comfortable with Odin, I started doing more complicated programs with it. Pretty soon, I started using it for web assembly (wasm) development. After building OdinDOM and Batchiness, as well as some Wasm games, an idea hit me: Why not port my Pascal interpreter to the web? As I worked on that, I realised I could do better: I could actually compile Pascal code to wasm! So that led to another whacky idea...

That idea now has a name: wasmpascal. It's a Pascal compiler that runs entirely in your browser. You type Pascal, hit Run, and it compiles your source to .wasm and executes it on the same page. No installs, no ceremony, just good old Pascal, like it was back in 1992. Except, of course, it's kind of Pascal with a bit of web flair now.


How it works

The compiler itself is written in Odin and ships as a WebAssembly module. It parses your source, compiles it to wasm, and hands it to the browser to instantiate and run. Console programs run inside a Web Worker; canvas programs render straight into a canvas element on the page. The whole compile-and-run loop happens quite fast, Pascal is not a very complex language to parse.

For the console side of things I try to make it behave like I remember Turbo Pascal. You get the fixed character screen, ClrScr, GotoXY, TextColor, TextBackground, Delay, ReadKey and the rest of the CRT functionality I remember using. readln pops up an input line in the browser. The editor even ships a "Turbo Pascal 7" colour theme, alongside Borland Pascal and FreePascal themes, because of course it does. Why not?!

It's not entirely done, of course. There's a lot of Pascal functionality that I haven't had the time to build in yet. But as I go along, and as I try out programs from old Pascal manuals, I update the compiler to bring more functionality to the web. Though I need to pace myself, I can't just keep adding things, there's a fair number of bugs I also need to address...

But it works! I mean, it works for a lot of Pascal programs. Here's the built-in crt_demo example, which is about as nostalgic as it gets:

program crt_demo;
uses Crt;
var
  i: Integer;
begin
  ClrScr;
  for i := 0 to 15 do
  begin
    TextColor(i);
    TextBackground(Black);
    writeln('Palette index ', i);
  end;
  TextColor(White);
  TextBackground(Black);
  writeln('Back to normal.');
end.
            

It's not just console

There's a canvas ABI that plugs into my existing WebAssembly hosts — pascaldom for DOM-ish stuff, batchiness for batched canvas drawing, and a basic_canvas for raw pixels. The examples folder already has Pong, Pascaloids (an Asteroids-style demo), a multi-file Sweep game that shows off uses units, a particle Sparks demo, and a transforms playground. You can write a program with units, or a library that exports functions. There's even a preprocessor with {$IF} and {$FATAL}, because a Pascal without conditional compilation wouldn't really be Pascal. There's even more, you should check out the help and learn sections in the editor.


Errrr, yeah, about that...

This is in a really early state. I'm having fun with it, it's able to do a lot already, but it's not commercial-grade software, yet. To be honest, I don't know if it ever will be. What it does right now, is provide some fun and entertainment, with a hint of nostalgia. It's such a blast to bring old Pascal projects to life on the web - I'm really enjoying this! Bonus points for forcing me to learn a lot more about web assembly and of course Odin!

Go give it a bash: https://wasmpascal.com/. Open the examples dropdown, load Pong or Pascaloids, and hit Run. Then tell me I'm not the only one who missed Pascal.



Return to the blog index