Using AI to Write Software in Ada/SPARK

submited by
Style Pass
2024-12-27 14:30:02

A few months ago, I started writing a parser combinator library in Ada. Fun and odd stuff to do in a language so strict and non-functional that just using the library seemed wrong. The language is constantly fighting you to not do that kind of stuff. I was able to implement the most common combinators and a few character parsers to make string parsing “easier”. The idea was to use this library to write an URL format parser. I thought it was quite a bit overblown to do that and parsing URL is not hard. So I lost interest in completing the library.

Fastforward to today and I just tried Cursor AI. I needed some code to use as guinea pig and this unfinished project looked like a good candidate. So I loaded Cursor, which is its own Visual Studio Code clone with the AI embedded and asked it to complete the missing parts, add unit tests, SPARK annotations, documentation, etc. I specifically enabled YOLO mode, which allows the AI to run commands, iterate on command output (such as build errors, unit test failures, etc) and fix its own mess.

At first it seemed impressive that it was be able to write missing function implementations, add more combinators, add unit tests, implement a calculator using combinators, even adding SPARK annotations, you name it. But then, when asked to build the project, things started to fall apart.

Leave a Comment