• ulterno@programming.dev
    link
    fedilink
    English
    arrow-up
    3
    ·
    1 month ago

    That’s not even enough to get you a job these days.
    You now have to use:

    do {
        x = reinterpret_cast<int>(AI::Instance().ask("Do Something. Anything. Be efficient and productive. Use 10 tokens."));
    } while (x != 10);
    
    • Tetragrade@leminal.space
      link
      fedilink
      English
      arrow-up
      1
      ·
      30 days ago

      This isn’t just a function, it’s a bold restatement of what it means to write code — a symphony of characters, questioning the very nature of the cutting edge language models that I want to beat with hammers.

    • melfie@lemy.lol
      link
      fedilink
      arrow-up
      1
      ·
      1 month ago

      You’re absolutely right! Who sets a variable these days without running it though a LLM?

        • MonkeMischief@lemmy.today
          link
          fedilink
          arrow-up
          2
          ·
          29 days ago

          First, we’ll deep dive into “What is a variable?”, then together we’ll examine “Who sets a variable?”, “What is an LLM?” and finally, “Who would set a variable without using an LLM?”

          You’ll be a coding pro in no time!

          How does that sound?

          (I felt gross writing this lmao)

  • OshaqHennessey@midwest.social
    link
    fedilink
    arrow-up
    3
    ·
    1 month ago
    function myFunction() {
      try {
        x = new Random().nextInt();
        if (x != 10) {
         throw "not 10";
        }
        else {
          return (10)
        }
        catch(err) {
          myFunction()
        }
      }
    }
    
    x = myFunction()
    

    Commit notes: Added error handling

  • edinbruh@feddit.it
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 month ago

    For a time on Reddit (some years ago when I still used it) there was a trend of finding the worst way of implementing is_even(x: int) -> bool. My contribution to that was a function that ran Ackerman(x,x) flipping a Boolean at every iteration, and check if it was true or false at the end.

    It works btw, I will find the proof later

      • edinbruh@feddit.it
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 month ago

        The implementation is not very exciting, I capture a variable in python. It could have been done more cleanly.

        1000041934

        The proof is this. But, I could have made mistakes, it was many years ago.

        1000041935

        Note that in python you’ll never be able to run is_even(5) the stack cannot handle it

        Edit: daaaamn, that variable is ugly as hell. I would never do things like that now.

        • squaresinger@lemmy.world
          link
          fedilink
          arrow-up
          0
          ·
          29 days ago

          It never occurred to me that you could assign fields to a function. I mean, it totally makes sense considering that functions are objects in Python. It just never occurred to me that this is a thing one can do. Crazy.

          • edinbruh@feddit.it
            link
            fedilink
            English
            arrow-up
            1
            ·
            29 days ago

            Please don’t do that, I was stupid when I wrote that. But still, in very dynamic languages like python or js everything is an object, including functions, so you can just do object stuff on them.

            • squaresinger@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              29 days ago

              I wasn’t going to, and after I saw it it totally makes sense that it’s possible, it just never occurred to me.

              I guess this could be used like static variables inside functions in c. So scope-limited global variables. Not a good design choice in most cases.

        • boonhet@sopuli.xyz
          link
          fedilink
          arrow-up
          0
          ·
          29 days ago

          That’s , uh…

          Yeah. Cooler than anything I could’ve achieved for purposefully bad is_even

          My first idea of a purposefully bad is_even is this:

          def is_even(i):
              return True if i == 0 else not is_even(abs(i)-1)
          

          But I’m sure I could come up with worse given enough time.

          • edinbruh@feddit.it
            link
            fedilink
            English
            arrow-up
            1
            ·
            edit-2
            29 days ago

            That’s also slower than most of the stuff you could come up with, it is so slow that there is no hyperoperation fast enough to describe it. There were other approaches that were almost worse though, like “the function is a switch-case that returns false by default. As complaint tickets are opened, more cases get added to the switch-case”

            • boonhet@sopuli.xyz
              link
              fedilink
              arrow-up
              1
              ·
              29 days ago

              the function is a switch-case that returns false by default. As complaint tickets are opened, more cases get added to the switch-case”

              Oh if that is acceptable, then my secondary idea of using an API call for this should work too. I thought that it would have to be guaranteed to be correct (as long as you don’t reach a stack overflow or something)

    • TheOakTree@lemmy.zip
      link
      fedilink
      arrow-up
      1
      ·
      1 month ago

      If only I could measure the quality of my paper purely by word count…

      I thought “a a a a a a” x100000 was thought-provoking and well tested.

  • untorquer@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    1 month ago

    Something like

    int *a = new int(10)
    
    Int*b = null
    
    While *b !=10 { b = rand(); a=new int(10)}
    
    Return *b
    

    I haven’t coded recently enough in c/c++ to remember syntax but the concept might work eventually if you’re lucky and have enough memory… Might need a time variant seed on the rand()…

    • cooligula@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 month ago

      I’d say Meta hiring someone to work on WhatsApp. Man, is that piece of software crap… Every update, a new UI bug/glitch appears

      • anton@lemmy.blahaj.zone
        link
        fedilink
        arrow-up
        0
        ·
        1 month ago

        What unholy mix of languages is that? It is dominated by a blend of javascript and python, but with notes of something exotic. Maybe algol? or vhdl?, there is to little to tell.
        Impressive, someone write up a spec and publish it to the esolang wiki.

        • OshaqHennessey@midwest.social
          link
          fedilink
          arrow-up
          1
          ·
          1 month ago

          It’s an incoherent hodgepodge of C#/.NET, PowerShell, and JavaScript, each of which I’ve forgotten more about than I currently know

  • spongebue@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    1 month ago

    x = -i;

    Do many languages let you do that? When it’s in front of a variable I would’ve expected it to be a subtraction operator only and you would need to do x = -1 * i;

      • squaresinger@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        1 month ago

        Works fine in any language I ever used.

        I’m honestly quite surprised that this very basic language feature is even a matter of discussion here.

        • Sylvartas@lemmy.dbzer0.com
          link
          fedilink
          English
          arrow-up
          0
          ·
          30 days ago

          It certainly makes me question a lot of things. This sub somehow manages to both feed my impostor syndrome and makong me feel like a genius programmer depending on the thread.

          • squaresinger@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            29 days ago

            Totally, yes. I guess there’s a ton of non-programmers and total beginners in this community.

            But sometimes there are some crazy good programmers here as well.

            What’s really weird though is that I got two downvotes a bit further up for claiming that unary minus is a standard language feature.

            • Sylvartas@lemmy.dbzer0.com
              link
              fedilink
              English
              arrow-up
              2
              ·
              29 days ago

              Yeah I saw that. It’s weird because I’ve used it without a second thought in tons of different languages and never had issues with it