Perusing Prolog (Part 1)

Reading my way through Seven Languages in Seven Weeks this past fall, Prolog caught my attention. The language worked so differently than any I’d used. It offered to solve problems challenging to code in the languages I was familiar with. Intrigued, I started setting aside an hour each workday to study Prolog. Learn Prolog Now! served as my primary tutorial. In interview-style, here are my thoughts after two months of exploring Prolog.

What attracted you to the language?

Prolog’s ability to solve logic problems without requiring me to figure out the execution steps involved piqued my interest. In the languages I’m used to (C#, PHP, Ruby, etc.), solving a logic-like problem requires me to spell out the step-by-step process the computer needs to take to apply the logic rules I define to come up with the valid set of answers—a complex, time-consuming and tedious task. With Prolog, I define only the logic rules, leaving Prolog to figure out the necessary steps to use those rules to compute the answer. Studying Prolog seemed like a good way to pick up a tool that could make certain tasks much easier than with my existing tool belt.

Learning new paradigms by studying a language that works extremely different from what I’m used to also attracted me. Even if I never do serious programming in Prolog, I thought the exposure to new ways of doing things would make me a better programmer overall.

Visualizing the various states that complex recursive code can assume is an area where I wanted to improve. Prolog’s style of coding and underlying way of functioning offered to help me toward this goal. Coding in Prolog often involves assembling values as they are passed up and down chains of recursive operations. Prolog operates by iteratively testing possible permutations against sets rules—rules that can involve many levels of recursion. Writing and working with (e.g. debugging) Prolog looked like it would force me to do a lot of complex visualizing, helping me towards this goal.

Continued in Part 2.

Leave a Reply

Your email address will not be published. Required fields are marked *