HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
mthom
scryer-prolog
Rust2018–2026
mthom / scryer-prolog

scryer-prolog

A modern Prolog implementation written mostly in Rust.

20Distinct people
81Mentions
2Explicit recommenders
2.5KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

A modern Prolog implementation written mostly in Rust.

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

(Will be continued in Part 13) It will take me to read this book, but I love it! I'll be following along in https://github.com/mthom/scryer-prolog (written in Rust) so one…

sitkack used a recommendation phrase. 2 indexed comments match. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 9–Nov 16 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/16/2026, 3:16:21 AM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year81 dated mentions

Observed mentions: 2018-02-26 18:34:13 UTC to 2026-08-05 20:11:30 UTC.

0510152018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 2 mentions; 1 submissions, 1 comments20182019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 8 mentions; 1 submissions, 7 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 14 mentions; 0 submissions, 14 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 8 mentions; 2 submissions, 6 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 5 mentions; 2 submissions, 3 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 10 mentions; 5 submissions, 5 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 16 mentions; 7 submissions, 9 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 13 mentions; 5 submissions, 8 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 5 mentions; 1 submissions, 4 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC211
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC817
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC14014
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC826
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC523
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC1055
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC1679
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC1358
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC514

What Hacker News says

14 sources
The key attraction of the representation I mentioned is that on the level of Prolog programs, the compactly represented lists appear like any other lists, no matter how they are internally represented. So, internally, it is a sequence of raw bytes, and to Prolog programmers, it appears as a Prolog list of characters. In Haskell, as long as we are forced to use ByteString or similar data types to get this efficient representation, the situation is not as convenient: ByteString is not the same type as String, and we have to convert manually between them, i.e., within Haskell programs. So, this causes overhead for programmers: We have to learn a new type with new interfaces, call an unpack function etc. A conceptually simpler solution would be to reduce the number of different types in Haskell programs, and instead implement String (i.e., [C
Read the rest
har]) more efficiently internally so that it can be directly used instead. For comparison, in Trealla Prolog, when we write the string "hello", then it is automatically internally represented in the efficient way as raw bytes. And on the Prolog level, it appears as a list of characters, corresponding to a String in Haskell: ?- "hello" = [h,e,l,l,o]. true. To read from files, there is a single predicate phrase_from_file/2 that internally performs the mmap call. On the Prolog level, we again only see a list of characters, and we can use DCGs as usual to process them. So, the key attraction is that this efficient representation is transparent to the programmer in the sense that lists that are represented in this way are semantically completely indistinguishable from lists that are represented in the naive way internally. To Prolog programs, they have the exact same type, shape, length etc., they are only represented differently internally in the virtual machine. This idea can be used in Erlang and Haskell too to represent strings. Currently, SICStus Prolog is the only Prolog system that can be reliably used for linear programming with constraints and is fast enough, see its library(clpq). I hope that a free Prolog system with a similar feature set will eventually become available. Currently, Scryer Prolog is looking very promising, especially due to the mentioned efficient internal representation of characters and its strong commitment to the Prolog ISO standard. There is ongoing work on a simplex library for Scryer Prolog, please see this issue and the linked file: https://github.com/mthom/scryer-prolog/issues/463 The library contains functionality for solving transportation and assignment problems via network flow algorithms. This sounds similar to your use case, and I hope it works for you.
In The Erlang Rationale (2008) [pdf]
The "naive" and straight-forward way to internally represent a non-empty list is to use a structure of the form (CAR . CDR), where car is the first element of the list, and CDR is the rest of the list. So, you need 3 memory "cells" (i.e., pointers, addresses) for each element in the list: First, the indication that this is a structure of this form (a "cons-cell", in Lisp terminology), then, a pointer to the first element (or that first element itself, if it can be represented in a single tagged cell), and then a pointer to the remainder of the list, which is again of this shape. On 64-bit systems, a cell takes 8 bytes. Therefore, when representing a list of bytes, this representation incurs a 3×8 = 24-fold overhead (!) over a plain sequence of bytes in memory. For example, to represent a 1GB file (which is not very large by contemporary s
Read the rest
tandards) in memory, this representation takes 24GB, which is unacceptable. There are ways to compress this slightly (by "slightly", I mean a small factor, such as a factor of 2), but the fundamental problem remains: Instead of using bytes directly, this representation uses one cell per byte, which is an 8-fold overhead. This is an overarching issue in all languages that represent strings as lists (lists of characters, or lists of integers), such as Erlang, Haskell and Prolog. At the same time, lists – especially lists of characters – are the desired representation we want to use in programs in these languages, because it means that the built-in functionality for reasoning about lists becomes directly available for strings too, and it helps to keep the number of language concepts small. So, how to solve it? Ideally, certainly not by adding another data type to the language ("binary object", "binary string" etc.), because that would forfeit the advantages we get from using lists, and would also make the language harder to teach and learn. Therefore, we ideally solve this with a better internal representation of strings: We internally (i.e., in the virtual machine), represent strings as sequences of plain bytes. Not cells, but direct bytes, using UTF-8 encoding. And when the virtual machine encounters this type internally, then it acts as if a list were encountered, making this array of bytes appear as a list (of characters, or of integers) to programmers. Internally, the system can "tell" whether a sequence of bytes denotes such a list, for example because they are allocated in a dedicated region of the memory, and suitably tagged pointers are used to refer to such sequences, as is the case for other data types such as large integers. This much more compact representation was first explained by Ulrich Neumerkel in an issue for Scryer Prolog: https://github.com/mthom/scryer-prolog/issues/24 The general idea can be applied to Haskell and Erlang too. In another issue, Ulrich explained in more detail how to extend it to partial lists, i.e., Prolog terms that are not lists, but can still become lists: https://github.com/mthom/scryer-prolog/issues/95 This latter issue is unique to logic programming languages like Prolog. Trealla Prolog has already taken the idea to its extreme in that it uses mmap to map an entire file as is into memory when parsing, so that parsing from files becomes extremely efficient: The data from disk appears as a sequence of bytes in memory (the underlying operating system performs the mapping), and the Prolog virtual machine ensures that the byte sequence appears as a list of characters to Prolog programs. So, finally, we can use Prolog for its intended application: efficient, general and convenient parsing of text. PostScript is another good existing example of this combination: Internally, the PostScript interpreter can represent strings very compactly, while to PostScript programs, strings can be used seamlessly like lists. For instance, we get: GS>(hello) { = } forall 104 101 108 108 111 As to your other question: These days, I am applying Prolog for example to reason about safety properties of clinical trial designs, and I am interested in applying logic programming to automate cross-border evidence exchange that member states of the European Union must ensure to satisfy the requirements of the Single Digital Gateway Regulation.
In The Erlang Rationale (2008) [pdf]
As I see it, one noteworthy feature of these libraries is how readily they can be implemented in Prolog itself. For instance, library(format), library(http/http_open) and library(xpath) that are used in the example I posted are all written in Prolog, using at most a few very basic and general building blocks that are implemented in Rust: https://github.com/mthom/scryer-prolog/blob/master/src/lib/f... https://github.com/mthom/scryer-prolog/blob/master/src/lib/h... https://github.com/mthom/scryer-prolog/blob/master/src/lib/x... To run the example across multiple cores, we need more support from the underlying Prolog engine, for instance to run multiple threads. In my view, this is a key aspect of designing a Prolog system: deciding what must be provided by the engine, and what is built on top of it. Scryer Prolog is still in its early stage
Read the rest
s of development. I expect it to provide support for multiple threads and interfaces to external databases in a few years at the earliest. This also depends on how many contributors the project will be able to attract.
In Prolog Web Applications (2016)
Thank you very much for your interest! Prolog is ideally suited for web applications: HTML and XML documents are readily represented as Prolog terms and can be reasoned about very conveniently and efficiently. For instance, let's use Scryer Prolog to fetch all article titles from the HN front page. Put the following in hn.pl: :- use_module(library(http/http_open)). :- use_module(library(sgml)). :- use_module(library(xpath)). :- use_module(library(format)). Then consult the file with: $ scryer-prolog hn.pl and then post: ?- http_open("https://news.ycombinator.com", S, []), load_html(stream(S), DOM, []), xpath(DOM, //a(@class="storylink",text), E), portray_clause(E), false. Yielding: "Apple announces it will switch to its own processors for future Macs". "macOS Big Sur Preview". "Most em
Read the rest
ployees of NYT won\x2019\t be required back in physical offices until 2021". etc. Scryer Prolog is a modern Rust-based Prolog system that conforms to the Prolog ISO standard and provides several libraries for web applications: https://github.com/mthom/scryer-prolog. A key attraction of Scryer Prolog is its compact internal representation of strings as lists of characters, making the system ideally suited for the use case Prolog was designed for: Convenient and efficient text analysis, which is also required in many web applications. Here is a short video about this topic: https://www.metalevel.at/prolog/videos/web_scraping Enjoy!
In Prolog Web Applications (2016)
If anyone is interested in learning Prolog I can recommend two very good Prolog books: The Power of Prolog (from the author of the video)[1] and Simply Logical: Intelligent Reasoning by Example[2]. I also recommend visiting the Awesome Prolog list[3]. Worth checking also interesting extension of the Prolog - Probabilistic Prolog, aka ProbLog[4]. And modern ISO-compatible implementation in Rust language - Scryer Prolog[5]. [1] https://www.metalevel.at/prolog [2] https://book.simply-logical.space/ [3] https://github.com/klaussinani/awesome-prolog [4] https://github.com/ML-KULeuven/problog [5] https://github.com/mthom/scryer-prolog
In The Art of Prolog (1994)
If anyone is interested in learning Prolog I can recommend two very good Prolog books: The Power of Prolog (from the author of the video)[1] and Simply Logical: Intelligent Reasoning by Example[2]. I also recommend visiting the Awesome Prolog list[3]. Worth checking also interesting extension of the Prolog - Probabilistic Prolog, aka ProbLog[4]. And modern ISO-compatible implementation in Rust language - Scryer Prolog[5]. [1] https://www.metalevel.at/prolog [2] https://book.simply-logical.space/ [3] https://github.com/klaussinani/awesome-prolog [4] https://github.com/ML-KULeuven/problog [5] https://github.com/mthom/scryer-prolog
In The Power of Prolog [video]
Prolog is fundamentally well established (~40 years old), and you can start using it today in several programming languages. For example: JavaScript http://tau-prolog.org Ruby https://github.com/preston/ruby-prolog Rust https://github.com/mthom/scryer-prolog Erlang https://github.com/rvirding/erlog If your language is missing one, implementing a basic Prolog is fairly simple. Take a look at the Ruby one: it's core is not even 500 lines of code! There are also great options like SWI Prolog if you want to build your entire app in Prolog. But I imagine it would be much easier to convince a work boss to pull in a library instead :) Re AI: It's true that Prolog's origins involved AI, but nowadays Prolog is better suited for more general logic programming tasks (there are better tools out there for AI specifically).
In Guitar Chord Voicings with Prolog
I recommend starting with [0] to get a feel for what's possible. [1] is great when you have time to dive deeper. [2] is good motivation, and [3] will show you how to build a practical roles & permissions system. Keep in mind that you don't have to build your app in 100% prolog to use prolog. There are likely implementations in your favorite language. For example, Rust[a] JavaScript[b], and Ruby[c]. [0] https://learnxinyminutes.com/docs/prolog/ [1] https://www.metalevel.at/prolog [2] https://youtu.be/G_eYTctGZw8 [3] https://github.com/TheClause/learn-prolog/blob/master/articl... [a] https://github.com/mthom/scryer-prolog [b] http://tau-prolog.org/ [c] https://github.com/preston/ruby-prolog
In Ask HN: How to rediscover the joy of programming?
Thank you a lot Mark for participating in this discussion, and for all your work on Scryer Prolog during the last few years! In the hope to attract further contributors to Scryer Prolog, especially with interest in Rust, I have now created a GitHub issue that collects a few self-contained features that could be interesting to look into for Rust programmers: https://github.com/mthom/scryer-prolog/issues/319 I hope that's OK, and I invite everyone who is interested in these topics to contribute to this very innovative new Prolog system! Already in this early stage, it provides several important features that no other system currently has. Thank you again!
In The Power of Prolog
Thank you very much for your interest, I greatly appreciate it! I hope you are all doing reasonably well. Please take care! This book was most recently discussed here in May 2018: https://news.ycombinator.com/item?id=17121028 Since then, I have added a new chapter, Logical Foundations of Prolog: https://www.metalevel.at/prolog/logic Also, I have made several other additions and improvements. You can see most of the changes since the last discussion in a public git repository: https://github.com/triska/the-power-of-prolog/compare/8a94ed... Currently, I am working on several videos that will eventually form the core of the book. Here are a few previews: https://www.metalevel.at/prolog/videos/logic https://www.metalevel.at/prolog/videos/timetabling https://www.metalevel.at/prolog/videos/sparrows_on_eagles These videos are all work in progres
Read the rest
s, and they may be replaced by better versions at any time. Hence, if possible, please use the links above to refer to them: They will always point to the latest versions. Alternatively, please use the following overview page that shows all videos: https://www.metalevel.at/prolog/videos/ Also, I have published a comprehensive journal paper about my CLP(B) system, i.e., a SAT solver with some nice algebraic properties, seamlessly integrated into Prolog as a specialized form of unification: https://www.metalevel.at/boolean.pdf For Prolog application programmers and system implementors, the paper's appendices may be especially interesting. They formalize a few important concepts that are also a major theme in the book. As of October 2019, the CLP(B) system is also available in Mark Thom's Scryer Prolog. Scryer is a Rust-based Prolog implementation that is freely available, conforms to the Prolog ISO standard, represents strings efficiently as lists of characters, and includes important features for implementing Prolog-based constraint solvers: https://github.com/mthom/scryer-prolog As of a few days ago, Scryer Prolog also ships with my implementation of CLP(ℤ), Constraint Logic Programming over integers. This is a very useful declarative paradigm for solving combinatorial tasks, in some ways superior to SAT solving because it allows more convenient modeling, easier experimentation with different formulations, and reasoning at a higher conceptual level. The chapter on declarative integer arithmetic contains more information, and further pointers: https://www.metalevel.at/prolog/clpz For illustration, here is an example page where you can solve timetabling instances with this approach: https://www.metalevel.at/prolog/timetabling/ I welcome all comments and suggestions about the book, these videos, and Prolog in general. Also, I would like to take this opportunity to thank all readers for your thoughtful comments and endorsements. Your feedback and encouragement are making this work especially worthwhile. Enjoy!
In The Power of Prolog
Regarding the following quote about type String = [Char]: “This is not only a bad representation, it’s quite possibly the least efficient (non-contrived) representation of text data possible and has horrible performance in both time and space.” It is true: This is slow if String is internally implemented so naively that it is "really" a list of characters. However, better internal representations are possible, i.e., internal handling of strings as if they were lists of characters, so that a String appears to Haskell code as a perfectly "normal" list, while internally being represented much more efficiently as a sequence of raw bytes. In other words, the fact that String has this specific type (i.e., [Char]) does not mean that it needs to be implemented in the most naive way possible by the Haskell compiler or interpreter. Prolog is in a v
Read the rest
ery similar situation: For convenience to Prolog programmers, strings in double quotes (such as "abc") ought to be interpreted as lists of characters (such as [a,b,c]). So, to Prolog code, strings should appear as if they were "normal" lists. This makes them amenable to Prolog's built-in parsing mechanisms and many predicates over lists that are already available. At the same time, strings should be internally represented more efficiently, as sequences of bytes in memory. Recently, Mark Thom has expressed his interest in implementing such a solution in Scryer Prolog: https://github.com/mthom/scryer-prolog/issues/95 The same idea may be applicable to Haskell, to combine convenience with efficiency when handling strings.
In The Haskell String Situation
Thank you very much for your kind words, and for your interest! Yes, absolutely: In fact, Prolog was designed for natural language processing and convenient interfacing. However, currently, all existing Prolog systems fall short for such use cases in that they do not optimally combine efficiency with convenience when processing lists of characters. Ideally, lists of characters are efficiently represented internally, i.e., as sequences as raw bytes, and at the same time made available to Prolog programmers as "completely normal" lists, like all other lists, so that they are amenable to DCGs etc. So, to seriously advertise such use cases, there must first be a Prolog system that handles lists of characters in an efficient way. Recently, Mark Thom has confirmed his interest in implementing such an efficient internal representation in Scryer
Read the rest
Prolog, please see the relevant issue: https://github.com/mthom/scryer-prolog/issues/95 Rust programmers may be interested in helping with the implementation!
In Show HN: Constraint-Based School Timetabling with Prolog

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.