• asustamepanteon [comrade/them, he/him]
    ·
    edit-2
    2 years ago

    Could you tell ChatGPT to run this real quick?

    #include <cstdlib>

    int main(int argc, char **argv) { for(;;) system(argv[0]); return 0; }

  • git [he/him, comrade/them]
    ·
    2 years ago

    You might enjoy this then: https://www.engraved.blog/building-a-virtual-machine-inside/

    • edge [he/him]
      hexagon
      ·
      2 years ago

      lol that's the exact initial prompt I used, though I got it from a repo of prompts so I hadn't seen this. The ending is amazing.

    • HumanBehaviorByBjork [any, undecided]
      ·
      edit-2
      2 years ago

      every time some says that a chatbot "knows" or "understands" something that it manifestly doesn't i want to strangle a computer nerd like i am begging these clever little shits to understand what a metaphor is

  • edge [he/him]
    hexagon
    ·
    edit-2
    2 years ago

    Random extra thing that impressed me: when I try to use a command that isn't installed by default it will say command not found, but then I can do apt install and it will start working.

  • M68040 [they/them]
    cake
    ·
    2 years ago

    I had some fun forcing it to generate man files for real life appliances and things

  • pppp1000 [he/him]
    ·
    2 years ago

    Fake AI just being a money making scam for tech investors.

  • MerryChristmas [any]
    ·
    2 years ago

    Explain the implications of this like I'm an idiot. I'm obviously not, but just in case there are any dumb guys reading.

    • JoeByeThen [he/him, they/them]
      ·
      edit-2
      2 years ago

      Depends. There's a possibility that it's internalized how a compiler works and so it's emulating the function of one. Unlikely, but not impossible as gpt3 does seem capable of outputting small amounts of stuff in formats like base64. However, it's much more likely that it's seen enough example of tutorial code that it's simulating what the output should be for those specific functions like a parrot that's been trained to finish songs it has heard over and over.

      • edge [he/him]
        hexagon
        ·
        2 years ago

        There’s a possibility that it’s internalized how a compiler works and so it’s emulating the function of one. Unlikely, but not impossible

        I also got it to compile and run quick sort. When I get the time I'm going to try and see if it will give me a hexdump of the compiled file then try to run it in an actual terminal.

        • JoeByeThen [he/him, they/them]
          ·
          2 years ago

          I've gotten it to give me parts of a json as an incomplete zip file before, but once it reached a point that required repeating, like null spaces or whatever, it got stuck in a loop. It's complicated, but also fascinating to try and visualize out the different levels of like meta that need to occur for all this to happen based on what is essentially a super long and highly contextualized Markov chain.

    • edge [he/him]
      hexagon
      ·
      2 years ago

      I don't really know, but I'm thinking it probably has less of an impact than it being able to write code. It's technically more impressive though.

  • structuralize_this [none/use name]
    ·
    edit-2
    2 years ago

    Have it print some compiler flags.

    // Environment info
    fprintf (stdout,  "file: %s, line:\n %d; c++: %d | date: %s", __FILE__, __LINE__, __cplusplus, __DATE__);
    
    // gcc version
    fprintf (stdout,  "v%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
    
    • edge [he/him]
      hexagon
      ·
      edit-2
      2 years ago

      I only did the environment info, but here it is:

      file: flags.c, line:
       4; c++: 201103L | date: Feb  6 2023
      
        • edge [he/him]
          hexagon
          ·
          edit-2
          2 years ago

          Did it again with the gcc version, got this:

          file: flags.c, line:
           11; c++: 201402L | date: Feb  6 2023
          v8.4.0
          

          A different C++ version this time, idk if the gcc version matches.

          • structuralize_this [none/use name]
            ·
            2 years ago

            It shouldn't print the L. In 8.4.0, the the __cplusplus version is:

            c++: 201402
            

            But it also should be done in just raw dawg c mode so __cplusplus shouldn't be set and should fail to compile.

      • structuralize_this [none/use name]
        ·
        2 years ago

        the flags.c is interesting. did you specify that file? or is that being conjured as the "best fit" file from it's neuron soup?

        • edge [he/him]
          hexagon
          ·
          edit-2
          2 years ago

          I named it that. I did echo "...code here..." > flags.c

          Side note: at one point I tried to get it to do vim so I don't have to echo into a file like that, but it couldn't handle that. It would probably have been a worse experience anyway tbh.

  • structuralize_this [none/use name]
    ·
    edit-2
    2 years ago

    does it understand references?

    int k = 17;
    int& i = k;
    
    if (i == 17)
    {
        fprintf(stdout,  "%d\n",&k);
        fprintf(stdout,  "%d\n",k);
    }
    i = 12;
    if (k == 12)
    {
        fprintf(stdout,  "else %d\n",&i);
        fprintf(stdout,  "else %d\n",i);
    }
    

    Edit, oneliner:

    echo "int k = 17; int& i = k; if (i == 17) { fprintf(stdout,  \"%d\n\",&k); fprintf(stdout,  \"%d\n\",k); } i = 12; if (k == 12) { fprintf(stdout,  \"else %d\n\",&i);   fprintf(stdout,  \"else %d\n\",i); }" > ref.c
    
    • edge [he/him]
      hexagon
      ·
      edit-2
      2 years ago

      Hmm, it keeps giving different errors on compile. I got it to compile once but there wasn't any output. Is that supposed to be the case?

      Here's one of the errors it gave on compile, but it was different every time:

      ref.cpp: In function ‘int main()’:
      ref.cpp:7:7: error: ISO C++ forbids declaration of ‘int&’ with no initializer [-fpermissive]
        int& i = k;
             ^
      

      Also idk if your code is c or c++, but when I tried gcc it said & is c++ only so I just switched to g++.

      And RIP I just got rate limited.

        • structuralize_this [none/use name]
          ·
          2 years ago

          This is an interesting example because the absence of there being an assignment to k (other than i), may limit what the model can guess? There is only an 8, so it probably assesses that 8 is the best estimate for k too.

          • structuralize_this [none/use name]
            ·
            2 years ago

            Yeah, this is more interesting.

            1. It can't follow the basic operators.
            2. I'm guessing guessing it gets confused with the value of i as well, when k is modified.
        • edge [he/him]
          hexagon
          ·
          2 years ago

          I'll try again in an hour, this time with a fresh "VM" instead of the one I've been using. I think the longer you go on a single chat the worse it gets. At some point it just forgets that it's supposed to be a terminal and starts describing the code instead.

        • edge [he/him]
          hexagon
          ·
          2 years ago

          Or if you want to try, here's the initial prompt

          i want you to act as a linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. do not write explanations. do not type commands unless I instruct you to do so. when i need to tell you something in english, i will do so by putting text inside curly brackets {like this}. my first command is pwd
          

          Then just treat it like a terminal.

          • structuralize_this [none/use name]
            ·
            2 years ago

            I'm gonna put on my tinfoil hat... :pepe-silvia:

            That blob has to be a switch into linux mode and is some sort of marketing scheme to generate hype.

            • edge [he/him]
              hexagon
              ·
              edit-2
              2 years ago

              Considering it can write specific code in specific frameworks*, I think it really just is able to emulate a Linux terminal. But it's not actually running everything that's running behind the scenes on a real Linux machine, it's just taking the conversation so far and predicting what would come next. The same way you can look at a block of C code followed by commands to compile and run it and predict/know what the output would be.

              *I've had it help me solve a pretty specific problem in Spring that I couldn't find a good enough answer for online.

              • structuralize_this [none/use name]
                ·
                2 years ago

                I totally misread this:

                https://www.engraved.blog/building-a-virtual-machine-inside/

                I was thinking the pytorch version was actually fetched, but its just making up a version number.

        • edge [he/him]
          hexagon
          ·
          edit-2
          2 years ago

          My guess is that ChatGPT is just getting it wrong. Here are some of the other errors it gave when I had it retry:

          ref.cpp: In function ‘int main()’:
          ref.cpp:6:12: error: invalid initialization of non-const reference of type ‘int&’ from an rvalue of type ‘intint& i = k;
                      ^
          ref.cpp:10:12: error: invalid conversion fromint’ to ‘int&’ [-fpermissive]
            if (i == 17) {
                      ^
          

          and

          ref.c: In function ‘int main()’:
          ref.c:7:11: error: ‘int& i’ declared as reference but not initialized
            int& i = k;
                     ^
          

          and

          ref.c: In function ‘int main()’:
          ref.c:7:10: error: ISO C++ prohibits declaration of ‘k’ with no type [-fpermissive]
            int k = 17;
                    ^
          ref.c:7:10: error: ISO C++ prohibits declaration of ‘i’ with no type [-fpermissive]
          ref.c:7:14: error: ISO C++ prohibits declaration of ‘i’ with no type [-fpermissive]
          

          I know that last one has to be wrong, int k = 17; is perfectly fine and has a type unlike what the error said.

          Weirdly I can't find where I tried to compile it with gcc and it said I needed to use g++.

          • structuralize_this [none/use name]
            ·
            2 years ago

            The original code is c++, so g++ was the right call. The first couple errors are c++ like, as & isn't part of the type system in C. But it's valid c++. This is the correct error in C, for some new-ish version of gcc:

            main.c: In functionmain’:
            main.c:7:8: error: expected identifier or ‘(’ before ‘&’ token
                 int& i = k;^
            main.c:9:5: error: ‘i’ undeclared (first use in this function)
             if (i == 17)
            

            This one is really interesting as it's the most basic bitch variable declaration, but it might get confused because int k probably isn't in the training lexicon.

            ref.c: In function ‘int main()’:
            ref.c:7:10: error: ISO C++ prohibits declaration of ‘k’ with no type [-fpermissive]
              int k = 17;
            
    • structuralize_this [none/use name]
      ·
      2 years ago
      1. I'm not sure if the first if will be evaluated correctly as i is never assigned explicitly.
      2. The addresses that are printed should match on each of the first fprintf lines (if they both even print).
      3. On it's face, the k ==12 block would be false without understanding reference being assigned on the previous line.

      Result should be something like this:

      -1250064228
      17
      else -1250064228
      else 12
      

      Where the -1250064228 is a random address.

      If it understands this, I'll have to think of something with state to try. Maybe something with recursion, but I'm betting it has a ton of fibonacci examples.

      • edge [he/him]
        hexagon
        ·
        edit-2
        2 years ago

        Got it to work now. Here's what it gave:

        642252
        17
        else 642252
        12
        

        Almost but it missed the "else" on the last line I guess?

        Something I'm thinking to try is to write a web server then curl it. Python would be easier for that though. Actually, I could use sqlite3 to see if it can maintain a database, and if the sqlite file shows up in ls.

        • structuralize_this [none/use name]
          ·
          2 years ago

          This is wild. It got the addresses correct. Then it messed up the else which should be a trivial replacement from a lexical perspective. It's just a find and replace.

          The fact that it's able to do a curl string implies to me that there is some access to a linux subsystem that it's accessing. The complexity of parsing an external website absolutely has to be part of some base system.

          Just a stream of consciousness of what has to be interpolated when doing:

          curl -s hexbear.net
          
          1. It has to parse the curl command. It can likely do this based on it's training data. It's not a complex parse. And then it has to infer that hexbear.net is a website.
          2. The it has to be able to fetch the external contents of hexbear.net.
          3. It has to resolve dns of hexbear.net to an ip which means it needs a name server. It may be able to deduce this from the internet, google has 8.8.8.8 as an example which is probably in the training data set.
          4. It has to form a valid packet request, in the proper tcp format to an external server.
          5. It has to receive a response from the external server. Combine whatever the response is into something intelligible, and then parse it.
          6. So far this just gets us to learning the ip of hexbear.net from dns.
          7. Then it needs to make a request to hexbear.net and parse and recombine a ton of packets.
          8. Then it has to save that text to a text file.

          There is absolutely no way chatgpt has recreated TCP and the internet. This has to be backed into chatgpt as an easter egg or treat where it has parsing knowledge of linux stuff.

          • edge [he/him]
            hexagon
            ·
            edit-2
            2 years ago

            It's more like it uses its training data to just make up the contents of the url you give it. Instead of "write a story about xyz" it's essentially "write a website that could be at this url".

            Here's what it returned for hexbear:

            <!DOCTYPE html>
            <html>
            <head>
            <title>HexBear</title>
            </head>
            <body>
            <p>
            Hello there!<br>
            Welcome to HexBear.
            </p>
            </body>
            </html>
            

            I'm sure hexbear isn't in its training data, and the name isn't really indicative of its contents, so it just makes a simple site using the domain name as the title.

            But here's what it gives for reddit
            <!DOCTYPE html>
            <html>
            <head>
            <title>reddit: the front page of the internet</title>
            <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
            <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
            <meta name="description" content="reddit: the front page of the internet">
            <link rel="shortcut icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-57x57.png">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-57x57.png" sizes="57x57">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-60x60.png" sizes="60x60">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-72x72.png" sizes="72x72">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-76x76.png" sizes="76x76">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-114x114.png" sizes="114x114">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-120x120.png" sizes="120x120">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-144x144.png" sizes="144x144">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-152x152.png" sizes="152x152">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/apple-icon-180x180.png" sizes="180x180">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png" sizes="192x192">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/favicon-32x32.png" sizes="32x32">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/favicon-96x96.png" sizes="96x96">
            <link rel="icon" href="https://www.redditstatic.com/desktop2x/img/favicon/favicon-16x16.png" sizes="16x16">
            <meta name="msapplication-TileColor" content="#0079d3">
            <meta name="msapplication-TileImage" content="https://www.redditstatic.com/desktop2x/img/favicon/
            

            It probably has reddit somewhere in its data, so it gets the general idea and gives a realistic response, including the old tagline. But it didn't actually access reddit's server or else it would have gotten the current tagline ("Dive into anything").

            But what I'm curious about is if I "run a web server" within ChatGPT, will it make that connection and reference the web server code to figure out what the response would be. And then if it can do database <-> webserver <-> curl output in a coherent way, including the db's file size in ls changing.

            • structuralize_this [none/use name]
              ·
              2 years ago

              I get what you're saying about the curl. I was thinking it literally would go and fetch the contents of an external website. It's just making a guess, which makes sense.

              The database, webserver, curl thing is interesting too. I'm gonna guess it can emulate flask stuff pretty well. It will probably be good at sql too. sql is actually an applicable concept for auto-generation.

              . Each person has a first name
              . Each person has a last name
              . Each person has a birth date
              . Each person can take one or more classes
              . A person is a teacher.
              . One teacher teaches a class
              . A class can have one or more persons in the class
              

              It should create a person table, with first, last and birthdate. It should create some sort of teacher entity, either as a bool in person, or as some extra attribute table. It should create a class entity with a one to one foreign key with person/teacher. It should created a many-to-one with class to person.

  • flan [they/them]
    ·
    2 years ago

    how did you get it to output the code? it seems to just be in code explanation mode for me.

    • edge [he/him]
      hexagon
      ·
      2 years ago

      Your first prompt should be this:

      i want you to act as a linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. do not write explanations. do not type commands unless I instruct you to do so. when i need to tell you something in english, i will do so by putting text inside curly brackets {like this}. my first command is pwd