
The Prolog Story  - zephyrfalcon
http://kylecordes.com/2010/the-prolog-story
======
mark_l_watson
I used to use Prolog a lot on R&D projects at SAIC but since becoming a
consultant, few customers have wanted work done in Prolog (it has been about 5
years since anyone has paid me to do Prolog).

Prolog is awesome for _some_ types of problems like graph operations, ad-hoc
rule systems, planning, etc.

If you want to play/learn, I would recommend Swi-Prolog. Jan Wielemaker does a
great job writing and maintaining Swi-Prolog. The semantic web libraries and
other Swi-Prolog libraries are very good stuff!

~~~
tom_b
Thanks for weighing in - I am a somewhat frequent visitor to your blog and
websites. This type of discussion (eg, using uncommon or less well-known
languages to be more productive or reason about an approach to a problem
domain) comes up here on Hacker News frequently.

I have been searching for new work opportunities that would involve more
freedom in programming language choice (specifically allowing me, as the
developer, to explore tools like Prolog, Lisp, and Ruby as appropriate).
Sadly, this has been somewhat fruitless in my geographic region. There is a
(probably well-founded) desire on the part of companies to use what we can
refer to as "lowest common denominator" tools (Java, C#, Oracle, MS SQL
Server) with the occasional upstart using Ruby/Rails. When I say LCD tools, I
don't mean to denigrate those languages/platforms, merely point out that
companies seem more comfortable knowing that there is a large pool of
potential programmers available with those skills.

PG has weighed in on the side of starting your own company and using more
powerful languages as a competitive advantage (the whole blub/magic of Lisp
set of essays). It seems that few companies see programming language as
competitive advantage or (based on your comment) be interested in hiring
consultants such as yourself to implement higher level software that leverages
these uncommon languages.

I'm curious - have you had projects where you felt that Prolog or Lisp
represented a "better" choice than Java or Ruby but had customer requirements
that specified language choice upfront? Have you "pitched" Prolog or Lisp to
customers, maybe saying something like "ah, using Prolog here would require
only 20 hours of my dev/consultant time, but using Java will require an 80
hour solution"?

I'm quite interested in using Prolog, Scheme, or Lisp at the "day job" so
hearing any of your thoughts might help better prepare my own internal pitches
. . .

~~~
mark_l_watson
Hello Tom, first I should say that Ruby is my favorite language and
fortunately there is a lot of demand for Ruby development. I don't really
pitch customers on language since almost everyone I work for is very tech
saavy and know what they want they want to use.

If you want to work in a particular language such as Common Lisp I suggest
writing a useful open source project and that could lead to work in Lisp, and
at the least you will learn something and have fun.

------
dejv
I like this sentence: We cut the cost/time of this implementation by 90% or
more, not by coding more quickly, but by thinking more clearly.

I think that this is valid for most projects in any language.

~~~
sophacles
I've always been a fan of the "Don't just do something! Sit there." approach
to work. Not only do I sometimes find really clever ways around a problem, or
weird issues that wouldn't immediately be apparent, I also save a whole bunch
of potential RSI :)

Added benefit: When it is time to start coding, you can amaze your coworkers
by brain dumping a decently coded solution at typing speed.

~~~
rdtsc
That's one of the most understated advice. Quite often managers like to see
lots of code, or developers have screwed up incentives and get payed by the
lines of code. If a manager walks by, their heart gladdens when they see you
banging on the keboard like mad -- to them that equals to "work being done".
They fail to realize that sometimes that equals to "more un-necessary garbage
added to the existing pile of code" that will eventually make the product
unstable, brittle and hard to maintain.

Sitting there with a notepad and a pencil thinking about the problem is when I
find I actually solve the difficult problems not when I type furiously at a
keyboard.

~~~
dkersten
Too right.

One day myself and another guy were debugging a piece of code by staring at
it, figuring the logic out in our heads and pitching theories back and
forward. The boss walked past, saw we were sitting there "doing nothing" and
told us to do some work... ugh!

~~~
sophacles
I have no idea how this works, but it does: when sharing a screen with someone
_and_ doing work: if one of you is pointing at something code-looking, the
boss reverts to thinking you are working. This works even if you are
discussing non-work things... its not content they care about but form :/

------
Maro
Learning Prolog was one of the most exciting things about getting a C.S.
degree. It's vastly underrated, though admittedly not very useful in real-
life.

