Skip to content
HomeVideosBooks
AllTopicsTrends
BlogsPodcasts
HistoryListsWatch laterLiked videosFollowing

The videos, books, blogs and podcasts Hacker News keeps recommending, all in one place.

VideosBooksBlogsPodcastsAboutPrivacySettings

Data from Hacker News, HackerTube, HackerBooks, HackerBlogs and Open Library. Credits · Not affiliated with Y Combinator.

HomeVideosBooksBlogsPodcasts
Ctrl K
    Cover of The craft of Prolog

    The craft of Prolog

    Richard A. O'Keefe · 1990

    The emphasis in The Craft of Prolog is on using Prolog effectively. It presents a loose collection of topics that build on and elaborate concepts learned in a first course.

    Programming
    Open LibraryAmazon
    Stats for nerds
    18recommend
    57mentions
    30people
    2009–2026years
    67% recommend33% neutral

    Mentions per year

    2009201120132015201720192021202320252026

    What Hacker News says

    1. kriroJul 2026
      Looking at the table of contents, I see no mention of Gödel/incompleteness theorems or limitations which is not a great sign. It does look well structured though but I'd probably recommend just going with "Introduction to Logic" by Tarski and "Metalogic. An introduction to the metatheory of standard first order logic." by Hunter. Those served me well and are fairly understandable for a non-mathematician (imo).

      Alternatively hop straight into Prolog (Art of Prolog, Craft of Prolog).

      thread
    2. floxyJan 2026
      I guess we are supposed to pile on, so I'll add that the author should read "The Art of Prolog" (Sterling & Shapiro) and then "The Craft of Prolog" (O'Keefe).
      thread
    3. kriroJun 2025
      I love Prolog but haven't used it in ages. I should really give it a go again. Whenever I used it my brain needed some adjustment time and then switched to declarative mode. It's a really unique experience and hard to describe. It was also my first contact with immutable data.

      Is implementing a Kanren and embedding it as suggested by the author really the recommended approach? Back in the day I used Sicstus mostly but tried to use SWI whenever possible (because I'm a FLOSS guy at heart). I'm asking because we went the opposite direction and used Prolog as the first language and called Java or C when needed (io, GUI). I'd describe the result as a "hot mess".

      Random note: "Art of Prolog" and "Craft of Prolog" remain two of my favorite CS books to this day.

      I'd be curious what the "state of the art" is these days and would love ve to hear from some folks using Prolog in the trenches.

      thread
    4. JadeNBMay 2025
      > Coincidentally, on Friday I pulled my dusty 1987 copies of Sterling & Shapiro and Bratko off the bookshelf for the first time in literally decades, and built myself a copy of SWI so that I could have a tinker with it for something where I think it may be a good fit.

      If you care for recommendations to complement those two, O'Keefe's The craft of Prolog is my favorite Prolog book.

      thread
    5. YeGoblynQueenneJul 2024
      Thanks, I don't really know much about Functional Programming. My expertise is in logic programming which btw is a different paradigm. I've heard it said that they're similar and it seems to me the reason was the support for pattern matching in functional languages.

      I agree that what "pattern matching" means depends on a programmer's background. It's interesting that the wikipedia article that you link to does not mention "unification" at all and only has one reference in Prolog as one of a group of example languages with a "pattern matching construct"; which is not how I would describe the use of the unification algorithm in Prolog.

      To be honest, I am not sure what is meant by "pattern matching". It seems to be a loosely defined term, like "Finite State Machine" (as opposed to "Finite State Automaton"). I expect that the book you linked to has a more formal treating, perhaps, but from what I can tell from a quick look the "pattern matching" here is based on types. In Prolog, unification is used to bind values to logic variables, which do not have types. So a variable, X, in Prolog can unify, i.e. "match with" absolutely anything. A "pattern" then can be formed by constructing terms (the only data structure in Prolog) with "holes" like p(X, a, b, Y,[1,2,3|Tail], f(Z)) etc. where capital letters are variables.

      One use of this ability is to manipulate singly-linked lists to insert in or remove elements from their tail, where normally only the head of such a list can be accessed directly. What I mean is that in Prolog a list is denoted by the special syntax [H|T] where H is the head of a list (and can be any term, including another list) and T is the tail of the list, another list.

      Normally one appends to a list in Prolog using the append/3 predicate:

        append([], L, L).
        append([H|T], L, [H|R]) :-
          append(T, L, R).
      
      This works on ordinary lists, but it is also possible to define a "difference list" as a term, e.g. like:

        [a,b,c,d|T]-T
      
      Where T is a variable bound to the end of the tail of the list. Two difference lists like that one can be appended with the following predicate:

        append_dl(Xs-Ys, Ys-Zs, Xs-Zs).
      
      For example:

        ?- Xs = [a,b,c,d|T1]-T1, Ys = [e,f,g,h|T2]-T2, append_dl(Xs,Ys,Zs).
        Xs = [a,b,c,d,e,f,g,h|T2]-[e,f,g,h|T2],
        T1 = [e,f,g,h|T2],
        Ys = [e,f,g,h|T2]-T2,
        Zs = [a,b,c,d,e,f,g,h|T2]-T2.
      
      The result of appending is in Zs, but you can see the result of the intermediary unification steps in the other variables echoed in the Prolog REPL (the "listener").

      Of course, because this is Prolog you can also use the same predicate to split a list:

        ?- Xs = [a,b,c,d|T1]-T1, Zs = [a,b,c,d,e,f,g,h|T2]-T2, append_dl(Xs,Ys,Zs).
        Xs = [a,b,c,d,e,f,g,h|T2]-[e,f,g,h|T2],
        T1 = [e,f,g,h|T2],
        Zs = [a,b,c,d,e,f,g,h|T2]-T2,
        Ys = [e,f,g,h|T2]-T2.
      
      Where Ys is what remains if we split Xs from Zs.

      Appending or splitting lists like this is preferred to append/3 because it appends the two lists in a single operation so it can be used to economically put a list together in a loop. The same technique is used with Prolog's Definite Clause Grammars where the "difference" in a difference list is the start and end of a string accepted by a grammar, acting as a parser.

      https://en.wikipedia.org/wiki/Definite_clause_grammar

      Sterling and Shapiro's "The Craft of Prolog" has a nice chapter on "Incomplete Data Structures" using difference lists and patterns with "holes" but I don't think there's a free version online, unfortunately.

      thread
    6. mstJul 2024
      If you want to see something truly fascinating, take apart https://logtalk.org/ - it implements an OO system for prolog which gives you all sorts of advantages (the least of which being a not-terrible way of getting namespaces).

      Reading "The Art of Prolog" and "The Craft of Prolog" was fun for me, as was learning how the Warren Abstract Machine works.

      (I am not at all a prolog expert, merely a programmer who happens to be fascinated by it, so this is all dabbling on my end but hopefully provides some stuff that's fun to learn for you as well)

      thread

    Related

    Cover of The art of Prolog
    2009–2026

    The art of Prolog

    Leon Sterling
    36 recommend · 114
    Cover of Prolog and natural-language analysis
    2010–2025

    Prolog and natural-language analysis

    Fernando C. N. Pereira
    6 recommend · 11
    Prolog Programming in DepthMichael A. Covington
    2009–2025

    Prolog Programming in Depth

    Michael A. Covington
    4 recommend · 5
    Cover of Prolog programming for artificial intelligence
    2009–2026

    Prolog programming for artificial intelligence

    Ivan Bratko
    10 recommend · 17
    Cover of Adventure in Prolog
    2016–2026

    Adventure in Prolog

    Dennis Merritt
    6 recommend · 10
    Cover of Programming in Prolog
    2009–2026

    Programming in Prolog

    William F. Clocksin
    8 recommend · 22
    Cover of AI algorithms, data structures, and idioms in Prolog, Lisp, and Java
    2013–2022

    AI algorithms, data structures, and idioms in Prolog, Lisp, and Java

    George F. Luger
    1 recommend · 8
    Cover of Foundations of Logic Programming
    2010–2026

    Foundations of Logic Programming

    John W. Lloyd
    1 recommend · 7