Learn Prolog Now (2006)
Prolog vs Python and general-purpose languages
- Prolog is Turing-complete and, in theory, as versatile as Python, but in practice is used far less broadly due to a much smaller ecosystem and library set.
- SWI-Prolog is described as roughly “Python-like” in capability (FFI, HTTP, threading, ODBC, GUI libs), but everyday tasks like arithmetic, strings, and loops feel awkward compared to Algol-style languages.
- Several commenters argue Python’s main strengths are ecosystem, ubiquity, and ease of learning—not language design—and that Prolog could handle whole applications, just with more friction.
- Others say Prolog is highly specialized: great for certain domains but not a replacement for mainstream languages; one view is that it “should have been a library,” not a standalone language.
Learning curve and cognitive impact
- Many report Prolog as their first humbling programming experience—“mind-bending,” forcing them to unlearn imperative habits.
- Some loved the intellectual challenge; others found it so confusing they failed courses, especially when asked to implement algorithms like A* or N-Queens directly in Prolog.
- Several say learning Prolog (and things like the cut operator, DCGs) permanently changed how they think about problems, even if they never use it professionally.
Where Prolog shines (use cases)
- Ideal for problems involving search, constraints, and relations: graph traversal, scheduling, parsing, compilers, type checking, formal verification, linear programming, and data manipulation.
- Real-world examples mentioned include timesheet/timeline reconstruction, airline ticketing, stock broking, grants reasoning, configuration systems, and expert-system-style analyses.
- DCGs and constraint logic programming (e.g., CLP(FD)) are highlighted as major strengths; parsing and declarative grammars feel especially natural.
Embedding logic programming elsewhere
- Strong desire for “embedded Prolog” or Prolog-like DSLs inside mainstream languages for constraints, configuration, and test generation.
- Various options cited: miniKanren (and uKanren), Racklog and Datalog in Racket, Lisprolog, Picat, Prolog bindings for Python and Ruby, SWI’s MQI and Janus interfaces, and logic/Datalog systems like Flix.
Prolog, reasoning, and LLMs
- A large subthread debates combining Prolog with LLMs: LLM writes Prolog to handle symbolic reasoning, constraints, and logical puzzles.
- Supporters see Prolog’s resolution and constraint solving as a natural complement to LLMs’ weaknesses (counting, formal reasoning).
- Skeptics argue Prolog’s search is still “brute force” and that any language could serve as well, especially those with more training data for LLMs.
- Others counter that Prolog’s foundation in resolution theorem proving means its execution is a form of automated reasoning, unlike typical imperative runtimes.
Semantics and theory notes
- Discussion touches on the Closed World Assumption and “negation as failure” versus classical predicate logic’s open-world view.
- Several commenters emphasize that understanding Prolog requires understanding its logical foundations (Horn clauses, SLD resolution), not just its syntax.