In my previous post, I rattled on about my first stab at generating the Fibonacci sequence using Prolog. Now, I’d like to tell you a bit about my attempts at getting comfortable with SWI-Prolog.

I had started my ride with Prolog using GNU Prolog, before I found some interesting results with the Fibonacci sequence. My initial trials with SWI made the installation on my mac crash pretty easily. I’ve progressed, and installed xquartz on my mac – something thats been missing for a few years (it was available OOTB with my first mac in 2010 – Snow Leopard). This has made things a lot more stable, even if its not a “native” feel – just start up xquartz before SWI-Prolog, and life is a bit better, though a fair bit short of what I’m accustomed to in this day and age.

There is even a form of an IDE: swipl-win has basic ability to load files into the console (“Consult”), create new files, reload them and edit them in a basic text editor.

It turns out that SWI had a unix origin, hence the X11 environment makes it feel more at home! Its all very retro for me – I learned unix at university in the early 90’s on an X-Windows environment. Considering I missed out on a Prolog course, it somehow connects some dots.

I had installed swi-prolog through a .dmg file, however there may be alternative ways to install on a mac – this stackoverflow thread suggests it can be installed through Homebrew (brew install swi-prolog) and MacPorts. I’m not sure if this would move development more onto the mac than on X11.

I had a look at this SWI plugin to IntelliJ, but I didn’t notice much change at all. There is little in the way of language support – for instance there is no way to create a new prolog project, nor even a file – and very minimal syntax highlighting on my exisiting Fibonacci source. I tried out another plugin for the Logtalk language, and this seemed to provide a little more support in the way of syntax highlighting, but little else as far as I could tell.

Aside from getting better accuracy with numbers, I wanted SWI-Prolog so I could try out the unit testing support. That leads me into my next article…