
Learn Prolog Now - profquail
http://www.learnprolognow.org/lpnpage.php?pageid=online
======
allan_s
I would be really interesting in getting a list of common problem or category
of problem that people usually implement in "common" languages but that would
benefit highly from being written using Prolog.

I did learn prolog during my engineer degree but we never went further than
the "school" exercises of finding if Mary is a member of the family of Bob or
not.

I then later played, while still being a student (i.e still playing with
things for intellectual fun rather than actual real life/business problem
solving) a bit with Flora2
[http://flora.sourceforge.net/](http://flora.sourceforge.net/) that seams to
me like a hackier but stronger variant of Prolog (the object-like syntax and
the possibility to pass rule has parameter to other rule).

At the opposite I learned also about functional programming, and until last
year I was also wondering the same until it became clear to me with javascript
(for the 'no class', function as parameter) and Rust (for the immutable by
default part). Ohhhhh suddenly all these for loop to create an other list of
the same size, all these for loop to arrive to one result, all these for loop
to get a subset of the list, all these for loop to find one specific value,
ALL gones and replaced by primitives.

All of that to say I really hope I'm missing something with Prolog that can
elevate my thinking.

~~~
33a
A lot of UI programming patterns are much easier to express in a constraint
programming language. Things like data binding don't exist in logic
programming, since they are captured by constraints. It is also easier to do
common tasks like position elements in a way which reacts nicely due to
resizing a viewport, etc.

Today constraint solving is still confined to a lot of niche applications like
physics engines or CAD systems, but I keep hoping for the day that someone
will build a more integrated system which makes it easier for anyone to grab
constraints and plug them in where it makes sense.

~~~
Animats
Prolog isn't a numerical constraint solver.

I once had to write a menu system in Turbo Prolog. Not fun. Totally the wrong
tool for the job. Prolog isn't that useful when you have to cause an action,
as opposed to computing a result.

~~~
abathologist
Have you used any of the numerical constraint solving libraries available for
many Prolog implementations?[1] (It is also worth noting that Turbo Prolog is
a rather peculiar—and now rather old—take on Prolog. I believe it has been
superseded by Visual Prolog).

[1]: e.g., SWI Prolog's [http://www.swi-
prolog.org/pldoc/man?section=clpfd](http://www.swi-
prolog.org/pldoc/man?section=clpfd), or [http://www.swi-
prolog.org/pldoc/man?section=clpqr](http://www.swi-
prolog.org/pldoc/man?section=clpqr)

------
tokenrove
It's cool to see this, but I think what Prolog could really use is a "Real
World Prolog" style of treatment showing things outside the usual logic
puzzles and toy genealogy examples. Like, starting from the elegantly tiny
compiler near the end of The Art of Prolog and going further with practical
examples -- systems administration tasks with Marelle, maybe show Constraint
Handling Rules, et cetera.

------
profquail
One interesting application of Prolog I've read about is using the language to
implement build systems a la _make_ and _CMake_.

Most (all?) of the build systems out there today ( _make_ , _CMake_ , _rake_ ,
etc.) are declarative but they lack Prolog's inference capabilities. This
gives a specific advantage -- it allows you to _reduce fragility_ of your
build system by making it dead simple to tell when you've combined
incompatible configuration options (e.g., compiler flags) which you might
otherwise discover halfway through a long build.

For a quick overview, check out the paper _prom: A flexible, Prolog-based make
tool_ [1].

