Day 24:

Prolog is a fascinating language I am starting to discover. This interesting language is an example of logic programming. Lots of modern programming languages derive lots of their ideas and syntax from C (which was influenced in turn by AGOL). Logic programming throws a lot of these ideas out the window and focuses on routing itself on predicate/first-order logic, which is a type of formal logic. Since I've recently gotten interested in formal logic as a discipline, I thought better understanding Prolog would help show me how you could use formal logic. Although it's not hugely used in the industry, it's a really cool example of how different things can be in programming, and you really have to wrap your head around a whole new way of thinking. A core premise of Prolog is the idea of facts as a key component of programming. Prolog is based around the idea of creating queries of these facts. A fact may look something like this:

human(tom).

That's a fact. I've said that "tom" is a human. Now we can ask if "tom" is a human and use the fact in a Prlog interpreter. True values will print "Yes" and false values "No". So we ask if "tom" is a human by writing our fact, and Prolog we'll tell us if we're right or not. We'd do that as so:

human(tom).

Prolog would say: "Yes" in response to that. This is a very simple example, but you can already see that logic programming is fundamentally different than most programming. If this interests you, you can take a look at the book: "Adventures in Prolog" which I'm currently working my way through now. Until next time!

Do you have a reply you want to share? You can send me the URL here: