Dear SWI-Prolog user,
This is set of rather personal notes. Some users may have noticed
changes in how I manage SWI-Prolog. Most recent contributions have
been implemented by Claude Code and I’ve not been very active on the
forum. The reason for this is that I was diagnosed with rectal cancer
in August last year. End of April I had the main surgical intervention.
Together with some complications this caused a lot of discomfort,
notably not being able to sit for more than 10..15 minutes. There
will be some more uncomfortable treatment. The good news is that,
unless I’m very unlucky, I should fully recover.
Not being able to predict how I would function during the various
treatment steps as well as problems concentrating caused a serious
change of activities. Except for small tasks for long-term commercial
customers I have not done any commercial work in that period. Instead,
I concentrated on improving SWI-Prolog, the tooling in particular because
it distracts, is fun and I do not have to deal with deadlines.
After the main surgery, traditional programming was not an option.
This is a perfect moment for contemplation and trying new paths.
Inspired by @EricGT I have been exploring the use of AI, Claude Code
in particular. I explored ChatGPT about a year ago to conclude it
might be nice for student exercises, but not for programming. Half a
year later I used ChatGPT for porting the XPCE GUI library to SDL3.
That was a better experience, although overall still a mixed blessing.
It was mostly good at finding the right API calls from SDL3, Pango and
Cairo, but plumbing them the wrong way. Pointing it at a bug
typically resulted in a completely different new implementation that
was buggy some other way, so eventually I had to do most debugging.
Agentic AI, first OpenAI Codex, is a game changer though. I quickly
switched to Anthropic’s Claude Code, mostly because they seem to be
most aware of the ethical implications of AI and are considered
state-of-the-art.
I used Claude Code mainly to enhance the tooling, mostly because it is
fun and doesn’t require too much deep thought. Working with the AI
fits my current physical state perfectly: sit down shortly to review and
adjust the AI generated plan, review code and test it then type a few
sentences of new instructions. Next, one can do exercises or other
small tasks while Claude Code does the work for a few minutes or
sometimes as long as several hours for writing a random test suite for
the commandline editor, simplify a failed run and fix it; repeat until
1,000 random edits show no issues.
Main tasks tackled (contemplation on that below):
- Get libedit (the commandline editor) to work properly on normal
terminals, the Windows console and the Epilog console. - Make Epilog deal with 256-colour and direct-colour modes, strike-through and
proper link (hover) feedback. Required significant changes to the basics
of the terminal. Implemented by Claude Code with minimal
intervention. - Get libedit, XPCE and Prolog to deal with the full Unicode range,
including double-width glyphs (Emoji, several Asian scripts) and
Unicode combining characters. This included changing the text
representation used in XPCE. All this was implemented by Claude
with minimal intervention from my side. It tends to use a bit too
much copy/paste programming, but if you point at that it is happy
to generalise and reuse. - Implement a Unicode symbol picker in XPCE. It needed some help
and a few iterations, but programming in XPCE+Prolog is not really
mainstream! - Deal with refining the Prolog Unicode syntax extension. Both
implementation and design. Handle feedback from the PIP working
group on this topic. - Update XPCE’s look, notably by designing SVG icons and adding support
for SVG icons to XPCE. I’m not really impressed by Claude’s ability
to design icons. It took a lot of guidance and is still far from
the quality that a human graphic designer would have produced. It
does look less 1990 style though
- Implement 2D transformation matrix in XPCE, allowing for scaling,
rotation and shearing. This is a giant task that was completed
in two days with only a short planning stage and few prompts. - Same for implementing opacity for graphical objects (much simpler
though). - Refactor the XPCE reference documentation that was stored in saved
binary blobs representing XPCE objects. Its task was to extract
the documentation, store it in Markdown files and add a plugin to
PlDoc to make it understand the XPCE documentation conventions.
This required quite a bit of guidance. But then, it concerns a
lot of legacy material in a rather alien environment. - Modernise the documentation of many classes, notably updating it
for the changes due to moving from X11 to SDL3 (still need more
work). - Refactor the MacOS binary from a bundle to a
.pkginstaller
and include all the automation to sign the package. I had started
to do this by hand, but gave up as it was too complicated and
frustrating. Claude did the job quite quickly and with not much
intervention. - Fix quite a few bugs. I’m most impressed by Claude’s ability to
fix bugs. With very little input it often finds the culprit
remarkably quickly. It is not always right about the details
nor the fix. Even if it is wrong, its analysis helps a lot in
nailing the problem. These days I start giving it the URL of
a bug report and see what it comes up with. - Write a lot of (PlUnit) tests as well as writing, improving
or updating documentation.
Contemplation
What did I learn? First of all that agentic coding systems have
matured immensely. In my experience to the level where these tools can
no longer be ignored. Is this good or bad? First of all, it just is
there and we cannot uninvent it. I was first considering this a
threat as it makes what I liked doing for over 40 years redundant.
Right now, I’m quite positive. Claude does a lot of the boring work
that also belongs to system development: bug hunting, writing tests,
updating documentation, reading through API documentation,
investigating portability issues (which platforms support X, if I
drop support for an outdated API, would it affect any still supported
platform, etc.). Instead, I can concentrate on what I want. If I
want to do some programming I still can. I can leave the finishing
touch to the AI though: write tests, fix issues and document; the
tasks that typically take most of the time and I like doing least.
I tried this and it was a pleasure!
What about our profession? I learned programming by doing small tasks
in the then young XPCE GUI library developed by Anjo Anjewierden. I
learned a lot by looking at his clean programming style and design.
Richard O’Keefe taught me a lot from work I did on his Thief editor
(a very lightweight Emacs clone used in Edinburgh in the 1980s, when
Emacs was an abbreviation for Eight Megabytes And Continuously
Swapping) as well as the many comments he had on SWI-Prolog. In
short, I learned by imitating and comments from giants. Now I
have the experience to prompt the AI, keeping an overall overview
of where the system should move, its architecture as well as general
principles on maintaining good programming style. How will young
professionals gain these skills?
These developments do raise some existential questions. I’ve spent
quite a bit of time on SWI-Prolog’s development tooling and made a lot
of progress with help from the AI. However, the AI doesn’t need most
of this tooling for writing Prolog programs … Crash reports with
good diagnostics are useful to the AI, but it doesn’t need a GUI
debugger, tooling that provide insight in the program structure,
editors, syntax highlighting, etc.
I tend to believe there is still a role for Prolog itself as it is
a good language for knowledge intensive tasks that require reliable
reasoning. For any such task, a Prolog program will outperform AI
by a large margin while providing trustworthy results rather than
results that are 95% correct, but wrong in some weird way in the
other 5%. Formalised as Prolog typically makes the logic easier
to assess and verify than imperative languages. I do believe most
of the Prolog code will soon be AI generated though.
Final words
I hope (and suspect) that I will soon recover enough to resume work
without constraints due to concentration problems and not being able
to sit comfortably. I’ll continue work on SWI-Prolog and hope to
restart commercial work in a couple of months. Donations (thanks!) as
well as commercial work are important to keep the project financially
healthy. Commercial work is also important to find new challenges.
I wonder about the overall direction in which (SWI-)Prolog should
evolve. Improving tooling, aiming at human program development seems
not a good investment. Possibly the tooling still has a role
maintaining an overview of the code? Tools like the profiler,
coverage analysis and static analysis can still play a role in
assessing bottlenecks, test completeness and potential bugs. With
modern graphics, XPCE can again play a role in providing interactive
GUI applications as the AI is quite capable of doing so.
I’m considering some refactoring of the Prolog core. Notably the way
engines/threads are threaded through the system is awkward. Too much
work to do by hand, but if the AI can do it, it is worth considering.
Actually exploiting the 64-bit Prolog cells we have now (also on 32
bit platforms) rather than using indirections to make all data types
fit into 32 bits can simplify the system and provide some performance
improvement. Implementing proper clause indexing for typical Prolog
predicates using a handful of clauses and for which first argument
indexing does not work well is another many times delayed plan. More
static analysis tools? Ideas on what has most impact are welcome.
Enjoy --- Jan
P.s. I wrote this myself
I did ask Claude to fix spelling and grammar …