18 ms·
I haven’t used Prolog, but I have a little experience with Erlang and a lot with Elixir. As I understand it, the early versions of Erlang were inspired by Prol
by MikeNotThePope 4mo ago
I haven’t used Prolog, but I have a little experience with Erlang and a lot with Elixir. As I understand it, the early versions of Erlang were inspired by Prolog.
For those with familiarity with both Prolog and Erlang, can you comment on the similarities and differences between? Is/was Erlang basically Prolog with OTP bolted on?
- Antibabelic 4mo agoErlang has very little in common with Prolog, which is a language in an entirely different paradigm (logic programming). Early versions of Erlang were implemented in Prolog, which is why Erlang's syntax looks a whole lot like Prolog's, but beyond that they're not very similar.
- jb1991 4mo agoThese two languages are completely different paradigms.
- xlii 4mo agoSuper simple example % Prolog next_light(green, yellow). next_light(yellow, red). next_light(red, green). % Erlang next_light(green) -> yellow; next_light(yellow) -> red; next_light(red) -> green. Notable differences: - `;` in Erlang indicates multi clause function - In Prolog next_light is database, in Erlang it's just a function Question: What's the light before green? % Erlang % Returns actual value prev_light_search() -> [State || State <- [green, yellow, red], next_light(State) == green]. % Prolog (?- means that it's in query mode) ?- next_light(Light, green). So syntax IS similar though the thing is that Prolog is more like binding and quering database and Erlang is executing function. In a nutshell Erlang is more like: "when I have X, then I can calculate Y" and Prolog like "If I want Y, what's the X".
- kunley 4mo agoWhat Joe Armstrong et al took from Prolog is mainly the syntax.
- tannhaeuser 4mo agoNot familiar with Erlang that much, but it's pretty clear Erlang was prototyped on Prolog because of its convenient facilities for DSLs using op/3 to define new tokens for its built-in bottom-up expression parser (using operator precedence parsing) and its Definite Clause Grammar recursive descent parser as trivial specialization of core SLD resolution (Prolog was created for NLP and planning apps in the first place after all). I guess what may also have contributed is that there are a number of concurrent logics implemented in Prolog for prototyping Erlang's scheduler such as Concurrent Transaction Logic ([1]). [1]: https://www.cs.toronto.edu/~bonner/ctr/Home.html https://www.cs.toronto.edu/~bonner/ctr/Home.html