The simplicity of Prolog

submited by
Style Pass
2025-01-26 03:30:05

Nowadays the most popular programming languages are Python, Javascript, Java, C++, C#, Kotlin and Ruby, and the average programmer is probably familiar with one or more of these languages. It's relatively easy to switch from one to another (barring any framework specific knowledge that may be needed), since they are all imperative (and for the most part object-oriented) languages, and are thus alike in their design.

Imperative languages focus on how a problem is solved, using sequences of instructions to manipulate state. There are multiple reasons for their popularity. Firstly, they are considered easy to learn, since it's easy to visualize physical cells of memory containing values and getting updates through a set of instructions. Secondly, the computational model maps nicely to hardware, and so instructions from imperative languages can often easily be translated to machine code that can be optimized quite a lot. For the same reason, imperative languages were developed way before other programming paradigms, and so have historically speaking had a larger backing.

In contrast, declarative languages focus on describing what the problem or desired outcome is. An example of a declarative language you are probably familiar with is SQL. When specifying a SELECT-statement, you usually don't really care how the records are retrieved, only that they adhere to specified conditions. While SQL isn't normally used as a general purpose programming language I think it's quite illustrative for those otherwise unfamiliar with declarative languages (though apparently it is Turing complete). There are entire paradigms of actual general purpose programming languages that are declarative. The main two of these are functional programming and logic programming.

Leave a Comment