A Lazy Sequence

Initial impressions of Picat

As a tourist into the world of logic programming, I was interested in reading Hillel Wayne talk about Picat, a new (relatively speaking) logical programming language derived from Prolog, but with affordances for functional and imperative programming1. Of particular note, Picat predicates default to deterministic and you have to explicitly opt into nondetermnism, which is a big change from Prolog, which – as a Prolog beginner – is maybe the thing I find most difficult about writing real programs.

I’ve been looking for something to trial Picat with, and this week I gave it a crack on some Advent of Code puzzles (more about that in a separate post maybe). This experiment resulted in around 400 lines of Picat code (including whitespace and some comments), covering some basic IO processing, algorithms, and building my own little test runner over about 5 days. I have not yet experimented in any real way with the planner or constraint programming libraries.


Picat is clearly a research language. For one thing Github doesn’t have syntax highlighting for it (and there are many hundreds of syntaxes supported there). There is a basic VSCode mode that I suspect is a fork(?) of the Prolog mode: it exhibits the same extremely frustrating bug that occasionaly causes random lines of code from elsewhere in the file to be randomly inserted instead of what you typed when some syntax errors occur.

There are very little in the way of developer ergonomics. Error messages report almost zero context, no line numbers, or stack traces. There’s a basic built in debugger but I leaned on println debugging more. There is a basic REPL, although it doesn’t have the readline style ergonomics you might be used to.

The documentation is comprehensive but terse, and I hope you area okay with Times New Roman for everything (everything even inline syntax). Good news, because the language is fundamentally ungoogleable2.


Picat encourages using a functional via it’s API design, and language features. It’s functional programming heavily flavoured by the Prolog origins, so powerful pattern matching and logical variables everywhere. This certainly got me productive quickly: I was writing productive code almost immediately. But it comes at a cost: Picat is not a great functional language, the syntax is, somewhat necessarily, clumsier than an ML or a lisp, or even a modern braces language like Javascript. And the inclusion of functions means that structures are just a little clumsier to work with in Picat than in Prolog: it’s not much but that friction adds up.

Similarly, the imperative facilities are useful (it certainly simplified the IO code I needed to write for Advent of Code), but an expressive imperative language this is not. It reminds me of basic in the 90s. Speaking of which, the IO library exists but is very bare bones.

A consequence of these feature’s is that I found myself writing more functional code than logical code, which was a disappointment. I didn’t really feel like I was getting the advantage of using the language.


As mentioned at the top, I ended up writing a minimal test case runner that would allow you to provide a predicate goal (predicates only, no functions), the name of the variable under test, and the expected value, and it would list successes, failures (predicates with no solutions), and incorrect results. Why did I do this? Because I couldn’t find a testing library in the standard library or elsewhere online.

This was a fun challenge. Prolog, and Picat as a result, have an interesting approach to metaprogramming that feels a bit like lisp macros on rocket fuel. I ended up learning how to make a function that would walk a structure replacing occurances of the named variable under test with a fresh variable, and the executing that goal with the call predicate.

Of course the very first Advent of Code puzzle I tried this on ended up using bigints which immediately blew up the test running (I suspect somewhere deep in the structure rewriting code). Oh well.


I’m not ready to say that I’m finished experienting with this language. But in the 5 days I spent with it, I certainly experienced enough friction to need a break, and ultimately I think Prolog is still probably more interesting to me at this point.


My next logic programming excursion is probably returning to Prolog. SWI Prolog recently released version 10, with improved support for their WASM runtime to let you run it in the browser. I believe Scryer Prolog also has a WASM build. Perhaps I’ll make a Svelte app that wraps up SWI Prolog; I’ve wanted to deploy logical programs for some RPG programs in the browser in the past (Manticore started life as a miniKanren program in Clojure that was rewritten into Typescript).

  1. These are basically syntactic sugar: Picat compiles these down to canonical logical forms.
  2. Googleʻs search AI will insist on generating answers to your queries that are pure fabrication: some sort of bullshit hybrid of Python and Prolog. It’s almost funny given the confidence it supplies this nonsense with.
6 December 2025