• Re: The Programming Language Wars have just begun

    From Mostowski Collapse@21:1/5 to Mostowski Collapse on Thu Apr 14 02:10:31 2022
    Unexpectedly, we could bring change_arg/3 from
    Dogelog Player to formerly Jekejeke Prolog.

    We have found change_arg/3 quite useful for the
    realization of built-ins such as findall/3, etc.. in the
    Dogelog Player. Bringing it to formerly Jekejeke Prolog
    opens up new roads of compatibility and portability
    between the two Prolog systems. We could already
    explore the compliance test suite.

    See also:

    change_arg/2 for a two Pointer Prolog System https://twitter.com/dogelogch/status/1514530478371622914

    change_arg/2 for a two Pointer Prolog System https://www.facebook.com/groups/dogelog

    Mostowski Collapse schrieb am Donnerstag, 8. Juli 2021 um 17:45:26 UTC+2:
    In case you are interested in imperfections
    of the ISO core standard. Maybe this can be
    read off from Dogelog, imperfections

    that even affect a lean language. You might
    read off imperfections from which predicates
    got implemented and are not in the ISO

    core standard. Since I have only implemented
    the absolute minimum right now, this might
    be an indicative what was overlooked

    in the ISO core standard. But there are only
    like 3-5 predicates which are not from the ISO
    core standard, but found in Dogelog:
    - consult/1 (from everywhere)
    - listing/1 (from everywhere)
    - '$MARK'/1 and friends (from BIM ProLog, Bruynooghe)
    - change_arg/3 (from BinProlog, Tarau)
    - What else?

    '$MARK'/1 and friends allow a more reflective
    implementation of the Prolog system. One can
    write an ISO core standard conforming

    call/1 in Prolog itself. change_arg/3 is
    used to inplement findall/3. But '$MARK'/1 and
    change_arg/3 are highly implementation specific,

    so that the ISO core standard doesn't have
    such things is somehow justified.

    Mostowski Collapse schrieb:
    Dogelog is lean, currently it doesn't have (@<)/2,
    sort/2, thread_create/2, etc..

    For more information:

    "The Dogelog Runtime is a small and fast ISO core
    standard Prolog system that runs in a browser or on
    node.js. The Dogelog Runtime supports old browsers
    with common JavaScript and new browsers with
    module JavaScript."
    https://github.com/jburse/dogelog-moon

    Julio Di Egidio schrieb:
    IMO, Prolog is an amazing idea with amazing potential,
    but should be refocused and rewritten from scratch: as a low-level "logical" language with the leanest possible spec
    and VM, and the smallest possible runtime, so that it
    easily runs everywhere: expert systems and stuff like
    that... Prolog 2.0, maybe.


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mostowski Collapse@21:1/5 to Mostowski Collapse on Thu Apr 14 02:16:00 2022
    We had to change the internal reference counting (*)
    API of Jekejeke Prolog a little bit. But regression
    testing showed so far no performanc epenality, its

    rather that we gained some little performance of
    ca. 4%. Need to do more regression testing. Did
    not yet test the attributed variables which have also

    reference counting.

    (*)
    In practice this reference counting and smart
    pointering is a horrible bottle neck, which is also
    felt in the poor performance of CPython.

    The outlook for JDK 8 and JDK 16 is different.
    We only saw ca. 4% for JDK 8, for JDK 16 its not
    that high. It could be also an other effect..

    Mostowski Collapse schrieb am Donnerstag, 14. April 2022 um 11:10:32 UTC+2:
    Unexpectedly, we could bring change_arg/3 from
    Dogelog Player to formerly Jekejeke Prolog.

    We have found change_arg/3 quite useful for the
    realization of built-ins such as findall/3, etc.. in the
    Dogelog Player. Bringing it to formerly Jekejeke Prolog
    opens up new roads of compatibility and portability
    between the two Prolog systems. We could already
    explore the compliance test suite.

    See also:

    change_arg/2 for a two Pointer Prolog System https://twitter.com/dogelogch/status/1514530478371622914

    change_arg/2 for a two Pointer Prolog System https://www.facebook.com/groups/dogelog
    Mostowski Collapse schrieb am Donnerstag, 8. Juli 2021 um 17:45:26 UTC+2:
    In case you are interested in imperfections
    of the ISO core standard. Maybe this can be
    read off from Dogelog, imperfections

    that even affect a lean language. You might
    read off imperfections from which predicates
    got implemented and are not in the ISO

    core standard. Since I have only implemented
    the absolute minimum right now, this might
    be an indicative what was overlooked

    in the ISO core standard. But there are only
    like 3-5 predicates which are not from the ISO
    core standard, but found in Dogelog:
    - consult/1 (from everywhere)
    - listing/1 (from everywhere)
    - '$MARK'/1 and friends (from BIM ProLog, Bruynooghe)
    - change_arg/3 (from BinProlog, Tarau)
    - What else?

    '$MARK'/1 and friends allow a more reflective
    implementation of the Prolog system. One can
    write an ISO core standard conforming

    call/1 in Prolog itself. change_arg/3 is
    used to inplement findall/3. But '$MARK'/1 and
    change_arg/3 are highly implementation specific,

    so that the ISO core standard doesn't have
    such things is somehow justified.

    Mostowski Collapse schrieb:
    Dogelog is lean, currently it doesn't have (@<)/2,
    sort/2, thread_create/2, etc..

    For more information:

    "The Dogelog Runtime is a small and fast ISO core
    standard Prolog system that runs in a browser or on
    node.js. The Dogelog Runtime supports old browsers
    with common JavaScript and new browsers with
    module JavaScript."
    https://github.com/jburse/dogelog-moon

    Julio Di Egidio schrieb:
    IMO, Prolog is an amazing idea with amazing potential,
    but should be refocused and rewritten from scratch: as a low-level "logical" language with the leanest possible spec
    and VM, and the smallest possible runtime, so that it
    easily runs everywhere: expert systems and stuff like
    that... Prolog 2.0, maybe.


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mostowski Collapse@21:1/5 to All on Wed Apr 20 14:30:49 2022
    About change_arg/3 and the call_nth/2 use case. Its also available in

    SICStus Prolog, by another predicate name I guess!!! Of course it needs intimate knowledge how compounds are allocated, deallocated or otherwise manipulated by the Prolog system. The use case of call_nth/2 is

    quite tame, since we do only update with an atomic, in particular
    with an integer, and not with a compound value of some sort,
    ground or not ground. But you gain quite some speed:

    You get near metal speed!!!

    count the number of calls of a clause https://stackoverflow.com/a/11400256/17524790

    In formerly Jekejeke Prolog the trick with the extra variable
    doesn't work, i.e. State=count(0,_), but functor(State, count, 1)
    works, and in Dogelog Player, current version State=count(0)

    can be used. I don't know what would work in Scryer Prolog.
    Also there are rumors that there are Coq and Isabelle/HOL
    libraries that allow reasoning about the construct, since it mimics

    aspects of RAM machines, which do have formalizations.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mostowski Collapse@21:1/5 to Mostowski Collapse on Thu Apr 21 03:26:54 2022
    If you don't think about introducing change_arg/3 in your Prolog system
    head start first, and start implementing call_nth/2 and all other stuff instead first, you are doing something wrong.

    Also that change_arg/3 isn't widely available is not correct, since
    recently I have it in formerly Jekejeke Prolog. So the list is bigger:

    - SWI-Prolog (corresponds to nb_linkarg/3, right?)
    - YAP (corresponds to nb_linkarg/3, right?)
    - GNU Prolog (possibly setarg/4 with 4-th argument false)
    - SICStus Prolog (didn't check yet which one is change_arg/3 exactly)
    - ECLiPSe Prolog (didn't check yet which one is change_arg/3 exactly)
    - Formerly Jekejeke Prolog (by its name)
    - Dogelog Player (by its name)
    - BinProlog from Paul Tarau (by its name)
    - ... What else?

    Mostowski Collapse schrieb am Mittwoch, 20. April 2022 um 23:30:50 UTC+2:
    About change_arg/3 and the call_nth/2 use case. Its also available in

    SICStus Prolog, by another predicate name I guess!!! Of course it needs intimate knowledge how compounds are allocated, deallocated or otherwise manipulated by the Prolog system. The use case of call_nth/2 is

    quite tame, since we do only update with an atomic, in particular
    with an integer, and not with a compound value of some sort,
    ground or not ground. But you gain quite some speed:

    You get near metal speed!!!

    count the number of calls of a clause https://stackoverflow.com/a/11400256/17524790

    In formerly Jekejeke Prolog the trick with the extra variable
    doesn't work, i.e. State=count(0,_), but functor(State, count, 1)
    works, and in Dogelog Player, current version State=count(0)

    can be used. I don't know what would work in Scryer Prolog.
    Also there are rumors that there are Coq and Isabelle/HOL
    libraries that allow reasoning about the construct, since it mimics

    aspects of RAM machines, which do have formalizations.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mostowski Collapse@21:1/5 to Mostowski Collapse on Thu Apr 21 08:34:16 2022
    Same speed as ECLiPSe Prolog which doesn't
    need setup_call_cleanup/3, solution from SO:

    /* ECLiPSe Prolog */
    [eclipse 5]: between(1,1000000,_), call_nth(call_nth((X=a;X=b), N), M), fail; true.
    X = X
    N = N
    M = M
    Yes (0.84s cpu)

    But 10 times faster than SICStus Prolog, which needs setup_call_cleanup/3, solution also from SO, which gives quite a speed damping:

    /* SICStus Prolog */
    ?- statistics(walltime, A), (between(1,1000000,_), call_nth(call_nth((X=a;X=b), N), M), fail; true),
    statistics(walltime, B).
    A = [408655,137987],
    B = [416794,8139] ?

    By SO solution I mean:
    https://stackoverflow.com/a/11400256/17524790

    Mostowski Collapse schrieb am Donnerstag, 21. April 2022 um 17:32:20 UTC+2:
    Oops, yes my bad. It could be that SICStus Prolog and ECLiPSe Prolog do
    not have some change_arg/3 equivalent. Was also making an experiment with:

    call_nth2(Goal_0, C) :-
    State = v(0),
    Goal_0,
    arg(1, State, C1),
    C2 is C1+1,
    nb_linkarg(1, State, C2),
    % setarg(1, State, C2, false), % for GNU Prolog
    C = C2.

    And then I got:

    /* SWI-Prolog */
    ?- time((between(1,1000000,_),
    call_nth2(call_nth2((X=a;X=b),N), M), fail; true)).
    % 10,000,003 inferences, 0.859 CPU in 0.847 seconds
    (101% CPU, 11636367 Lips)
    true.

    /* GNU Prolog */
    ?- ((between(1,1000000,_),
    call_nth2(call_nth2((X=a;X=b),N), M), fail; true)).
    (1578 ms) yes

    Was I allowed to use nb_linkarg/3? If this is allowed, then SWI-Prolog
    ranks top in speed.
    Mostowski Collapse schrieb am Donnerstag, 21. April 2022 um 12:26:55 UTC+2:
    If you don't think about introducing change_arg/3 in your Prolog system head start first, and start implementing call_nth/2 and all other stuff instead
    first, you are doing something wrong.

    Also that change_arg/3 isn't widely available is not correct, since recently I have it in formerly Jekejeke Prolog. So the list is bigger:

    - SWI-Prolog (corresponds to nb_linkarg/3, right?)
    - YAP (corresponds to nb_linkarg/3, right?)
    - GNU Prolog (possibly setarg/4 with 4-th argument false)
    - SICStus Prolog (didn't check yet which one is change_arg/3 exactly)
    - ECLiPSe Prolog (didn't check yet which one is change_arg/3 exactly)
    - Formerly Jekejeke Prolog (by its name)
    - Dogelog Player (by its name)
    - BinProlog from Paul Tarau (by its name)
    - ... What else?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Mostowski Collapse@21:1/5 to Mostowski Collapse on Thu Apr 21 08:32:19 2022
    Oops, yes my bad. It could be that SICStus Prolog and ECLiPSe Prolog do
    not have some change_arg/3 equivalent. Was also making an experiment with:

    call_nth2(Goal_0, C) :-
    State = v(0),
    Goal_0,
    arg(1, State, C1),
    C2 is C1+1,
    nb_linkarg(1, State, C2),
    % setarg(1, State, C2, false), % for GNU Prolog
    C = C2.

    And then I got:

    /* SWI-Prolog */
    ?- time((between(1,1000000,_),
    call_nth2(call_nth2((X=a;X=b),N), M), fail; true)).
    % 10,000,003 inferences, 0.859 CPU in 0.847 seconds
    (101% CPU, 11636367 Lips)
    true.

    /* GNU Prolog */
    ?- ((between(1,1000000,_),
    call_nth2(call_nth2((X=a;X=b),N), M), fail; true)).
    (1578 ms) yes

    Was I allowed to use nb_linkarg/3? If this is allowed, then SWI-Prolog
    ranks top in speed.

    Mostowski Collapse schrieb am Donnerstag, 21. April 2022 um 12:26:55 UTC+2:
    If you don't think about introducing change_arg/3 in your Prolog system
    head start first, and start implementing call_nth/2 and all other stuff instead
    first, you are doing something wrong.

    Also that change_arg/3 isn't widely available is not correct, since
    recently I have it in formerly Jekejeke Prolog. So the list is bigger:

    - SWI-Prolog (corresponds to nb_linkarg/3, right?)
    - YAP (corresponds to nb_linkarg/3, right?)
    - GNU Prolog (possibly setarg/4 with 4-th argument false)
    - SICStus Prolog (didn't check yet which one is change_arg/3 exactly)
    - ECLiPSe Prolog (didn't check yet which one is change_arg/3 exactly)
    - Formerly Jekejeke Prolog (by its name)
    - Dogelog Player (by its name)
    - BinProlog from Paul Tarau (by its name)
    - ... What else?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)