Wrapping Up miniKanren

Logic programming is a strange thing. Where else can you run programs backward or create programs that achieve your goals without having any concrete steps? It takes some time getting used to, but for some kinds of problems, you’ll have a tough time writing a better or shorter program with any other tool.

Embedding a powerful logic system inside a practical programming language like Clojure provides an environment where logic can be used seamlessly alongside your regular code, making it easy to use the right tool for the job.

Strengths

The primary strength of miniKanren is the use of declarative programming to achieve almost magical ends. Goals can be reordered and programs run backward. This makes it easy to express problems such as constraint solving, scheduling, and path finding.

Core.logic adds to this mix the integration with a practical, everyday programming language, Clojure, along with the entire Java ecosystem. Your logic programs can make use of existing SQL databases and the myriad of other existing libraries.

To give you an idea of the leverage core.logic is giving you, imagine implementing the narrative generator in Java or Ruby. Would it still be as concise and easy to extend?

Weaknesses

Logic programming is mind-bending. When it goes wrong, it is hard to tell why as the search going on behind the scenes can derail in subtle ways. For example, while writing this chapter I spent many hours debugging an example that in the end I was unable to get fully working.

Although this is true of every new language you attempt to learn, logic programming makes it even more difficult since there are no familiar landmarks to help you out.

Final Thoughts

More than a library, miniKanren is a new language with a new programming paradigm. It’s also one of the most fun programming languages I’ve ever played with. Running programs backward will always put a smile on my face.

Problems that fit its domain are so easily and concisely expressed that it’s a wonder to me that every language doesn’t have an embedded logic system like miniKanren. Core.logic does a particularly fine job of integrating with Clojure and using the strengths of Clojure to make logic programming practical. It will be amazing to watch as core.logic and miniKanren keep getting better and are used in more places.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset