Over a million developers have joined DZone.

Day 3 - Prolog

DZone's Guide to

Day 3 - Prolog

· Java Zone ·
Free Resource

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

Prolog is the 3rd language covered in Bruce Tate's Seven Languages in Seven Weeks, and is a declarative, rather than imperative, language. Prolog is not new, of course (1972), but I have to admit this is the first time I've taken a look at it.

Like Bruce, I used GNU Prolog (1.3.1). As he describes the language, the building blocks are facts and rules (which together form a knowledge base), and queries. He describes some simple queries, then moves on to substituting variables in queries. He finishes the first day of the Prolog segment with a discussion of Prolog unification, then an interview with Brian Tarbox, a dolphin researcher who used Prolog both to simulate dolphin behavior and to schedule the personnel needed for each dolphin experiment. According to Tarbox, Prolog was very well suited for solving both types of problems.

The first day looked at declaring facts and rules and making simple queries against them. Day 2 adds some more tools, including recursion, math functions, and lists and tuples (and operations on them). Day 2 is the day where my experiment in covering one language per day seems the least feasible; I'm not familiar with declarative (programming) languages and although I get the idea, a lot of it went over my head. Bruce is extremely profuse with examples, deconstructed ones at that. If I wanted to learn Prolog, I would start with this book first and spend a few more days on it.

For Day 3, Bruce goes through two detailed examples -- a solution for a small Sudoku puzzle, and the Eight Queens problem. He then finishes with a discussion of Prolog's strengths and weaknesses, including listing problem spaces for which Prolog is particularly well-suited. Those areas? Scheduling constrained resources, natural-language processing, games, semantic web representation and artificial intelligence. 

From http://wayne-adams.blogspot.com/2011/03/day-3-prolog.html

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}