Pscal, The Mostly AI Generated Pascal Byte Code Compiler & VM That The World Didn't Need

emkey1966

New member
First post, and I'm flogging something. Sorry about that. Hopefully this is an appropriate spot?

A short bit of background: I spent the majority of my career working in various IT-related roles, including supporting the installation and day-to-day operations of very large cluster/supercomputers. Programming has always been a part of my life, both professionally and in my spare time, but it's never been my forte. I ended up doing systems support-related tasks because that was where my strengths led me.

I've also always had a fascination with and desire to write a compiler. I just didn't have the time, nor, to be frank, the talent. I did take a compiler design class many years ago in college, so I'm not a total novice.

Four months or so back, I decided to see if AI had reached the point where it could take on a task of this size and complexity. The short answer was: kind of. I tried a number of different AIs at that point but ended up doing the bulk of the work with Google's Gemini 2.5 Pro, as the others I tried stopped being effective around 3,000 lines of code. Fast forward a couple of months, and I reached the point where Gemini stopped being effective. That happened in the 23,000 lines of code range. So I took a break from the project, knowing that if I waited, there would likely be advances that made continuing possible. The release of OpenAI's GPT-5, in conjunction with their Codex ended up what I was waiting for.

While I am not a great programmer, I do, as I said, have a background in compilers and several decades of programming experience, which was a huge help. For instance, I occasionally had to explain how to properly implement back-patching or reject an AI's kludgy solution in favor of explaining a better approach. In short, this wasn't a task for a novice, even with the latest AI's. AI is a powerful tool and a productivity multiplier, but it isn't capable of taking on a large complex task and carrying it to completion at the moment. At least that is my experience. There is still the need for a lot of hand holding and knowledgeable advice.

Why a Pascal bytecode compiler and VM? Because I've always had a soft spot for Pascal. Borland's Turbo Pascal was what I used in the early part of my career when I was still primarily a programmer. Does the world need a Pascal bytecode compiler and VM? Probably not. But that was really secondary to my primary goals, which were to fill some time and see just how capable LLMs/AIs had become.

The source code is all available at...

https://github.com/emkey1/pscal

And it is completely free to use for anything, though I'd like to be given some sort of credit on the off chance somebody repurposes the VM, for instance. While it was written with AI, I was, for better or worse, the architect and overall 'project lead'.

The 1.0 release is at...


And should compile on MacOS or Linux, though I do the bulk of my development and testing on my Mac.
 

Attachments

  • Logo.webp
    Logo.webp
    72.2 KB · Views: 9
  • Screenshot 2025-08-16 at 07.22.23.webp
    Screenshot 2025-08-16 at 07.22.23.webp
    25.7 KB · Views: 2
  • Screenshot 2025-08-16 at 07.24.10.webp
    Screenshot 2025-08-16 at 07.24.10.webp
    72.5 KB · Views: 1
  • Screenshot 2025-08-16 at 07.23.21.webp
    Screenshot 2025-08-16 at 07.23.21.webp
    24.7 KB · Views: 2
@emkey1966 cool!

All these agents are really a game changer.Something I wonder if I should just change the way I code completely, I've always tried to minimize the amount of code. But nowadays that's not of any use almost.
 
It's mind blowing to me. I did a 2.1 beta release yesterday. The changes and additions since the 1.0 release, only two or so weeks ago are huge. The most notable being the addition of a front end that looks a lot like C (CLike) and true multithreading. I'm now working on the 2.2 version, and have already added the ability to call functions via pointers to my devel branch...
Code:
#!/usr/bin/env clike
int inc1(int x) {
    return x + 1;
}

int main() {
int f;
f = &inc1;            // take address of function
printf("%d\n", f(41)); // indirect call via function pointer (address in 'f')
    return 0;

Code:
#!/usr/bin/env pascal
program ThreadsProcPtrDemo;

type
  PInt = ^integer;
  PInc = function(x: Integer): Integer;

function Inc1(x: Integer): Integer; 
begin 
  Inc1 := x + 1; 
end;

procedure Worker(p: PInt);
begin
  p^ := p^ + 1;
end;

var p: PInt;
    t: integer;
    f: PInc;
begin
  { Demonstrate CreateThread with a pointer argument }
  new(p); p^ := 41;
  t := CreateThread(@Worker, p);
  WaitForThread(t);
  writeln('thread result: ', p^);  { 42 }
  dispose(p);

  { Demonstrate procedure/function pointers and indirect call }
  f := @Inc1;
  writeln('func ptr: ', f(41));     { 42 }
end.

I'm in the middle of adding a bunch of additional networking functionality to the same branch and have plans to add an object oriented language front end in the next week or so. I'm a fairly mediocre programmer with a bit of domain knowledge, both in working with AI and compiler design. The fact that I can get this much done in that short a period of time is mind blowing.
 
Back
Top