Re: Newbie, The secret with Prolog: How to to transform old "traditionally programming" thinking into Prolog style?

From: Robert Oschler (no_replies_at_fake_email_address.invalid)
Date: 02/14/04


Date: Sat, 14 Feb 2004 09:11:25 -0500


"Matthew Huntbach" <mmh@dcs.qmw.ac.uk> wrote in message
news:c08b5m$c1k$1@beta.qmul.ac.uk...
> Torkel Franzen <torkel@sm.luth.se> wrote:
> > Matthew Huntbach <mmh@dcs.qmw.ac.uk> writes:
>
> The convinced declarativist would probably argue "Ah, but what did they do
> before they came to you?". Did they do Haskell before any other
programming,
> or did they come to you with their brains already irretrievably damaged by
> having dabbled with Basic etc?
>
> Even if you said "No, they never programmed before", the argument might be
> "Aha, if only they'd been taught to program - with Haskell, or with
Prolog -
> when they were in primary school, they'd find it natural".
>
> Matthew Huntbach

>> irretrievably damaged

That's a bit extreme. In my case I had years of procedural programming
before using Prolog. I admit, it did take several long years of hard study
to finally "grok" Prolog, but it did come.

In procedural programs you have to write statements for every step in the
flow control of a problem.

The hardest thing for a procedural programmer to understand, is that in
Prolog, you describe the logical relations (I know, hence it's "declarative"
nature) that underly the problem you want to solve, and then just hand it
off to the Prolog inference engine. This is a very alien way of thinking
for a procedural programmer, but it can be learned.

I think recursion is hard for people in the same way that pointers in
programming are hard for people. Most people can handle the thinking
involved with a single indirection, but "this points to this points to...";
at some point the mind just loses focus trying to visualize the indirection
chain. Recursion has similar attributes if you are not thinking
declaratively, but instead are trying to visualize the entire program flow
and variable state changes while recursing; which is a natural way of
thinking about things in a procedural language.

Just my two cents.

-- 
Robert Oschler