5 ms·
Clolog
- anonzzzies 2y agoThis 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).
- mark_l_watson 2y agoVery 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 2y ago> 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.
- mappu 2y agoMy /usr/share/dict/words offers Clojure, cajolery, and jocular[ly/ity]. Jocular's not bad.
- iLemming 2y agohahaha. Jocular reminded me the naming story of Karma test runner. Initially they named the project "Testacular". With a description that was something like "Spectacular test runner" (or something like that). Sadly, they had to rename it and the choice imo was a lame one. Karma? Really? I suppose some Mormon-backed Google partner thought the initial name was inscripturesque and the team had to choose something Buddhist to passive-aggressively throw a finger.
- mindcrime 2y ago> Whenever I see a project starting with "Clo" I pay attention. You're going to love my "Cobol in Clojure" project "Clobol" then!
- phlakaton 2y ago"Surely this is a joke," I thought as I read this. Then I did a Google search just to make sure...
- mindcrime 2y agoSo, I actually was joking. But then I did a Google search after reading your response, and much to my astonishment I found that there actually is a clobol project[1]! I honestly had no idea. [1]: https://github.com/enajski/clobol https://github.com/enajski/clobol
- sterlind 2y agoreally 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 2y agoWhen would you reach for it?
- winwang 2y agoI've seen shops (e.g. Netflix I think) use Datalog for certain query types.
- iLemming 2y agoScheduling, 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 2y agoThis 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?
- winwang 2y agoThis might unironically be a reason for me to finally try Clojure!
- jan3024-2r 2y ago[flagged]
- justin_oaks 2y agoYour comment could have been simplified to: "I don't like the syntax" And that could be optimized further by leaving no comment. All syntax is learned. None of it is "intuitive". Anything unfamiliar to you will seem unpleasant. Some syntaxes can be better than others, but to make that distinction you'd have to at least cite reasons why one syntax is better than another.
- dang 2y agoI've taken the liberty of fixing the formatting in your comment so the code reads like code. For HN formatting info, see https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc. But can you please make your substantive points more thoughtfully, without name-calling or shallow dismissals? These things are in the site guidelines: https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html.
- dkersten 2y agoI’ve been programming for 25 years and this looks fine to me. Perhaps it is you who is the problem here and not the code?
- dayvigo 2y ago[flagged]
- jdminhbg 2y agoCan anybody comment on when or why to choose this over core.logic?
- deleted 2y ago[deleted]
- drob518 2y agoClolog is more of a direct translation of Prolog into Clojure, with an s-expression syntax rather than Prolog’s standard syntax, but close. Core.logic is a translation of Mini-Kanren into Clojure and doesn’t use anything close to Prolog’s syntax, even one based on s-expressions. Prolog and Mini-Kanren, while both logic programming systems also use different search algorithms. Prolog uses a depth-first exploration of the solution space, whereas Mini-Kanren uses a breadth-first search. Consequently, Prolog can be more memory efficient (remember, it was created in the 1970s), but it can get stuck in infinite parts of the solution tree and never find a solution. Mini-Karen is less memory efficient as it explores the solution tree more broadly, but it can find solutions even if the solution tree has infinite branches. So, why/when to choose this? When you want something much more Prolog-like, using the same search algorithm as Prolog. That said, they both do logic programming. I haven’t benchmarked, but from comments in the README, I suspect core.logic will be more performant as it compiles down to Clojure function calls which are then compiled down to Java function calls. It’s sort of like choosing between Python and Java. They both do imperative programming with objects but they both have their own strengths and weaknesses.
- jdminhbg 2y agoThank you, very helpful.
- Blackthorn 2y agocore.logic has a lot of limitations you pretty quickly run into, and they languish on their bug tracker for years now because nobody actually works on it.
- 2y ago
- cpdean 2y agoI absolutely love the aesthetic of a repo having a giant README.md
- SOLAR_FIELDS 2y agoI 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
- AtlasBarfed 2y agoSo is prolog just a big SAT solver?
- drob518 2y agoNo, but they share logic as the foundation. A SAT solver merely solves a series of Boolean equations, typically in conjunctive normal form. Prolog has deduction capabilities that go far beyond that, where you can reason over a tree data structure, computing various parts of it according to a set of constraints. A SAT solver is not Turing complete. Prolog is. You could use Prolog to write a SAT solver (though it wouldn’t be very competitive with solvers written in C or other languages).
- perdomon 2y agoComing from Javascript and PHP, this seems completely foreign and alien and I have almost no idea what I'm looking at. Can't wait to try it.
- alex-robbins 2y agoIt strikes me as too bad that this API is so imperative. You can see a pattern over and over in the README where they have `do` blocks, in which they clear some global state (`initialize-prolog`), then add some assertions back into that global state (via side-effectful API calls), and finally run a query (which is implicitly a query on the state that's been built up). Why not represent the knowledge base as a normal Clojure data structure, rather than as the effect of a sequence of API calls? Then it can be passed in by the caller alongside the query, instead of being stored as mutable state. This isn't just a style thing, either; there are consequences. REPL-driven development loses a lot of its slickness when some expressions can only be eval'd in a special context. Also, what am I supposed to do if two different parts of my program want to use Clolog? If I'm using Clolog, and one of my dependencies is using it too, will we end up trashing each other's global state? (The case of external dependencies is just an example. Let's say I have an application that sets up the Clolog state and runs a query. Part of the setup involves calls to other parts of my application. At the time the code was written, those other parts didn't use Clolog, but now they do, and there's a bug, because those other parts are trashing the Clolog state that their caller had set up, before it runs its query.) Of course, you could get around this by adding something like a dynamically bound variable that points to the instance of state to use, but at that point you're jumping through hoops to support a subpar (stateful) paradigm that Clojure developers expect to be free of.
- Pet_Ant 2y agoSubmit a PR? If you have an idea how it would look better, submit it. It's nice that they got it to this point as is. Lets make it better.