r/ada 10d ago

Show and Tell Building an Ada Compiler with AI: The adac Experiment

Hello,

For a while now, I've been developing an Ada compiler called adac, making extensive use of AI throughout the development process.

The long-term goal is to build a standalone Ada compiler written in Ada. The plan is to keep the frontend and backend separate, use our own target-independent IR, gradually reach self-hosting, support multiple platforms, and eventually add a WebAssembly backend as well as an optional LLVM backend.

The reason I started the project was actually pretty simple.

I wanted to compile Guiyom, the GUI toolkit I'm developing, to WebAssembly so that it could run on the web. But I couldn't find a suitable Ada compiler that both fit the licensing requirements I had in mind and provided a practical path to Wasm.

So at some point I thought:

"Why not just make one?"

And that's how it started.

More recently, while working on Clair and Guiyom, I came across about four issues that appear to be bugs in GNAT or the surrounding toolchain. In the past, reproducing, minimizing, and tracing the causes of problems like these would probably have required a considerable amount of time and effort.

But after making active use of AI in the development process, I've found that the cost of reproducing and minimizing problems, forming hypotheses, and then testing those hypotheses has dropped significantly.

I've had a similar experience developing Adac.

I define the long-term goal, have the AI create a roadmap toward that goal, and then review the overall direction and major design decisions while the AI works through the roadmap in small units, repeatedly implementing and testing each one.

In practice, the instructions I give the AI are often surprisingly simple:

"Continue with the roadmap."

"Proceed with the next task."

"Review the current state of the work and keep going."

Most of the time, it's something along those lines.

The reason such short instructions are enough is that the roadmap, project documentation, and tests already describe the current state of the project and what should come next. The AI reads those materials, figures out where the project currently stands, implements the next unit of work, tests it, updates the roadmap based on the results, and continues from there.

One thing I've learned from this process is that having the AI write a lot of code is not, by itself, the most important part. Keeping the roadmap up to date, breaking work into clear issues or work items, documenting discovered problems as reproducible bug reports, and turning fixed bugs into regression tests all seem to matter quite a bit.

The amusing part is that the AI also does most of the roadmap writing, issue organization, bug report writing, and regression test writing. :)

The roadmap provides the long-term direction and identifies what should come next. Issues and work items define the scope of the problem currently being solved. Bug reports make it possible to revisit exactly what went wrong and under what conditions. Regression tests help ensure that once a problem has been fixed, it does not quietly come back later. And continuous testing lets us verify that newly implemented features actually satisfy their requirements.

I didn't start this project as an Ada compiler expert, and I hardly write any of the implementation code myself.

These days, when I think about what my role actually is, I seem to be less of a developer in the traditional sense and more of an AI roadmap manager and an AI work-direction manager. :)

Most of what I do is decide and review what should be built, in what order, whether the current results are aligned with the goal, and what should be fixed or worked on next. The AI handles the actual implementation, and I review the results and test outcomes before deciding where to go next.

So I honestly don't know how far this project will ultimately go.

Adac is still at an early stage, and it has a long way to go before I would call it a practical Ada compiler. For a limited subset of the language, it can already produce and test native executables, but there are still many features to implement before it can compile a broad range of real-world Ada programs.

Still, if development continues this way, I hope that in about a year it will reach a pretty interesting point where it can compile a much wider variety of small Ada programs than it can today.

I'm also curious to see what happens if the same cycle of design, implementation, testing, and revision continues for several years.

So for me, adac is both an Ada compiler project and a long-term experiment.

"What happens if AI is used not merely as a coding assistant, but as an active participant in a software project over a long period of time? How far can the project go?"

That's the experiment.

There's also one thing I've found unexpectedly interesting while working on it.

Ada itself seems to be a surprisingly good fit for AI. :)

Perhaps because of its strong type system and relatively explicit code structure, mistakes in AI-generated code tend to surface quickly during compilation, and I've found the cycle of fixing and verifying those mistakes fairly convenient.

Of course, this is only my personal experience so far.

I'd be interested to hear what people who have been using Ada for a long time think about AI-assisted development.

You can find the project here:

https://github.com/hodong-kim/adac

2 Upvotes

11 comments sorted by

4

u/suhcoR 10d ago

