Comment by b0a04gl

Comment by b0a04gl 3 days ago

2 replies

i tried writing a tiny logic engine once after reading the SICP chapter and yeah, the syntax part was easy to mimic but the actual backtracking logic hit me harder than expected. what helped was thinking of it less like solving and more like building a lazy search tree. once that clicked, i stopped trying to force control flow and just let the tree expand. one thing i didn’t see many mention handling stateful part or side effects blows up fast. even printing during backtracking messes the whole thing. most tutorials avoid that part completely

sirwhinesalot 3 days ago

That's one of the reasons I tell people to avoid Prolog. Leave the side effects to the host language and embed either a miniKanren or Datalog engine.

  • b0a04gl 3 days ago

    yeah agree. keeping side effects in host lang makes life easier. tried forcing it in prolog once and instantly regretted. miniKanren with clean boundaries felt way more maintainable