encyclopegia.org

Mercury (programming language)

Mercury is a functional logic programming language made for real-world uses.[src] The first version was developed at the University of Melbourne, Computer Science department, by Fergus Henderson, Thomas Conway, and Zoltan Somogyi, under Somogyi's supervision, and released on April 8, 1995.[src] Mercury is a purely declarative logic programming language.[src] It is related to both Prolog and Haskell.[src] It features a strong, static, polymorphic type system, and a strong mode and determinism system.[src] The official implementation, the Melbourne Mercury Compiler, is available for most Unix and Unix-like platforms, including Linux, macOS, and for Windows.[src]

Mercury is a functional logic programming language made for real-world uses.[src] The first version was developed at the University of Melbourne, Computer Science department, by Fergus Henderson, Thomas Conway, and Zoltan Somogyi, under Somogyi's supervision, and released on April 8, 1995.[src] Mercury is a purely declarative logic programming language.[src] It is related to both Prolog and Haskell.[src] It features a strong, static, polymorphic type system, and a strong mode and determinism system.[src] The official implementation, the Melbourne Mercury Compiler, is available for most Unix and Unix-like platforms, including Linux, macOS, and for Windows.[src] ==Overview== Mercury is based on the logic programming language Prolog.[src] It has the same syntax and the same basic concepts such as the selective linear definite clause resolution (SLD) algorithm.[src] It can be viewed as a pure subset of Prolog with strong types and modes.[src] As such, it is often compared to its predecessor in features and run-time efficiency.[src] The language is designed using software engineering principles.[src] Unlike the original implementations of Prolog, it has a separate compilation phase, rather than being directly interpreted.[src] This allows a much wider range of errors to be detected before running a program.[src] It features a strict static type and mode system and a module system.[src] By using information obtained at compile time (such as type and mode), programs written in Mercury typically perform significantly faster than equivalent programs written in Prolog.[src] Its authors claim that Mercury is the fastest logic language in the world, by a wide margin.[src] Mercury is a purely declarative language, unlike Prolog, since it lacks extra-logical Prolog statements such as ![src] (cut) and imperative input/output (I/O).[src] This enables advanced static program analysis and program optimization, including compile-time garbage collection, but it can make certain programming constructs (such as a switch over a number of options, with a default ) harder to express.[src] While Mercury does allow impure functionality, it serves mainly as a way to call foreign language code.[src] All impure code must be explicitly marked.[src] Operations which would typically be impure (such as input/output) are expressed using pure constructs in Mercury using linear types, by threading a dummy world value through all relevant code.[src] Notable programs written in Mercury include the Mercury compiler and the Prince XML formatter.[src] The Software company ODASE has also been using Mercury to develop its Ontology-Centric software development platform, ODASE.[src] ==Back-ends== Mercury has several back-ends, which enable compiling Mercury code into several languages, including: ===Production level=== Low-level C for GNU Compiler Collection (GCC), the original Mercury back-end High-level C Java C# ===Past=== Assembly language via the GCC back-end Aditi, a deductive database system also developed at the University of Melbourne.[src] Mercury-0.12.2 is the last version to support Aditi.[src] Common Intermediate Language (CIL) for the .NET Framework Erlang Mercury also features a foreign language interface, allowing code in other languages (depending on the chosen back-end) to be linked with Mercury code.[src] The following foreign languages are possible: Other languages can then be interfaced to by calling them from these languages.[src] However, this means that foreign language code may need to be written several times for the different backends, otherwise portability between backends will be lost.[src] The most commonly used back-end is the original low-level C back-end.[src] :- module hello.[src] :- interface.[src] :- import_module io.[src] :- pred main(io::di, io::uo) is det.[src] :- implementation.[src] main(!IO) :- io.write_string("Hello, World!\n", !IO).[src] Calculating the 10th Fibonacci number (in the most obvious way): :- module fib.[src] :- interface.[src] :- import_module io.[src] :- pred main(io::di, io::uo) is det.[src] :- implementation.[src] :- import_module int.[src] :- func fib(int) = int.[src] fib(N) = (if N = !IO is a "state variable", which is syntactic sugar for a pair of variables which are assigned concrete names at compilation; for example, the above is desugared to something like: main(IO0, IO) :- io.write_string("fib(10) = ", IO0, IO1), io.write_int(fib(10), IO1, IO2), io.nl(IO2, IO).[src] ==Release schedule== The stable release naming scheme was 0.1 up to 0.13 for the first thirteen stable releases.[src] In February 2010 the Mercury project decided to name each stable release by using the year and month of the release.[src] For example 10.04 is for a release made in April 2010.[src] There is often also a periodic snapshot of the development system release of the day (ROTD) ==IDE and editor support== Developers provide support for Vim Flycheck library for Emacs A plugin is available for the Eclipse IDE A plugin is available for the NetBeans IDE ==See also== Curry, another functional logic language Alice, a dialect language of Standard ML Logtalk, language, an object-oriented extension of Prolog which compiles down to Prolog Oz/Mozart, a multiparadigm language Visual Prolog, language, a strongly typed object-oriented extension of Prolog, with a new syntax λProlog, language, a higher order logic programming language also featuring static types and modes ==References== ==External links==[src]

54 sentences · 54 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Mercury (programming language)." encyclopegia.org, 2026, https://encyclopegia.org/wiki/mercury-programming-language. Accessed 02 December 2026.

Chicago

"Mercury (programming language)." encyclopegia.org. Accessed December 2, 2026. https://encyclopegia.org/wiki/mercury-programming-language.

APA

encyclopegia.org. (2026). Mercury (programming language). Retrieved December 2, 2026, from https://encyclopegia.org/wiki/mercury-programming-language

Accessed December 2, 2026 · CC BY-SA 4.0 · citation page · JSON

Claims

PredicateValueSource
release date1995-04-08Wikipedia

Related articles

official language

stub · references available

pan-Slavic language

stub · references available

Hawaiʻi Sign Language

stub · references available

Taiwanese Sign Language

stub · references available

Category:Programming languages

stub · references available

International Mother Language Day

stub · references available

polysynthetic language

stub · references available

Category:Films by country or language

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1378652934 · 0.5 · snapshot enwiki-001378652934

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools
  • Careers — open roles: frontier engineers and sales partners
  • Index — every corpus, paper and record
  • Estate guide — what a public data estate is
  • Founder — Lois-Kleinner Alpasan
  • Records — DOIs and external deposits
  • Documents — one-pagers, PDFs and QR codes
  • Brand kit — logos and share images
  • Papers — plain-language briefs with citations
  • Browser — search engine, PWA and bookmarklet
  • Anticloud — the operator and its projects

As seen in Business Insider · 336 outlets · evidence DOIs · plain-language papers

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.