Logic/functional languageLogic/functional language which combines the clarity and expressiveness of declarative programming with advanced static analysis and error detection features. Its highly optimized execution algorithm delivers efficiency far in excess of existing logic systems, and close to conventional programming systems. Structures: Related languages
References: portable C code. Our benchmarks show that the code generated by our experimental implementation is significantly faster than the code generated by mature optimizing implementations of other logic programming languages. Extract: Introduction Introduction Logic programming languages are theoretically superior to imperative programming languages such as Pascal, C, C++ and Ada because they operate on a higher level. They are declarative, which means they allow the programmer to state what is to be done while leaving the details of how it is to be done to the language implementation. However, application programmers demand much more from a language than merely being declarative. Most applications are written by groups of programmers. Languages should therefore support cooperation between programmers; the most effective method to date is to provide a module system that separates interfaces from implementations. This way, changes in one part of the program do not propagate unnecessarily to other parts of the program. Application programmers want as much help as possible from the compiler in locating errors in their programs. This requires a programming language with redundant information; type declarations have proven useful in this role. This redundancy often turns out to be useful documentation; since the compiler's checks ensure that declarations are accurate, declarations are much more useful than comments. Another requirement on the programming language is that its implementation produce reasonably fast and space efficient programs. Customers do not like slow programs. Our objective is the creation of a logic programming language that meets the requirements of application programmers, i.e. one that has a good module system, detects a large fraction of program errors at compile time, and has an efficient implementation on many platforms. Current logic programming languages do not meet the requirements of application programmers. Only a few Prolog dialects support modules, and their module systems interact badly with the rest of the language. Many Prolog implementations perform no semantic checks at compile-time, and most of the ones that do confine themselves to simple tests (e.g. detecting variables that occur only once in a clause). The absence of declarations makes it difficult for compilers to gather the information required by the optimizations needed to achieve competitive performance. Prolog programmers therefore often resort to non-logical constructs, which then destroy the declarative semantics of the program. The lack of modules and compiler-checked declarations in most Prolog dialects tends not to be a problem for small programs, since a single programmer can understand all of the code at once and since such small programs can be debugged using Prolog's limited debugging facilities. However, as the size of the program increases and more people are added to the project team, the benefits of the declarative nature of logic programming are quickly outweighed by the effects of these limitations. Our new logic programming language, Mercury, represents a clean break with previous logic programming tradition. It is necessarily incompatible with existing logic programming languages such as Prolog, since unlike these languages, Mercury has no non-logical constructs that could destroy the declarative semantics that gives logic programs their power. At the same time, it is explicitly designed to support teams of programmers working on large programs. For example, it has a modern module system that separates interfaces from implementations. Mercury's polymorphic type system, modelled after ML's [6], is very expressive. The type system detects a large fraction of program errors. It is also the basis for a novel strong mode system that lets the compiler prevent errors such as floundering. The mode system is in turn the basis for a strong determinism analysis system, which catches even more errors. One of the most frustrating experiences of a Prolog programmer occurs when a large computation that was intended to succeed fails instead, since the bug could be anywhere in the computation; Mercury's determinism system can point out the bug at compile time. The support provided by these systems goes a long way towards ensuring that Mercury programmers spend less time tracking down errors via tedious manual debugging than programmers working in other languages, declarative or imperative. We are currently working on a Mercury compiler. We are writing the compiler in Mercury itself, using NU-Prolog for boot-strapping until the compiler is complete. After a year and about 1.6 person-years of effort, much of the compiler is already operational. The module system has proven that it can do its job of letting programmers cooperate without stepping on each others' toes. The compiler's type, mode and determinism checkers have together caught and hence prevented hundreds of errors in the compiler itself. The compiler uses the information provided by the type, mode, and determinism systems to generate better code. We have tested the performance of the code generated by the compiler on several standard logic programming benchmarks. We have found it to have much higher performance than all the logic programming implementations we have access to, including SICStus Prolog and Aquarius Prolog. The fastest of these systems achieve their speed by directly generating native code. Since significant effort is required to retarget them for different architectures, they are available on only a few platforms. Our Mercury compiler generates C code that can be compiled on almost all software and hardware platforms, including Unix systems, Macintoshes and PCs. in Joint International Conference and Symposium on Logic Programming. Bonn, Germany, September 1996 view details in Joint International Conference and Symposium on Logic Programming. Bonn, Germany, September 1996 view details Resources
|