Prev Next Up Home Keys Figs Search New

Strong Typing

Appeared in Volume 9/1, February 1996

Keywords: typing.


ok@goanna.cs.rmit.edu.au
Richard A. O'Keefe
5th December 1995

freyes@i-2000.com writes:
I am currently using two Prologs; one is Turbo Prolog, the other is an OS2 interpreter. Turbo is strong typed, the OS2 interpreter is not.

I was told by the makers of the interpreters that the proposed standard makes strong typing optional. I am interested in whether other people think strong typing would make Prolog programs more efficient.

Turbo Prolog is a logic programming language. Turbo Prolog is not "Prolog", as that name is commonly understood. It is not necessary to be "Prolog" to be good!

The standard does not say that strong typing is optional. The standard defines a language with no compile-time type checking, in which programs that are not well-typed by most plausible definitions are still defined, meaningful, and useful.

On the other hand, the DEC-10 Prolog type checker (designed by Alan Mycroft and me, coded by me) which has been around since 1984 could be adapted to ISO Prolog without too much difficulty. Note that Turbo Prolog types are very much restricted compared with this!

It should be obvious that (a) the existence of strong types is no guarantee that you will get speed (Java is strongly typed, but most people are running interpreted J-code, not native code, and they are very happy with it); (b) that strong compile-time type checking has benefits quite other than speed; (c) that enforcing compile time type checks is going to rule out many legal Prolog programs.

Two logic programming languages with type systems based on the Mycroft/O'Keefe model (but far more to commend them than just that) are Goedel and Mercury. Both of them have freely available implementations. Mercury in particular gets very impressive speed. But it wouldn't get it just with types.

Prolog was wonderful. It is time to move on. I guess the next question is "can we have extensible constraint logic programming and strong polymorphic static type checking with type classes and high performance and parallelism?" I think the answer's going to be "yes", but it's not going to be trivial.

Prev Next Up Home Keys Figs Search New