26-07-2012, 12:25 PM
PROLOG
What is Prolog?
Prolog is a declarative programming language. This means that in prolog, you do not write out what the computer should do line by line, as in procedural languages such as C and Java . The general idea behind declarative languages is that you describe a situation.
Based on this code, the interpreter or compiler will tell you a solution. In the case of prolog, it will tell you whether a prolog sentence is true or not and, if it contains variables, what the values of the variables need to be.
This may sound like a godsend for programmers, but the truth is that prolog is seldom used purely in this way. Though the declarative idea is the backbone of prolog, it is possible to see prolog code as procedural.
A prolog programmer will generally do both depending on the part of the code he or she is reading or writing. When learning prolog however, experience in procedural programming is in no way useful. (it is often said that it is easier to learn prolog for someone who does not have any experience in procedural programming than for someone who does)
Prolog is considered a difficult language to master, especially when the student tries to rush things, mainly because of the different way of thinking the student has to adopt and amount of recursion in prolog programs. When used correctly, however, prolog can be a very powerful language.
Q-2 Difference between OOP and Procedural language
• POP follows the procedural programming paradigm while OOP is a multi-paradigm language(procedural as well as object oriented)
• POP follows a top down approach in problem solving while OOP follows a bottom up approach.
• In POP, adding of data and function is difficult and in OOP it is easy.
• In POP, there is no access specifier and in OOP there are public, private and protected specifier.
• In POP, operator cannot be overloaded and in OOP operator can be overloaded.
• In case of POP, importance is given to the steps or procedure of the program while OOP focuses on the data rather than the process.
•
In case of POP, the data is not secured while the data is secured(hidden) in OOP This difference is due to specific OOP features like Data Hiding which are not present in POP.
Benefits of PROLOG.
The Benefits are:-
• It understands human language.
• Fast compilation then any other language.
• It is pre-eminent language.
• Code can be tested most immediately after being written.
• It supports programming with RDBMS.
Describe features of prolog.
The features of the PROLOG are ;-
• The sentences are expressed in terms of the clauses and facts.
• The data types supported in prolog are atoms,numbers,compound terms and variables.
• There are certain rules in prolog which enable to derive new property from existing ones.
• It supports shares variables features .Goals in a conjunctive query can share variables.
• Queries are supported by prolog to retrieve information from databases.
Applications of Prolog.
• In automatic airline traffic control programming.
• In computer games programming like chess.
• In term indexing.
• In programming where human interaction are required like asking about any scenarios.
• In Tabling.
• In Robotics.