Is the first version of Erlang written in Prolog?

I had been told the first version of Erlang is written in Prolog for a long time. But just now I had read a interesting post in stackoverflow, which says:

The first version of Erlang was not written in Prolog, it was written in one of the committed-choice logic programming languages. These languages dropped Prolog’s backtracking hence the name “committed choice” meaning once a choice was made it was not possible to backtrack and try another.

but it is important to understand it picked this up through the committed choice logic programming languages which picked it up from Prolog, not directly from Prolog.

Is this true? I’m interested in this piece of history. :grinning:

2 Likes

AFAIK, it was prolog. This is covered briefly in this blog post by @bjorng and covered in detail by Joe here.

2 Likes

The concurrent logic programming language in question might have been Strand88.

1 Like

Thank you for you clues. I found some documents for Strand. The code of Strand looks the same as Prolog, but the document has stated:

The main differences between Strand and Prolog can be summarized as follows:

  • Strand has no backtracking: once a rule head matches and the guards succeed, all remaining solutions are abandoned.

  • All goals of a rule are executed in parallel, in an arbitrary order.

  • Strand has no general unification - rule heads and guards only match, variables are assigned exclusively by “:=/2”, “assign/3”, “is/2” and primitives that assign results to argument variables.

  • Referencing an unbound variable suspends the current process until the variable has been bound.

Is Strand considered as a dialect of Prolog?
Was Erlang written in a Prolog who had no backtracking support?
:thinking:

Backtracking is not mentioned in the post nor the pdf. :thinking:

Is Prolog just like Lisp, who is a collection of different languages ?

Strand (and I am so pleased that Ian Foster’s book is available at that web site) is unquestionably a member of the family of concurrent logic programming languages. Whether you want to consider it a dialect of Prolog is a question of where you want to draw the line: it’s syntactically and historically related to Prolog, but semantically very different.

There are, as it happens, several Prolog systems which support some form of concurrency/multithreading. SWI Prolog is a good place to start. There are three “concurrency for logic programming” paradiams.

(1) committed choice concurrent logic programming. This is the CP, FCP, GHC, FGHC, Parlog, Flat Parlog, Strand family. The languages in this family basically abandon the “logic” part of logic programming and go for massive concurrency.

(2) parallel logic programming. This includes languages like Andorra (because it supports AND-parallelism and OR-parallelism), languages which try to exploit concurrency in the service of logic programming.

(3) whack-a-bit-of-threading-on-the-side, she’ll-be-right. This includes languages where you have multiple threads communicating by message passing or mutable shared state and each thread is a sequential Prolog. Tim Lindholm built a system like this at Quintus but it was shelved. He went on to work on Java. This approach is taken in SWI Prolog and YAP and by a couple of Prologs implemented in Java.

To put it bluntly, (1) is simple, clean, and dead; (2) is difficult to get right but amazing when you do, it’s real parallel Prolog; (3) makes you popular with the punters (like mutable data structures…) so guess which approach is still around?

Erlang’s great advantage was that it DIDN’T add concurrency to a functional language (as Concurrent ML did), but made a programming language out of communicating sequential processes where the sequential processes happened to be implemented using functional programming, and that actually made life EASIER for programmers.

If I were prototyping Erlang, I’d do it in Prolog, not Strand.

5 Likes

Wonderful view! Thank you for your reply. :smiley:

Oh I read the book you listed (history-of-erlang by Joe), and here is the code inside the document:

reduce([]).
reduce([{H}|T]) :-
        call(H),!,
        reduce(T).
reduce([Lhs|More]) :-
        eqn(Lhs, Rhs),
        append(Rhs,More,More1),!,
        reduce(More1).

I guess the cut (!) has shown that it’s true Prolog (with backtracking).
thank you for your documents. :smiley:

1 Like

A short comment here. Erlang was developed using Prolog so the first versions were in Prolog. Originally then, it was more of a logic language but we decided, amongst many other things, that we didn’t want logical variables or back-tracking in the language so it became functional. Having the language implemented in Prolog made it easy to work with when the language evolved and became Erlang. When our original group wanted/required a much faster implementation, about 70x times faster, we moved away from interpreting it in Prolog and developed the first VM, the JAM, and moved everything from Prolog to Erlang.

Strand is a nice concurrent logic language and we did a serious experiment of using it to implement Erlang. We found that it was too logical and in some ways too concurrent/parallel so it was not a good base for Erlang. E.g. in Strand everything is done in parallel so we had to put effort into making the functional part sequential. You need to get it just the right amount of concurrency to be what you want.

In Strand with a clause like:

foo(X, Y) :- is_right(X), !, a(Y), b(Y), c(Y), d(Y), exit(die).

then a(), b(), c(), d() and exit() are all run into parallel so it will die way to fast.

Another concurrent logic language was Parlog from Imperial College Londong which IIRC you could explicitly serialise the clause body. I did an implementation of Parlog to both experiment with the language and to experiment with implementing a VM. It was fun and it worked and did exactly what it was supposed to do. :smile: :wink:

7 Likes

So according to Robert Virding’s answer, I was wrong and Strand do have the ! sign. (Which may have different meaning from Prolog’s cut sign. Maybe it means spliting the sequential part and the parallel part ?)

Anyway we know that Erlang was written in true Prolog now. (And I’m going to paste the link of this page under that stackoverflow answer to avoid further misunderstanding about the history of Erlang)

1 Like

Thank you very much ! Many things I want to know, even those ones I haven’t asked yet, are answered by your reply. :grinning:

1 Like

Adding comments in Stackoverflow need 50 reputations, which I don’t have yet :sweat_smile:

Can someone else who have been using Stackoverflow long enough attach Robert’s answer to This post ?

This can help a lot of people who want to know how Erlang comes and how decisions were made.

1 Like

I may be wrong about the ‘!’ sign. Whatever it is not a Prolog cut but a separation between the guard which Strand has and the body.

2 Likes

Sorry I didn’t read the whole document you pasted :sweat_smile:

Joe’s document has already talked about strand:


We started looking at languages like Parlog, KL/1 and Strand for possible in spiration.

Eventually, in 1988, we decided to experiment with cross compilation of Erlang to Strand.

Wasn’t CSP somewhat an inspiration to ‘!’ and ‘?’ (early Erlang used ‘?’ instead of receive).
(See also: Communicating sequential processes - Wikipedia )