[mercury-users] Mercury in academic teaching?

Jonathan Morgan jonmmorgan at gmail.com
Sun Oct 8 00:01:20 AEST 2006


On 07/10/06, Nicholas Nethercote <njn at csse.unimelb.edu.au> wrote:
> On Sat, 7 Oct 2006, Jonathan Morgan wrote:
>
> >> Is Mercury an option as introduction to logic programming?
> >
> > As a student who is just studying Prolog, I do not believe that
> > Mercury is likely to be a good introductory logic programming language
> > for several reasons.  The main one is very simple - Mercury was not
> > designed for simplicity, but rather for performance and large-scale
> > Software Engineering.  In my opinion, this makes it a great language
> > for using to write real programs, but not for education, as even small
> > programs require understanding of Mercury's module system, type and
> > mode system (unless you use inference), and the I/O state.  On the
> > contrary, most Prologs do not require types, and have interpreters,
> > allowing them to be used in an exploratory manner quickly and easily -
> > which I feel is much better for education as an introduction to logic
> > programming.  Prolog is much simpler (and probably more elegant) for
> > writing small programs in, and for playing round with to discover how
> > things like non-determinism work.
>
> I disagree.  I studied Prolog first, but didn't properly understand it until
> I learnt Mercury and learnt explicitly about modes and determinism;  it was
> only then I understood what Prolog was doing.

Whereas I had the opposite experience - I read Ralph's tutorial, and
played with Mercury (coming from a Haskell background), but I didn't
really understand how Mercury worked (or even why various issues were
cared about) until doing a couple of weeks of Prolog, just playing
with the SWI interpreter and experimenting.  If I wished to have
multiple solutions, I could get them one at a time from the
interpreter, examine them, and figure out what was happening.

On the other hand, knowing Mercury makes me annoyed at all the various
"solutions" proposed to Prolog problems, which Mercury can handle
automatically.

> I don't think Mercury's module system is difficult at all (particularly if
> you're writing single-module programs), and the I/O isn't that difficult --
> it's much simpler than Haskell's and Haskell is routinely taught to computer
> science novices.

I was not arguing that it was more difficult, just that it was another
thing that had to be done before you could even get your first
programs working.  I'm also not convinced that Haskell's model of I/O
is all that difficult to use (as opposed to reasoning about it).  If
you use the do syntax, all you need to know is that your instructions
will be carried out in the order specified, that some kind of action
occurs, and that if you wish to get input you need to use <- rather
than =.  Mercury takes far too long to get to the stage where you can
just play with the language and see what happens if you change this,
that or the other.

I have found (for both Prolog and Haskell) that having an interpreter
is a great aid in learning a language initially.  The ability to alter
your queries and get a result without having to worry about providing
a main, and without having to re-compile for every tiny little change,
helps me in figuring out what is happening.  The ability to put
together an exploratory prototype, without having to work out exactly
what the type system expects from you, is very useful (though Hugs was
strongly typed as well as interpreted).  On the other hand, I would
not wish to write serious programs in Prolog - I use the type system
of Mercury heavily, and am convinced that a program does not have to
grow very large before the disadvantages of Mercury for exploratory
programming become irrelevant, as the disadvantages of exploratory
programming come to the front.  I like many of Mercury's features,
designed for software construction in the large, but I do not think
that they are appropriate for introductory logic programming.

Jon
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list