[1]: [http://www.cs.vu.nl/~kielmann/papers/THD-
SP-1991-04.pdf](http://www.cs.vu.nl/~kielmann/papers/THD-SP-1991-04.pdf)

~~~
Svenstaro
But then you would manually have to create a list of incompatible flags.
There's no way Prolog can know which gcc flags mess with your program.

~~~
profquail
Correct. It could be broken down into two parts though:

* One database containing facts about which GCC flags are incompatible with one another (i.e., cases where you can't specify both --foo and --bar). This would ideally be provided as part of the build system itself, since it's not going to change for every program built with the system.

* A small database (if one is even needed) you'd specify in your build scripts where you can enumerate specific flags or compiler features you know shouldn't be used with your program. This would augment the database provided by the build system for your specific compiler.

Note, I'm not suggesting that using Prolog to define a build system would make
it _impossible_ to specify bad or incompatible compiler flags. I am suggesting
that deriving the set of flags to use for a build based on known facts about
the compiler being used and your program makes it much less likely that a
change you make to a build script causes the build to break in subtle ways
once you've started compiling (or worse, at run-time). With Prolog, it'd be
easier to detect such issues up-front so you can fix them before you start
compiling or deploying.

------
jeffdavis
Every time I've started to learn prolog, I feel like it's too much about the
language and nothing about the environment.

I realize that prolog is a language, but it's much harder to learn things when
they are purely abstract. A good implementation and a good library go a long
way.

I don't have a problem with non-mainstream languages. I like erlang.

I tried learning haskell, too. I didn't get hung up on monads; I ran into a
wall when I found out there was no good way to use haskell as an embedded
language or call a haskell library from something else without pulling in a
big runtime (which interferes with non-trivial host applications). Correct me
if I'm wrong.

~~~
toblotron
We use Sicstus Prolog, which we connect to .Net by a provided set of
interface-classes

It also has a bi-directional interface to Java, but Sicstus is unfortunately
neither free nor cheap

------
profquail
IBM's Watson system is partially written in Prolog:

[http://asmarterplanet.com/blog/2011/02/the-watson-
research-t...](http://asmarterplanet.com/blog/2011/02/the-watson-research-
team-answers-your-questions.html)

(see the answers to questions #3 and #6)

------
robertszkutak
Are there any recommended implementations out there of using prolog with RDF?
I feel like prolog could offer some interesting trade-offs for working with
RDF over SPARQL and I'd be curious to give it a shot.

~~~
sgt101
I feel a disturbance in the Semantic Web - as if a million palms slapped into
faces all at once and €100m got spent on nonsense.

~~~
sgt101
To explain - many people spent many eons trying to reason with RDF, OWL and so
on, and it hasn't gone too well. The problem is that writing logical
statements is very hard, and writing knowledge bases is harder, and writing
distributed knowledge bases is hardest of all, and none of this and nothing
has sorted out the knowledge engineering bottleneck.

And encoding it in XML does not help.

~~~
robertszkutak
How hasn't it gone too well? Many, many well known companies outside of the
technology space including Fortune 100s and 500s as well as various government
agencies are successfully leveraging semantic web technologies for knowledge
management. There are many interesting public databases out there being widely
used for research that leverage semantic technologies as well. JSON
serializations of RDF exist too. See: [https://dvcs.w3.org/hg/rdf/raw-
file/default/rdf-json/index.h...](https://dvcs.w3.org/hg/rdf/raw-
file/default/rdf-json/index.html)

Public database examples: [http://flybase.org/](http://flybase.org/) ,
[http://dbpedia.org/](http://dbpedia.org/) , [http://disease-
ontology.org/](http://disease-ontology.org/)

~~~
sgt101
Ok, how about

[http://www.itjobswatch.co.uk/jobs/uk/semantic%20web.do](http://www.itjobswatch.co.uk/jobs/uk/semantic%20web.do)

Ranking 845 doesn't seem to me to cut it.

------
dmichulke
Are there any jobs where Prolog is required? Or maybe something like
functionaljobs.com, just declarative?

From my point of view (I worked a few years with the language while in
academia), there are no real job offers where Prolog makes a difference.

So maybe erlang people prefer a Prolog background but that's it (w.r.t. a job
market perspective)

~~~
profquail
I found a page from 1994(!) asking the same question:
[https://dtai.cs.kuleuven.be/projects/ALP/newsletter/archive_...](https://dtai.cs.kuleuven.be/projects/ALP/newsletter/archive_93_96/net/world/jobs.html)

Given that Prolog isn't super-widely used (compared to say, C++), there are
going to be a limited number of developers with Prolog expertise. That means
companies who use it in their tech stack are generally going to have to hire
developers who fit the other qualifications for the role then put them through
some internal Prolog training. The listings for such positions probably won't
have Prolog as a "required" skill but a "desired" skill.

One other point -- just because there aren't any/many jobs where Prolog is
required doesn't mean there aren't many cases where Prolog could be useful.
Prolog hasn't been widely taught for a couple of decades, so a significant
proportion of developers today won't recognize a problem that Prolog would be
a good solution for as a problem that Prolog would be a good solution for.

There's a Strange Loop 2014 talk on YouTube, "Production Prolog", that might
give ideas about jobs that use (or could use) Prolog:
[https://www.youtube.com/watch?v=G_eYTctGZw8](https://www.youtube.com/watch?v=G_eYTctGZw8)

------
bkeroack
Prolog is really interesting. There's also
[https://github.com/mcsoto/cosmos](https://github.com/mcsoto/cosmos) which
transpiles to Prolog, I believe. It looks like the latter isn't actively
worked on, unfortunately.

------
2188daysago
Windows NT used an embedded Prolog interpreter to configure its networking

[https://news.ycombinator.com/item?id=513962](https://news.ycombinator.com/item?id=513962)

------
guruparan18
OMG! This is like Christmas morning. Though I learnt BASIC programming
language first, Prolog was the first language that blew me off. Part of the
reason may be that I learnt Prolog late during my post graduation. It was such
a wonderful language with its constructs that gave me a sudden feeling like
having wings.

Good. It is such a powerful language. I ended up writing a console game as a
side project and was simply thrilled with ability of the program that can
"take" decisions and play the game along.

------
ragebol
Prolog is really great for some applications. I used it in robotics and
RoboCup@Home. The robot built a world model of its surroundings and labeled
entities with classes. When a cleanup tasks was given, the robot picked
something up, and based on the class, it reasoned where the entity should be
moved (e.g table, kitchen or trashbin).

This was in a mechanical engineering group, so it took some time for some
people to get used to such e different language.

------
jkbyc
A year ago I asked about real-world use cases for Prolog, there were a couple
of interesting ones: [https://www.linkedin.com/groups/Examples-current-
realworld-u...](https://www.linkedin.com/groups/Examples-current-realworld-
use-Prolog-166142.S.5849652140556984324)

People might not be aware that the JVM (Java Virtual Machine) specification
includes a class verifier written in Prolog, see
[http://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf](http://docs.oracle.com/javase/specs/jvms/se7/jvms7.pdf)

Clementine -- a data mining application purchased by SPSS

SPARK toolset -- a rigorously defined Ada subset used for developing software
correct by construction. This approach is used in areas like aviation,
transportation, medicine, energy, etc. where failure is not an option.

ECLIPSE-CLP -- an open source constraint logic programming library used to
solve various resource allocation problems. Think of it as a poor man's
Operation Research expert.

Experian, the credit rating company, bought out Colmerauer's Prologia company:
[http://www.experianplc.com/news/company-
news/2005/25-10-2005...](http://www.experianplc.com/news/company-
news/2005/25-10-2005.aspx)

ContractExpress/DealBuilder from Business Integrity Ltd [http://www.business-
integrity.com/](http://www.business-integrity.com/)

InFlow from OrgNet [http://www.orgnet.com/](http://www.orgnet.com/)

GridMind tool - a for modelling and simulation new technologies implementation
into energy grids (smart grids, smart metering etc.). They have to generate
detailed complex models satisfying lot of rules which to make models
realistic. Prolog together with CLP is excellent tool for that. Fast
development, small code, elegant solutions. www.mycroftmind.com

David Warren (Leading Professor at Stony Brook University): "We at XSB, Inc.
use Prolog and Java. We use Prolog for knowledge extraction and
standardization and for ontology representation. We have (to me, somewhat
surprisingly) found that our Prolog code is more stable and we spend less on
maintaining it than we do our Java code. It may be programmer skills, but I
think it is also due to the much more succinct expression of similar
functionality."

The Nokia N900 phone used prolog to do ui state management .... prolog in a
smartphone!

London-based startup Texrazor performs text analysis via API and the engine
behind it is coded in Prolog
[http://www.textrazor.com/technology](http://www.textrazor.com/technology)

Prolog does social and organizational network analysis for clients around the
world. [http://orgnet.com/inflow3.html](http://orgnet.com/inflow3.html)

Orgnet, LLC also uses LPA Prolog to do data analysis, especially for hidden
relationships and patterns in business data... for examples, see:
[http://thenetworkthinkers.com](http://thenetworkthinkers.com)

etc., see the discussion on LinkedIn

------
arianvanp
The first Erlang Compiler and VM were implemented in Prolog iirc.

Erlang's syntax was also influenced by prolog.

EDIT: apparently i recalled correctly:
[http://www.erlang.org/faq/academic.html](http://www.erlang.org/faq/academic.html)

------
Simiyu1
Am excited that prolog can be queried by JavaScript. Am doing a project on an
interactive chatbot-like pages in javascript. My LOCs was getting extremely
large. Any links on sample codes for querying prolog from JavaScript?

------
aspirin
Could Prolog be used in geometric constraint solving? Any examples?

------
rbc
It seems to me that Prolog (and Datalog) might have some strengths in querying
social graphs for social network applications. Has anyone seen it being used
in that way?

------
ericcholis
The examples could benefit from some syntax highlighting

------
ing33k
yes

------
radiodario
no.

