Setup
Implementations
Before you start, you have to choose one of the many existing implementations. Happily there is an ISO standart, defining a common core language called ISO Prolog. If you choose an implementation supporting this standart, you will be able to write Prolog code, which is runable on different prolog implementations.
If portability of your code is not significant for your choice of an implementation, you might want to look for the many interesting implementation specific language Extensions.
Most linux distributions have packages for at least GNU Prolog and SWI-Prolog. Other widespread implementations include Ciao and YAP. Personally I have good experience with the very powerfull XSB.
Recently I got aware of Scryer Prolog, a modern Prolog implementation written in Rust 😍
Scryer Prolog
The developers claim:
Scryer Prolog aims to become to ISO Prolog what GHC is to Haskell: an open source industrial strength production environment that is also a testbed for bleeding edge research in logic and constraint programming, which is itself written in a high-level language.
Scryer supports WebAssembly 😀 It can very easily be used from Javascript as this example shows…
Playground
Thanks to WebAssembly support and the Scryer Playground, you can simply try Prolog at this simple website without installing anything. If you are new to Prolog, this hints how to use the Playground might be helpfull…
Installation
First check if scryer is available from the packet manager of your distribution…
…otherwise building it yourself is easy, since only cargo is required.
The official installation instructins explain how to use Precompiled binaries and Docker container.
Nix
If you are already a Nix fanboy, you can start scryer with this simple command:
nix run nixpkgs#scryer-prologYou may also be interested in how to package prolog code for Nix.
If you love logic programming and declarative representations of knowledge, but don't know the declarative and reproducible buildsystem Nix and the linux distribution NixOS, you may want learn about it… 😉