~~~
fogus
I once worked with a guy who was using Prolog to develop a system that devised
optimal cargo hold layouts for shipping barges. Seems fairly "real-life" to
me.

~~~
barrkel
Optimal packing problems are fun 1-hour programming contest fodder - so many
problems that you might solve in Prolog are trivially written imperatively or
functionally as combinatorial or permutational recursive searches with pruning
- but they are such a small kernel of a real-world application that I don't
think they justify the complexity of linking in another language, runtime,
etc.

Where you're dynamically building up facts and clauses, and you need more
general solving logic at run time, then I think Prolog is more warranted. But
that's a smaller niche, IMO.

~~~
scott_s
I think you're misusing the word "trivially" by putting it in front of
"combinatorial or permutational recursive searches with pruning."

~~~
gaius
Trivially in this context means the program can be written without discovering
a new algorithm first.

~~~
scott_s
Considering that it still requires a significant amount of code that the
Prolog solution would not require, and that code will have to be tested and
debugged, I don't consider it "trivial" in any way I use the word. If we were
talking theory, maybe, but we're talking implementation.

Consider that we know, and have known for some time, proper ways to manage
dynamic memory. We still consider doing it correctly in practice not trivial
and consider automatic garbage collection a productivity win.

~~~
arethuza
From what I can remember of being an academic researcher (it was a while ago)
the term "trivial" was indeed used to indicate something that wasn't of any
real research interest.

This does indeed annoy people who put a lot of work into building complex
systems that actually do useful stuff.

~~~
scott_s
I do systems research. We only use "trivial" if something is so easy as to be
an afterthought. If you're talking theory, then, fine, solved problems are
"trivial." But we're not talking theory.

------
jim_lawless
This story sort of reminds me of another that was reported here. See the link
referred to in <http://news.ycombinator.com/item?id=756873>

------
scscsc
Ok, so Prolog is nice. We know that already. But the story lacks any real
content... It's really just: we used Prolog, it seemed to be a lot faster to
code and the customer was happy.

------
tlack
Does anyone else have any war stories about using Prolog in their day jobs?
It's a tool I'm always on the look out to use to simplify some of my more
complex tasks, but so far I haven't had any luck in that regard.

~~~
porlw
I once had a huge pile of Oracle PL/SQL to take care of, which was written for
performance rather than ease of maintenance and used a lot of session level
global data.

PL/SQL doesn't give you nice stack traces when you have an error, I just knew
the entry point and the place where the error occurred.

Even knowing the data coming in to the entry point, use of the globals meant
that you often couldn't know for sure what route the code would take.

I wrote a primitive PL/SQL parser (in Perl) to turn the call tree into Prolog
rules, and then used Prolog to give me the possible routes between the entry
point and the error location, making debugging much easier.

~~~
tlack
Wow, that sounds like a serious undertaking. How much PL/SQL are we talking
about here? How long did writing the Perl -> Prolog solution take?

~~~
porlw
I think it was about 60Mb of source, around 1000 packages and stand-alone
procs.

Basically the perl pulled a list of scoped function names from the DDL, did a
text index on the executable code, and searched the index for references to
those functions, creating a list of [from.function, to.function] pairs that I
fed into prolog.

------
ollysb
It was the similarity to prolog that first got me excited about erlang, I
thought I'd found a language that used the same principles that could be used
in the real world. Then I discovered there was no backtracking...

------
Mark_B
So, in other words, the customer's system can now be described as being "a
client/server application written completely in [not Prolog] with SQL Server
behind it except for this ONE piece - THAT one is in Prolog!"

Next question - Who's going to maintain it?

I mean, props for using Prolog to tackle the complex problem and save gobs of
money/time, but doesn't an approach like this seem _really_ risky?

------
agbell
Are there things prolog can do that embedded solvers cannot? In .net, solver
foundation, <http://code.msdn.microsoft.com/solverfoundation> , is a great fit
for solving from a set of rules. And I believe most languages can embed some
sort of rules optimizing engine.

------
stralep
Is there some up-to-date implementation of micro-Prolog?

I find its syntax nice and lispish :)

[edit]s/it's/its/

------
travem
I've used Drools a fair bit in my current job but I've never learnt much about
prolog. Can any one summarise where prolog would work better or provide
additional features?

------
dws
Great takeaway quote: "Don't be the person who only has a hammer."

