Install SWI on Catalina?

Hi,

I’m running Catalina on my IMac and would like to install, learn, and use SWI Prolog on that OS (10.15.7)
I’ve tried a few times to install the latest stable release 8.x.y but keep getting told that My system is "too old” and that brew can’t run…
Is there a binary/version/way that will install and run on Catalina?
Thanks, Chuck

Did you just try to install using brew? If that doesn’t work it looks like an issue with brew. AFAIK, the binaries from SWI-Prolog downloads should work fine. Preferably take the devel releases. It will become stable shortly anyway.

Note that these binaries are for Intel. If you have an M1 machine you must compile from source. The Intel binary runs on the M1, but is slow. The Macport build should work fine.

The M1 is still a bit problematic. We compile the binaries with gcc as this produces significantly (close to 2 times) faster code that clang. AFAIK gcc does not yet produce M1 binaries. We also need to figure out how to generate a universal binary in the CMake toolchain.

Jan,
Yes, I think the problem was with homebrew. but I couldn’t decipher it at the time.
Still can’t actually. I did however mange to get SWIPL installed and working on my intel machine, the old fashioned way. . .by downloading the appropriate macOS binary and running the installer. I don’t think I have the knowledge or toolset to compile from source and I don’t have M1 (yet!). thanks for the heads-up regarding compilation required on M1.

Just wondering, what do you use as an IDE?
Now, to attempt to digest the manual. . .

Thanks!
Chuck

Did you try the IDE that comes with SWI-Prolog (the Emacs clone, graphical debugger and so on)? It works beautifully :slight_smile: there has been some mac-specific configurations some of us have had to do esp. for “retina” displays but it works.

I’ve found emacs to be sufficient for my needs; but I tend to write systems that process lots of data and whose test cases (which I run with make or similar) fit well with the *compilation* window.

There are many options, such as the native tools, GNU-Emacs, PDT (for Eclipse), a VSC plugin and most likely more. There is also an experimental LSP (Language Server Protocol) that should allow using any editor of choice that supports LSP.

I use the native tools. Just run Prolog in a terminal (terminator), normally starting it as

swipl myfile.pl

To edit the main file, use ?- edit.. To edit anything else that has a name (predicates, modules, files, …), use ?- edit(Name). To find stuff anywhere in the project I split the terminal and use git grep (always have my source under git). Then there is a script edit in the customize directory of the release. I install that in my ~/bin and install a PceEmacs client from https://raw.githubusercontent.com/SWI-Prolog/packages-xpce/master/src/unx/client.c. Just compile that using cc -o xpce-client client.c should work on most machines. Install also in ~/bin. Now, if the Prolog editor is open you can run from any terminal

edit file:line[:column]

To edit at that position. That works nicely with git grep as well as to copy paste locations of error messages for editing. Note that the commandline also allows for editing a file+line. Typically only use the plain file name, i.e. myfile to avoid the need for quotes.

?- edit(file:line).

edit If you use terminator. consider adding the editor plugin. See Install SWI on Catalina? - #10 by jan

After editing sources I normally type ?- make. in the Prolog console to update the compiled image and try again. You can also compile from the PceEmacs editor. Note that the editor runs in its own Prolog thread. This allows editing while the program runs. Prolog/View threads can come handy to see a dynamic chart of the resource usage if your program takes long. That also allows to profile suspect threads for a while to see what it is doing.

Ultimately I hope the LSP protocol will allow for a good user experience on any IDE of the user’s preference … The native IDE works well, but it is a bit unconventional and multiple IDEs for different tasks is a burden. You might still want to use the native editor for browsing around and fixing minor issues as the highlighting and context menus on predicates, calls, files, etc. are quite helpful. That is similar to what I did when using MS Visual Studio and MSVC on Wndows: I used VS for the final steps while I used Emacs for bulk editing.

P.s. The brew version is rather minimal. The Macports version is complete. If you need to go source the best option is typically to install the dependencies from Macports or brew and then just compile from the git sources. First might be a bit tricky. Once working you can update easily in less than a minute.

3 Likes

Haven’t tried them yet, but I will now, thanks! Any hints as to how to best invoke them?

Chuck

Check out Jan’s post he went into detail

I do something similar to Jan, except I use the Emacs term (M-x shell) and compilation windows (M-x compile) – the latter is convenient because I can scan for error messages (using the tab key) and jump to the source code (C-c C-c).

That is indeed the biggest advantage. I don’t like the Emacs terminal that much (although I must admit I haven’t used it for quite a while). In my (dated) experience, it is rather slow, there is no support for “raw” mode (non-echo, no-wait) as used by the Prolog debugger and toplevel and there is no support for color.

Just made me search a bit harder to find terminators editor plugin, so patterns file:line and underlined when hovered and ctrl-click now opens them in the Prolog built-in editor :slight_smile: Almost as good as an Emacs shell :slight_smile: Only lacks a command to go through the error/warning locations (must click one-by-one) and if editing changes the lines, subsequent clicks end up in the wrong place. Well, that is bearable. The built-in editor on the fly checking of your code ensures you get very few messages when loading the code and in many cases one only wishes to fix the first issue and then reload because other issues are often caused by the first. I’m happy :slight_smile: Pushed an updated version of the edit script that cooperates better with terminator.

With the graphical debugger i get a low resolution appearance on mac with retina display. Can i do something to fix that? The graphical debugger is nice!

You can set preferences for the editor in a bit old fashioned way:

  • Start ?- emacs.
  • Use the Edit/Preferences menu. That should (the first time) ask to install the default preferences file.
  • Edit the file as you seem fit. Note that ! is comment. Notably at the end of the file you find font.scale. That scales all truetype fonts with this amount.
  • Save the file, quit and restart Prolog.

That should make the system work reasonable on any screen resolution. Unfortunately the bitmaps are hard coded, so they do not scale. If anyone wants to make pretty icons and can generate them in a few sizes, please contribute them!

1 Like

Would it work if we found an MIT-licensed set of svg icons and used those as a starting point? A precursory internet search shows such things exist.

1 Like

Sure. Anything MIT, Apache, BSD and most (?) CC licenses are fine. In fact, these icons do not end up in final systems and thus any license that allows for them to be freely distributed is good enough.

You find all the icons in packages/xpce/prolog/lib/trace/icons. The idea would be to create several subdirectories with different sizes, e.g., 16x16, 24x24 and 32x32. Adding an svg dir for the SVG version is of course a good idea. I doubt xpce will ever support SVG though :frowning:

Thanks Jan :slight_smile: