[HN Gopher] Clolog
       ___________________________________________________________________
        
       Clolog
        
       Author : todsacerdoti
       Score  : 165 points
       Date   : 2025-04-15 17:04 UTC (5 hours ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | mark_l_watson wrote:
       | Very cool! I just cloned the repository, will play with it later.
       | 
       | BTW, Clojure was such a brilliant name (from Rich): Whenever I
       | see a project starting with "Clo" I pay attention.
       | 
       | EDIT: had a chance to try it: a very cool resource!
        
         | iLemming wrote:
         | > Clojure was such a brilliant name
         | 
         | IIRC Rich wanted a name that has CLR and J in it - Clojure
         | initially was officially to be supported on both .Net and Java
         | stacks. Later he realized that keeping it completely compatible
         | on both platforms is an uphill battle. CLR Clojure still
         | exists, but it's not "an officially supported" runtime.
        
       | anonzzzies wrote:
       | This is very nice, I played with it before and working on a
       | similar idea in CL (I am one of those people who finds the
       | uniformity of no syntax soothing).
        
       | sterlind wrote:
       | really happy to see something of a revival of interest for logic
       | programming lately. it's an extremely powerful tool if you know
       | when to reach for it.
        
         | MarkMarine wrote:
         | When would you reach for it?
        
           | winwang wrote:
           | I've seen shops (e.g. Netflix I think) use Datalog for
           | certain query types.
        
           | iLemming wrote:
           | Scheduling, e.g., course scheduling - allocating rooms,
           | professors, time slots while satisfying constraints; Product
           | configuration systems - helping customers select compatible
           | options for complex products; Genealogical research -
           | querying family relationships and ancestry; Static analysis
           | tools for code - finding bugs or verifying properties without
           | execution; Medical diagnosis systems - inferring conditions
           | from symptoms based on medical knowledge; Travel planning -
           | finding optimal routes with multiple constraints; Legal
           | reasoning systems - determining applicability of laws to
           | specific cases; Natural language interfaces - parsing
           | questions and generating appropriate database queries;
           | Hardware verification - proving correctness of circuit
           | designs; Puzzle solvers - Sudoku, crosswords, logic puzzles;
           | 
           | Basically anything that excels when declarative specification
           | of relationships is more natural than imperative algorithms.
        
             | sethhochberg wrote:
             | This all makes perfect sense. The gap I usually have - and
             | I admit its probably something of a skill issue, I have
             | relatively little formal CS background - is how these
             | abstract declarations of rules are integrated into a
             | product. The example code in projects like this is usually
             | pretty dense and intangible.
             | 
             | Does anyone have good examples of open source codebases or
             | reading material in this area? Lets imagine I have a set of
             | complex business rules about the way a product can be
             | configured and I want to use a logic programming language
             | to enforce them, called from a web interface based on
             | config data stored in a traditional relational database. Is
             | that... a misunderstanding of how these things are to be
             | used?
             | 
             | I've love a good book about how to bring tools and
             | techniques for logical correctness into a Rails
             | ecosystem... or similar language/framework for app dev. I
             | love the promises many of logic languages make but can't
             | rewrite existing applications in them wholesale and it
             | seems like they're a poor fit for that anyways. How are
             | people blending these worlds at large enterprises? Maybe
             | the answer is that nobody really is yet, and thats what
             | makes things like Clolog + Clojure so exciting?
        
               | iLemming wrote:
               | FWIW I have no formal CS background whatsoever (maybe you
               | shouldn't even listen to me on this matter), but if you
               | want to gain some understanding of rule engines, you
               | probably shouldn't start with core.logic or clolog (I
               | have not looked into this project myself just yet, so my
               | assumptions might be completely misleading) - core.logic
               | imo good for complex constrains and relationships, it's
               | based on miniKanren, but has quite steep learning curve,
               | and not sure if it's worth the effort (as a starting
               | point).
               | 
               | oakes/odoyle-rules is a forward-chaining rules engine
               | with a more straightforward approach - for someone
               | already familiar with Clojure, it should be fun to try
               | out. Then maybe check out Clara Rules, if I'm not
               | mistaken the lib is specifically designed for business
               | rules processing. For understanding the theoretical
               | pieces, you probably want to look into forward vs.
               | backward chaining rule systems; pattern matching used in
               | rules engines; understanding how to model domain rules
               | declaratively; Rete algorithm (odoyle lib explains it and
               | iirc links to the paper).
        
               | ARandomerDude wrote:
               | Great comments, thank you for taking the time to mentor a
               | few interested strangers.
        
               | iLemming wrote:
               | Awww, thank you. As a Clojurian, I aspire to be kind and
               | helpful. The Clojure community is renowned for its
               | friendly, coaching-oriented attitude. Anyone with
               | questions (even those unrelated to Clojure) should
               | absolutely reach out to Clojuristas -- just go to
               | http://clojurians.net and don't be shy.
               | 
               | I'm forever thankful for Clojure for reigniting my
               | passion for programming, but particularly, I'm indebted
               | to the many individuals in the Clojure community.
               | Whenever I pose a question expecting just straightforward
               | guidance or documentation links, I consistently receive
               | profound, thought-provoking answers that surpass my
               | expectations. Virtually every discussion I initiate with
               | them ends up being incredibly educational, teaching me
               | far more than I initially sought. I can confidently admit
               | - yes, learning Clojure has made a better programmer out
               | of me, but most importantly, it made me a better person.
        
             | whartung wrote:
             | Well the bigger question is how big does the system have to
             | be to warrant breaking out a new technique, much less
             | adding a new runtime or other large dependency.
             | 
             | Now, I have no direct experience with any of the common
             | logical programming systems. I have familiarity.
             | 
             | But anytime I came upon anything that might justify such a
             | system, the need just didn't seem to justify it.
             | 
             | Talking less than 100 rules. Most likely less than a couple
             | dozen. Stacking some IFs and a bit of math, strategically
             | grouped in a couple aptly named wrapper methods to help
             | reduce the cognitive load, and it's all worked pretty well.
             | 
             | And, granted, if I had solid experience using these
             | systems, onboarding cost would be lower.
             | 
             | When have you found it to be worth cutting over?
        
               | iLemming wrote:
               | Absolutely valid and befitting point - adding complexity
               | without clear benefits never should be justified. Most
               | (business) applications have ruleset logic for specific
               | problems not exceeding a dozens of rules - regular code
               | often works fine.
               | 
               | Logic systems tend to show the value when rules become
               | complex with many interdependencies or non-linear
               | execution patterns emerge, or rules change frequently or
               | need to be defined at runtime; when you need explanation
               | tools - e.g., why was this conclusion reached?, etc.
               | 
               | I agree, situations for when you need to implement a
               | logic system are not extremely common, but maybe I just
               | have not worked in industries where they are - on top of
               | my head I can think of: factory floor scheduling;
               | regulatory compliance (e.g., complex tax rules);
               | insurance systems, risk-calculation (credit approval);
               | strategy games; retail - complex discounting; etc.
        
           | baq wrote:
           | Same reason you'd reach for SQL when querying relations - a
           | good enough tool designed for the job.
           | 
           | The problem has always been getting facts into the prolog
           | system. I've been looking for a prolog which is as easy to
           | embed in eg Python or node as a Postgres client and...
           | crickets.
        
             | Avshalom wrote:
             | I dunno which postgres client you're thinking of but:
             | 
             | https://github.com/tau-prolog/tau-prolog
             | 
             | https://pyswip.org/ https://www.swi-
             | prolog.org/packages/mqi/prologmqi.html
             | 
             | Unfortunately the tau site's certificate seems to have
             | lapsed sometime in the last week or so, but I swear it's
             | actually very good.
        
         | paddy_m wrote:
         | I'm working on a problem that I think logic programming might
         | be a fit for. And I already have a lisp. Anyone interested in
         | giving me some feedback on a mini language for heuristics?
         | 
         | https://marimo.io/p/@paddy-mullen/notebook-b79pj7
        
       | winwang wrote:
       | This might unironically be a reason for me to finally try
       | Clojure!
        
       | jdminhbg wrote:
       | Can anybody comment on when or why to choose this over
       | core.logic?
        
       | cpdean wrote:
       | I absolutely love the aesthetic of a repo having a giant
       | README.md
        
         | SOLAR_FIELDS wrote:
         | I think about docs a lot and the best docs are the ones that
         | are easiest to find. There is few things right in front of you
         | more than README.md
        
       ___________________________________________________________________
       (page generated 2025-04-15 23:00 UTC)