Why are people sleeping on the future?

Why are people sleeping on the future?

  1. 3 weeks ago
    Anonymous

    Buy an ad.

    • 3 weeks ago
      Anonymous

      >t. Filtered by prolog
      Keep seething retard

    • 3 weeks ago
      Anonymous

      you saw the youtube seething last week? no one wants ads. they'd rather reply to based threads bringing up based technology.

  2. 3 weeks ago
    Anonymous

    what is prolog and why would I use it?

    • 3 weeks ago
      Anonymous

      Declarative programming language. Because you stop wasting time writing boilerplate loops and spent more time focusing on the actual problem solving

      • 3 weeks ago
        Anonymous

        Ah, you're the tranny in the OCaml thread having a melt down over there.

      • 3 weeks ago
        Anonymous

        >declarative
        >has cut operator
        what did xe mean by this?

        • 3 weeks ago
          Anonymous

          what does a cut operator?

          • 3 weeks ago
            Anonymous

            Stops execution of a computational branch.

      • 3 weeks ago
        Anonymous

        >So, anon, what problems have you been solving with Prolog lately?

      • 3 weeks ago
        Anonymous

        >Declarative programming language
        Ah, so it's a DSL.
        What domain is it specialized for?

        • 3 weeks ago
          Anonymous

          constraint satisfaction
          implementing type inference in it is very easy for example

      • 3 weeks ago
        Anonymous

        >Because you stop wasting time writing boilerplate loops and spent more time focusing on the actual problem solving
        APL and derivatives do this way better.

  3. 3 weeks ago
    Anonymous

    Because prolog is awkward as all hell. For 99% of use cases it sucks. For the last 1% there's usually better choices.

    • 3 weeks ago
      Anonymous

      >Because prolog is awkward as all hell
      That is only the result of poor docs and syntax that could definitely be better but some things like lexers are easy af declaratively while traditionally you would need loops with hundreds of lines of logic

      • 3 weeks ago
        Anonymous

        NTA but do you know of good docs?

      • 3 weeks ago
        Anonymous

        Lexers are easy af in any language. Not difficult to make. But how do you optimize prolog lexers when it's slow and taking up your time?

  4. 3 weeks ago
    Anonymous

    I did advent of code using prolog. Performance sucks. In particular, there was the Van Eck Sequence, which was awfully slow to compute with prolog. Switching to python and doing the exact same computation was about 100 times faster.

    • 3 weeks ago
      Anonymous

      They are not the exact same computations if the speed was that different. Prolog just requires a different mindset and time investment.

      • 3 weeks ago
        Anonymous

        I ported the code. Literally copy&paste and made the necessary changes regarding syntax. Turned tail recursion into a loop, and turned prologs rbtree into a python dict. That's it.

        • 3 weeks ago
          Anonymous

          That's what I mean by mindset. Your code doesn't actually mean the same thing between the two languages. Good fast code in Prolog doesn't look like the equivalent Python code, because Prolog runs your code through a logic solver. It's like using a saw vs using a hammer to drive in a nail. You need to use different constructs/code structures in Prolog to accomplish the same task quickly.

          • 3 weeks ago
            Anonymous

            Alright then, can you show me a performant solution using prolog for the van eck sequence (advent of code 2020 day 15 part 2)?

            • 3 weeks ago
              Anonymous

              Yeah. It's possible that the hash table you used was slow. This is fast on my machine.
              %% hash table
              :- dynamic hash_table/2.

              hash_put(K, V) :-
              ( hash_table(K, V)
              -> true
              ;
              % delete the old entry if any
              (hash_table(K, W)
              ->
              retract(hash_table(K, W))
              ;
              true
              ),
              % insert
              asserta(hash_table(K, V))
              ).

              hash_get(K, V) :-
              hash_table(K, V).

              % compute the number spoken on PTurn + 1
              speak(PTurn, PNum, NextNumber) :-
              (hash_get(PNum, OldTurn)
              ->
              NextNumber is PTurn - OldTurn
              ;
              NextNumber = 0
              ).

              % clear the hash table, and add
              % the starting numbers.
              setup(S1, S2, S3) :-
              retractall(hash_table(_, _)),
              hash_put(S1, 1),
              hash_put(S2, 2),
              hash_put(prev, S3).

              % recursive procedure to compute the number spoken each turn
              compute_iter(Turn, TargetTurn, Result) :-
              % compute number spoken on this turn
              hash_get(prev, PNum),
              PTurn is Turn - 1,
              speak(PTurn, PNum, NextNumber),
              write('Turn: '),
              write(Turn),
              write(', Number: '),
              write(NextNumber),
              write('n'),
              % save the previous number
              % such that its "last seen value"
              % is the most recent one.
              hash_put(PNum, PTurn),
              % mark this turn's number as the new "previous"
              hash_put(prev, NextNumber),
              ( Turn = TargetTurn
              ->
              Result = NextNumber
              ;
              NextTurn is Turn + 1,
              compute_iter(NextTurn, TargetTurn, Result)
              ).

              compute(S1, S2, S3, TargetTurn, Result) :-
              TargetTurn > 3,
              setup(S1, S2, S3),
              compute_iter(4, TargetTurn, Result).

              :- compute(0, 3, 6, 2020, Result),
              write('On turn 2020, number is '),
              write(Result),
              write('n').

              • 3 weeks ago
                Anonymous

                teach me senpai!

              • 3 weeks ago
                Anonymous

                kek, okay what do you need to know?

                >the hash table
                Prolog is a database of facts, and you can modify this database at runtime.
                assert() introduces a fact, and retract() deletes it.
                Maybe you'll like this explanation:

                I set this program up so that I can create or delete facts that look like "hash_table(K, V)". You can think of this as saying "at key K, the hash table has stored the value V".
                This is the 'dictionary'.

                The goal hash_put(K, V) uses assert() to insert the fact "hash_table(K, V)" into the dictionary. For example hash_put(hello, world) will create the fact "hash_table(hello, world)".

                hash_get(K, V) can be used to "get" things from the hash table. Continuing the example above, I could write "hash_get(hello, X)" and Prolog will search for a fact that matches the pattern and make X equal to "world". But I can also do hash_get(X, world) to find a key associated with "world". So it's not a normal dictionary, it's more flexible because of Prolog's "unification" feature.

                >van eck sequence
                In the hash table I store the numbers that have been spoken so far, together with the turn number on which the number was most recently spoken. For example if number 3 was most recently spoken on turn 5, then the database should contain the fact hash_table(3, 5). And so on for all the other numbers spoken. If I encounter the number 3 on a later turn, say, 8, then I delete the old fact with retract() before I create a new fact hash_table(3, 8). This is what hash_put does.

                I use the goal compute_iter, which uses tail recursion to compute the numbers to add to the hash table each turn. It begins at turn 4 and just counts up to 2020.

                I also use the hash table to track another variable I called "prev", which is the number spoken on the previous turn. Only after I have calculated the number for the current turn (NextNumber) will I insert the previous one into the hash table as normal.

              • 3 weeks ago
                Anonymous

                >Given your starting numbers, what will be the 30000000th number spoken?

                Is it still fast on your machine for part 2 of the puzzle? The 30000000th number spoken? Because on my machine it has been running for quite a while and is still not finished.

                Meanwhile, the translated python code which I mentioned earlier is done within seconds on my machine. (It looks weird because it's ported from prolog without cleaning up.)

                [CODE]
                def take_turn(Dict, LastTurn, LastNumber):
                while LastTurn < 30000000:
                Age = 0
                if LastNumber in Dict:
                PreviousTurn = Dict[LastNumber]
                Age = LastTurn - PreviousTurn
                Dict[LastNumber] = LastTurn
                CurrentTurn = LastTurn + 1
                LastTurn = CurrentTurn
                LastNumber = Age
                return LastNumber

                def initialize_dict(List):
                Turn = 1
                Dict = dict()
                for E in List:
                Dict[E] = Turn
                Turn = Turn + 1
                return Dict

                def main():
                FirstInputNumbers = [0,3]
                LastInputNumber = 6
                LastInputTurn = 3
                Dict = initialize_dict(FirstInputNumbers)
                Result = take_turn(Dict, LastInputTurn, LastInputNumber)
                print(Result)

                main()
                [/CODE]

              • 3 weeks ago
                Anonymous

                Let's try using the code tags again, I guess....

                def take_turn(Dict, LastTurn, LastNumber):
                while LastTurn < 30000000:
                Age = 0
                if LastNumber in Dict:
                PreviousTurn = Dict[LastNumber]
                Age = LastTurn - PreviousTurn
                Dict[LastNumber] = LastTurn
                CurrentTurn = LastTurn + 1
                LastTurn = CurrentTurn
                LastNumber = Age
                return LastNumber

                def initialize_dict(List):
                Turn = 1
                Dict = dict()
                for E in List:
                Dict[E] = Turn
                Turn = Turn + 1
                return Dict

                def main():
                FirstInputNumbers = [0,3]
                LastInputNumber = 6
                LastInputTurn = 3
                Dict = initialize_dict(FirstInputNumbers)
                Result = take_turn(Dict, LastInputTurn, LastInputNumber)
                print(Result)

                main()

              • 3 weeks ago
                Anonymous

                you can drop [/CODE] (in lowercase) if there is nothing after

              • 3 weeks ago
                Anonymous

                I see, thanks!

  5. 3 weeks ago
    Anonymous

    Everybody's read through the prolog and now we're waiting for the main text

  6. 3 weeks ago
    Anonymous

    >Anon, were you trying to lie to me about your Prolog experience?

  7. 3 weeks ago
    Anonymous

    I did prolog back in 2005 at college. It was a meme then and is now.

    • 3 weeks ago
      Anonymous

      Is it though?

      https://www.cs.cmu.edu/Groups/AI/html/faqs/lang/prolog/prg/part1/faq-doc-9.html
      >The Prolog 1000 is a database of real Prolog applications being assembled in conjunction with the Association for Logic Programming (ALP) and PVG. The aim is to demonstrate how Prolog is being used in the real world and it already contains over 500 programs with a total of well over 2 million lines of code.

      https://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/prolog/doc/pl_1000/pl1000v1.gz

      • 3 weeks ago
        Anonymous

        So linux kernel alone is 15M loc.
        Those 2M is probably mostly projects by some overly-ardent graduate students and actually does nothing or could be rewritten in another language just as easily. The question here is: what are the idiomatic use-cases for prolog, and not "hey, we can do it here too, just 10 times slower".

        • 3 weeks ago
          Anonymous

          I mean, I tried to read some prolog books, but lost interest, and they started either trivial or with how the engine or whatever works. What I gathered is that it all it is good for is a database of facts, where some facts are automatically inferred. The solver is of a general nature, meaning it's slow as fuck, but it's also dumb as fuck, because logical inference based on facts goes only so far.

          anons, extract the archive. that's the main point of my post, I just copy pasted a few lines just so that you know wtf the random file is about, but when you look at the text files it's fucking impressive

      • 3 weeks ago
        Anonymous

        I mean, I tried to read some prolog books, but lost interest, and they started either trivial or with how the engine or whatever works. What I gathered is that it all it is good for is a database of facts, where some facts are automatically inferred. The solver is of a general nature, meaning it's slow as fuck, but it's also dumb as fuck, because logical inference based on facts goes only so far.

      • 3 weeks ago
        Anonymous

        So linux kernel alone is 15M loc.
        Those 2M is probably mostly projects by some overly-ardent graduate students and actually does nothing or could be rewritten in another language just as easily. The question here is: what are the idiomatic use-cases for prolog, and not "hey, we can do it here too, just 10 times slower".

        I mean, I tried to read some prolog books, but lost interest, and they started either trivial or with how the engine or whatever works. What I gathered is that it all it is good for is a database of facts, where some facts are automatically inferred. The solver is of a general nature, meaning it's slow as fuck, but it's also dumb as fuck, because logical inference based on facts goes only so far.

        > logical inference based on facts goes only so far...
        ...which is to say -- not very far. So I don't see how prolog can compete with normal languages. You basically have a general-purpose algorithm under the hood and you are trying to cajole it into solving the actual problem for you. That sounds not just anti-straitforward, but retarded as fuck.

        So, prolog is basically a slow retarded database mainly used for jerking off in academia. Anything I missed?

        • 3 weeks ago
          Anonymous

          >So, prolog is basically a slow retarded database mainly used for jerking off in academia. Anything I missed?
          It was created around the time when symbolic AI was more popular than deep learning. And it's still used in industry at some places. Prolog is also great for expressing problems that require search or dynamic programming, like computing a schedule for N people that has to satisfy various constraints. Sure, you can also do anything in other languages because of Turing-completeness, but Prolog makes its tasks more convenient.

          • 3 weeks ago
            Anonymous

            (me)
            I forgot to mention planning problems, pathfinding, etc.
            There are also computations that take so much time that Prolog being somewhat slower doesn't make a serious difference. Then what's more important is how convenient the language is.

        • 3 weeks ago
          Anonymous

          >So, prolog is basically a slow retarded database mainly used for jerking off in academia. Anything I missed?
          I think the best use for Prolog is "expert systems", not specific and intensive solvers. Programs that are not used to make relatively simple data structures transformations but rather programs containing hundreds of conditionals, all of them relating to the real logic of the program/applications, not conditionals inside loops checing for termaintions or for doing filtering.
          You can see it from the list of companies and applications here

          Is it though?

          https://www.cs.cmu.edu/Groups/AI/html/faqs/lang/prolog/prg/part1/faq-doc-9.html
          >The Prolog 1000 is a database of real Prolog applications being assembled in conjunction with the Association for Logic Programming (ALP) and PVG. The aim is to demonstrate how Prolog is being used in the real world and it already contains over 500 programs with a total of well over 2 million lines of code.

          https://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/prolog/doc/pl_1000/pl1000v1.gz

          https://www.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/prolog/doc/pl_1000/pl1000v1.gz. Each of this application is used to "help people think or act", they do not really transform
          In this list there are least 1 or 2 prolog system for doing Law type kind of stuff. You can easily imagine that the kind of program requied for helping lawyers is not one that will transform linked list. It's more like it will contains thousands of conditionals to discrimimate situations or something. All that matters is the "rules".

          • 3 weeks ago
            Anonymous

            >they do not really transform
            *data structures. Like any regular program you use, from text editor to virtual machine to browser engine to game engine to ffmpeg, etc.... All of those transform data, their use case is not to help people think.

  8. 3 weeks ago
    Anonymous

    prolog is basically Lisp except with weird(er) syntax and you can run functions bidirectionally

  9. 3 weeks ago
    Anonymous

    Kinda reminds me of the Duolingo owl. Are they related?

  10. 3 weeks ago
    Anonymous

    >prolog
    >future
    kek
    who knew the future was 30 years ago

    • 3 weeks ago
      Anonymous

      >peak high tech was the 1990s
      Yes.

Your email address will not be published. Required fields are marked *