Just ask it to rewrite the shitty code you wrote in a language you barely understand to “follow standard best practices in <language>” or something like that and it will add advanced typing features, functional programming for iterables, advanced exception handling, proper concurrency handling, optimize control flows, use better equivalent functions, etc.

As long as you understand the foundations of these concepts in at least one language anybody can become pretty close to an expert in most languages instantly. Especially since most of them are C based and pretty similar

The output will sometimes change the logic but I mean that’s pretty easy to catch and fix

Rip C++ nerds that memorize the entirety of each releases manual to shave off 3ms in every single function

  • PapaEmeritusIII [any]@hexbear.net
    link
    fedilink
    English
    arrow-up
    19
    ·
    edit-2
    3 days ago

    Become “pretty close to an expert” by… outsourcing the process of improving your code to a machine…

    Even if it improves your code in that scenario, you’re not going to really understand what it’s doing or why. You can use AI as a shortcut for scripting, but you can’t use it as a shortcut for learning

    Edit: Besides, we already have perfectly good static analysis tools. Just use a linter. Trying to use AI as a linter will just be worse and unpredictable compared to using an actual linter

    • GaveUp [she/her]@hexbear.netOP
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      2
      ·
      3 days ago

      But I’m not using it for learning. I already understand exception handling, concurrency, typing, etc.

      But I only know the exact syntax for some languages

      Now I can replicate the best practices for those concepts in a language I’ve never touched, and I can understand what it does because I know the equivalent syntax in another language and so I can also judge the quality as well

      It’s even more confident when the new language is C based because I’m already familiar with other C based languages

      Obviously it’ll never be as good as a person who spent time to learn the language by reading documentation and practicing but most cases it should be fine

      • footfaults@lemmygrad.ml
        link
        fedilink
        English
        arrow-up
        18
        ·
        3 days ago

        I already understand exception handling, concurrency, typing, etc.

        But I only know the exact syntax for some languages

        Now I can replicate the best practices for those concepts in a language I’ve never touched, and I can understand what it does because I know the equivalent syntax in another language and so I can also judge the quality as well

        I’m sorry but this just doesn’t match my experience. I have used greenlet, Node.js, asyncio, POSIX threads, kqueue, and uv and just recently I had to look at something that uses tokio (Rust) and I would never say confidently that just because I know the syntax of one concurrency library, that looking at a different language and equivalent library I can immediately judge the quality and understand what it does.

        That is just not realistic

        • Hermes [none/use name]@hexbear.net
          link
          fedilink
          English
          arrow-up
          11
          ·
          3 days ago

          Don’t you know that all programming languages are the same, except each uses a different set of symbols and keywords? Since all languages are the same, we can use an LLM to efficiently translate code from one language into another where it will perform optimally. /s

          • footfaults@lemmygrad.ml
            link
            fedilink
            English
            arrow-up
            7
            ·
            3 days ago

            “Computer, replace all the whitespace indentation with curly braces and put a semicolon at the end of every line, in order to convert my Python program to Rust”

            • invalidusernamelol [he/him]@hexbear.net
              link
              fedilink
              English
              arrow-up
              1
              ·
              1 day ago

              Python also allows you to override what operators do meaning I can write

              int.__add__ = lambda self, other: print("hello world")
              
              >>> 1 + 2
              'hello world'
              

              And that’s totally valid code. Don’t think many other languages allow that, and translating that would be a mess.

              • footfaults@lemmygrad.ml
                link
                fedilink
                English
                arrow-up
                2
                ·
                edit-2
                1 day ago

                It’s technically operator overloading, the wacky thing that Python allows you to do, is overload operators for base types like int which I’m not sure if other languages allow you to do for base types.

                • invalidusernamelol [he/him]@hexbear.net
                  link
                  fedilink
                  English
                  arrow-up
                  2
                  ·
                  23 hours ago

                  That’s what I meant, you can modify the behavior of code by directly over riding the operator implementation for base types. What it really reveals is that Python int is not at all a C int or really any other int.

                  Directly translating syntax without knowing that the Python type is so vastly different from say, the C type is a recipe for latent disaster.

        • GaveUp [she/her]@hexbear.netOP
          link
          fedilink
          English
          arrow-up
          3
          arrow-down
          1
          ·
          edit-2
          3 days ago

          Well my personal experiences have just been that the ML approach catches a lot of things the static analysis tool hasn’t. Those are hard coded by humans and there are dozens of not hundreds of ways to write any given function with identical logic. It’s impossible for static analysis to be comprehensive enough to catch and fix a code block more than a few lines

          E.g. I had a super ugly nested try catch exception block for this new integration test I was writing. It was using a test framework and language I’ve never used before, and so it was the only way I knew to write this logic. I asked the LLM to improve it and it broke up the nested try catch logic into 2 top level pieces with timeout functions and assertion checks I didn’t know existed. The timeout removing the need to throw an exception and the assertion fixing the issue of catching it

          • PapaEmeritusIII [any]@hexbear.net
            link
            fedilink
            English
            arrow-up
            9
            ·
            3 days ago

            I’m glad you’ve gotten some actual use out of the LLMs! My outlook is more skeptical because I’ve seen too many interns get stuck on projects because they tried to ask LLMs for advice (which they did not double check) instead of reaching out to an experienced dev. The word calculators can only do so much.

            • GaveUp [she/her]@hexbear.netOP
              link
              fedilink
              English
              arrow-up
              3
              arrow-down
              1
              ·
              3 days ago

              Oh don’t get me wrong, I definitely think LLMs are gonna absolutely destroy kids ability to learn anything, including coding if they use it like a teacher

              But for those who use it as a tool to build and do instead of learning, I’m quickly starting to become a strong believer in its usefulness