[mercury-users] Mercury in academic teaching?

Ralph Becket rafe at csse.unimelb.edu.au
Mon Oct 9 10:09:09 AEST 2006


Jonathan Morgan, Saturday,  7 October 2006:
> On 06/10/06, J?rg Roman Rudnick <joerg.rudnick at t-online.de> wrote:
> >are there any experiences with teaching Mercury instead of Prolog at
> >academic level?
> >
> >The head of the chair I'm working at displays unexpected interest in
> >Mercury - now a completely new question appears in my head:
> >
> >Is Mercury an option as introduction to logic programming?
> >
> >Personally very convinced, I am unsure about possible problems in
> >teaching it as second (or third) language besides Java (and C#) to
> >students of AI (at a course of study like 'master of business computing').
> >
> >I would be very interested in your opinions...
> 
> 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.

You can make arguments either way.  For my money, the distinction is

- Prolog has full unification, but is not logical (cuts, improper
  handling of negated contexts, no occurs check, no distinction between
  pure and impure code, etc.)

- Mercury is a pure logic programming language, but does not support
  full unification (for that you need to use solver types, which are
  probably not for beginners).

In favour of Mercury as a pragmatic teaching choice is the lack of an
interpreter: having strict, static checking by the compiler means that
users are far less able to "debug" code by making random changes.  Also,
Mercury's mode system provides a useful handle on the operational
semantics of programs.

> The main one is very simple - Mercury was not
> designed for simplicity, but rather for performance and large-scale
> Software Engineering.

I don't think that many subtle issues have to be mastered by Mercury
beginners.  I think problems understanding determinism cause most
problems for beginners, but determinism is also the main source of bugs
in Prolog programs.  I think it is easy to write programs that do
something in Prolog; however, it is much harder to write programs that
do what you intended.

> 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.

Mercury's type system (as far as beginners are concerned) is
considerably simpler than that of C or Java.

IO issues are common to Mercury and Haskell.  You don't have to go into
depth about the io-state/di/uo issue, you can simply teach it as "here
are the rules you need to understand to do IO".

The Mercury module system is very simple, moreso than Java's private
rules or C's header file conventions.

In general, I'd say you could just give beginners template Mercury
programs with "/* your code goes here */" comments for them to fill in.
They'd get the hang of things pretty quickly.

> 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.

Hmm.  In my years of using and teaching Prolog, I think the interpreter
inclines people to solving problems by making random code changes rather
than using their brains.

-- Ralph
--------------------------------------------------------------------------
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