javalogic-programming

Are there elements of 'logic programming' in Java?


In recent years many elements of 'functional programming' have entered Java, in particular with Java 8. I have in mind lambda-expressions, functional interfaces, Java Generics, the Stream-interface, the Optional-class and similar.

My question is, are there likewise any new classes/interfaces/syntaxes that have been added to Java and stem from the paradigm of 'logic programming'? Or are there maybe plans to do so?

(see e.g. here for a comparison of the two approaches)


Solution

  • A logic programming language (such as Prolog) allows programs to be written as statements of truth and relations between them, so that an implementation of the language is essentially an algorithm which searches for solutions which satisfy all of a program's declarative statements.

    So for Java to support logic programming "out of the box", the standard library would have to contain such a search algorithm. To my knowledge, it does not. However, there are third-party libraries which do; a Google search for 'Java logic programming library' yields several (constraint programming libraries likewise.)

    These libraries will generally represent statements and relations as Java objects, and include an implementation of an algorithm (or possibly several algorithms to choose from) in order to search for solutions. Given the availability, complexity and variety of these libraries, it seems unlikely that something equivalent will be added to the Java standard library.