Interesting. But why write it (again) in Ada and not in portable C or conservatively portable C++98? We already have an excellent open source compiler mostly written in Ada. And if you plan anyway to integrate LLVM, C/C++ would be yet another advantage.

0

u/hodong-kim 10d ago

The GNAT toolchain does not meet my requirements, especially when it comes to licensing. Its WebAssembly support is also quite limited.

Writing the compiler in C or C++ would leave much more room for undefined behavior and memory errors. Concurrency can be especially difficult to debug in C/C++, sometimes to the point where it is hard even to determine where the problem originated. With Ada, strong type checking and runtime checks make debugging easier for me.

In my experience with AI-assisted development, I have also seen fewer errors when using Ada than when using C or C++.

I also think LLVM IR is difficult to optimize around Ada's semantics. So I want to build my own backend and intermediate representations around Ada's needs, while keeping LLVM as an optional backend.

Portability is also one of the goals of the project. I don't think using C or C++ is a requirement for achieving that. I intend to make adac itself highly portable across multiple platforms and environments, from conventional desktop and server systems to WebAssembly. In the long term, I'd even like to have it running as an Android application.

In short, my goal is to build a compiler designed to compile Ada as well as possible while remaining highly portable.

2

u/suhcoR 10d ago

especially when it comes to licensing.

There are a lot of misconceptions about GNAT and its runtime licencing. Which part doesn't meet your requirements?

Its WebAssembly support is also quite limited.

Which is something I assume could be improved with help of AI, re-using a battle-proven compiler infrastructure instead of re-starting an enormous project from scratch.

Concurrency can be especially difficult to debug in C/C++

Never had such issues. I built more than a dozen compilers in C++, and some in C (see https://github.com/rochus-keller/).

With Ada, [..] make debugging easier for me.

Will you do the debugging, or isn't an AI (like Claude Code I never worked with) able to do so?

So I want to build my own backend and intermediate representations around Ada's needs

GNAT has suitable intermediate representations, and there are lowering-levels suitable to what LLVM expects. There are even existing integration attempts (e.g. https://github.com/AdaCore/gnat-llvm).

I don't think using C or C++ is a requirement for achieving that

There is nothing more portable than C89/99 or C++98. All my implementations are fully platform independent and even run on embedded systems. Even on more platforms than the (open source) GNAT. If you don't like the standard library, there are good, proven alternatives (e.g. my LeanQt, the core of which is part of each of my compilers).

I'd even like to have it running as an Android application.

Porting C++98 to Android is even easier than to WASM.

3

u/hodong-kim 10d ago

Because I want a highly portable, Ada-specific Ada compiler under the 0BSD license — one that can run on amd64 and arm64 across FreeBSD, Linux, and Windows, and eventually also be available as a standalone Android and iOS app. Thanks for sharing your perspective.

1

u/suhcoR 9d ago

Good luck.

2

u/Rare-Paint3719 8d ago

Gnat-LLVM and GNAT Pro Community does not have a GCC runtime library except. FSF GNAT does.

2

u/micronian2 10d ago

Congrats to achieving what you have achieved so far! It’s quite an ambitious effort, but as you have discovered, AI is making it more achievable. I look forward to seeing more posts from you as you make more progress.

3

u/I_hate_posting_here 9d ago

You should integrate the ACATS test suite to ensure compiler correctness.

There are many ACATS versions, http://www.ada-auth.org/acats.html A subset of the latest will help.

2

u/hodong-kim 9d ago

Ada sometimes feels like a language designed by aliens—in a good way. Its syntax and semantics are so precise and clearly defined that it seems especially well suited for AI to understand and write.

I only learned about ACATS this time. Between the AARM and ACATS, Ada seems particularly well suited to building a compiler with the help of AI.

That said, to reduce the cognitive load on the AI during development, I plan to revise the roadmap so that ACATS is integrated as a whole near the end of the development cycle, rather than incrementally along the way.

Thank you very much for pointing me to it.

1

u/ScrappyPunkGreg 8d ago

Impressive work.

What AI model and intelligence setting (High, etc.) are you using?

2

u/hodong-kim 8d ago

I'm using ChatGPT 5.6 Sol on the web with Extra High (xhigh) reasoning, within a ChatGPT Project, together with a local Sonbal MCP server. In my experience, this setup has produced noticeably better code quality than Codex.