Mercury (programming language)

from Wikipedia, the free encyclopedia
Mercury
Basic data

Maintainer Zoltán Somogyi
developer Melbourne University
Publishing year April 8, 1995
Current  version 01/20
(20 January 2020)
operating system platform independent
category programming language
License Compiler: GPL , library: LGPL
www.mercurylang.org

Mercury is a strongly prologue ajar programming . It combines elements from functional and logical programming. The first version was developed by Fergus Henderson, Thomas Conway and Zoltan Somogyi and published on April 8, 1995.

Mercury is a "purer" and thus more declarative language than Prolog because, unlike Prolog, it has no "non-logical" properties such as the cut operator (a Prolog construct that prevents backtracking ) or imperative input and output . This makes programming sequential algorithms a little unwieldy, but makes it easier to optimize the programs. This means that code can be generated much faster than is possible with Prolog.

Mercury has some properties for better software technology , it is compiled instead of interpreted , as is otherwise customary in logical programming languages, and it implements an advanced, strict type and mode system. The authors claim that these properties, along with the abstract nature of logical programming, accelerate the creation of reliable programs. Mercury's module system enables it to be subdivided into self-contained units, which has been a problem of logical programming in the past. (Although some Prolog implementations also introduced a module system.) Input and output are implemented using uniqueness types .

Mercury has several backends such as "low-level C " (the original Mercury back-end), "high-level C", Microsoft's IL for .NET , Sun's JVM and assembler using the gcc backend, with the last three back-ends still have alpha or beta status. Mercury is being developed at the University of Melbourne under the direction of Zoltan Somogyi and is available for most Unix platforms, for Mac OS X and, with the help of Cygwin and MinGW, also for Microsoft Windows .

Example program in Mercury

Hello World :

 :- module hello.

 :- interface.

 :- import_module io.

 :- pred main(io.state, io.state).
 :- mode main(di, uo) is det.

 :- implementation.

 main(!IO) :-
 	io.write_string("Hello, World!\n", !IO).

(after Ralph Beckets)

Web links

Individual evidence

  1. Mercury tutorial (PDF; 239 kB)