Please remove it if unallowed

I see alot of people in here who get mad at AI generated code and I am wondering why. I wrote a couple of bash scripts with the help of chatGPT and if anything, I think its great.

Now, I obviously didnt tell it to write the entire code by itself. That would be a horrible idea, instead, I would ask it questions along the way and test its output before putting it in my scripts.

I am fairly competent in writing programs. I know how and when to use arrays, loops, functions, conditionals, etc. I just dont know anything about bash’s syntax. Now, I could have used any other languages I knew but chose bash because it made the most sense, that bash is shipped with most linux distros out of the box and one does not have to install another interpreter/compiler for another language. I dont like Bash because of its, dare I say weird syntax but it made the most sense for my purpose so I chose it. Also I have not written anything of this complexity before in Bash, just a bunch of commands in multiple seperate lines so that I dont have to type those one after another. But this one required many rather advanced features. I was not motivated to learn Bash, I just wanted to put my idea into action.

I did start with internet search. But guides I found were lacking. I could not find how to pass values into the function and return from a function easily, or removing trailing slash from directory path or how to loop over array or how to catch errors that occured in previous command or how to seperate letter and number from a string, etc.

That is where chatGPT helped greatly. I would ask chatGPT to write these pieces of code whenever I encountered them, then test its code with various input to see if it works as expected. If not, I would ask it again with what case failed and it would revise the code before I put it in my scripts.

Thanks to chatGPT, someone who has 0 knowledge about bash can write bash easily and quickly that is fairly advanced. I dont think it would take this quick to write what I wrote if I had to do it the old fashioned way, I would eventually write it but it would take far too long. Thanks to chatGPT I can just write all this quickly and forget about it. If I want to learn Bash and am motivated, I would certainly take time to learn it in a nice way.

What do you think? What negative experience do you have with AI chatbots that made you hate them?

  • AreaKode@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    I’ve found it to be extremely helpful in coding. Instead of trying to read huge documentation pages, I can just have a chatbot read it and tell me the answer. My coworker has been wanting to learn Powershell. Using a chatbot, his understanding of the language has greatly improved. A chatbot can not only give you the answer, but it can break down how it reached that conclusion. It can be a very useful learning tool.

    • yeehaw@lemmy.ca
      link
      fedilink
      English
      arrow-up
      0
      ·
      10 days ago

      I’ve been using it for CLI syntax and code for a while now. It’s not always right but it definitely helps in getting you almost all the way there when it doesn’t. I will continue to use it 😁

        • yeehaw@lemmy.ca
          link
          fedilink
          English
          arrow-up
          0
          ·
          10 days ago

          Chatgpt all versions. I don’t know. I use it a lot and I just know it’s been wrong. Powershell comes to mind. And juniper srx syntax. And Alcatel.

  • boatswain@infosec.pub
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    As a cybersecurity guy, it’s things like this study, which said:

    Overall, we find that participants who had access to an AI assistant based on OpenAI’s codex-davinci-002 model wrote significantly less secure code than those without access. Additionally, participants with access to an AI assistant were more likely to believe they wrote secure code than those without access to the AI assistant.

    • eerongal@ttrpg.network
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      10 days ago

      FWIW, at this point, that study would be horribly outdated. It was done in 2022, which means it probably took place in early 2022 or 2021. The models used for coding have come a long way since then, the study would essentially have to be redone on current models to see if that’s still the case.

      The people’s perceptions have probably not changed, but if the code is actually insecure would need to be reassessed

      • sugar_in_your_tea@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        0
        ·
        9 days ago

        I think it’s more appalling because they should have assumed this was early tech and therefore less trustworthy. If anything, I’d expect more people to believe their code is secure today using AI than back in 2021/2022 because the tech is that much more mature.

        I’m guessing an LLM will make a lot of noob mistakes, especially in languages like C(++) where a lot of care needs to be taken for memory safety. LLMs don’t understand code, they just look at a lot of samples of existing code, and a lot of code available on the internet is terrible from a security and performance perspective. If you’re writing it yourself, hopefully you’ve been through enough code reviews to catch the more common mistakes.

      • boatswain@infosec.pub
        link
        fedilink
        English
        arrow-up
        0
        ·
        edit-2
        10 days ago

        Sure, but to me that means the latest information is that AI assistants help produce insecure code. If someone wants to perform a study with more recent models to show that’s no longer the case, I’ll revisit my opinion. Until then, I’m assuming that the study holds true. We can’t do security based on “it’s probably fine now.”

  • HakFoo@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    My objections:

    1. It doesn’t adequately indicate “confidence”. It could return “foo” or “!foo” just as easily, and if that’s one term in a nested structure, you could spend hours chasing it.
    2. So many hallucinations-- inventing methods and fields from nowhere, even in an IDE where they’re tagged and searchable.

    Instead of writing the code now, you end up having to review and debug it, which is more work IMO.

  • tal@lemmy.today
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    10 days ago

    I don’t think that the current approaches being used by generative AIs are sufficient to reliably produce correct code; I think that they’re more-amenable to human-consumable output (and even there, I’m much more enthusiastic about their use for images than text, as things stand). A human needs approximately-correct material to cue their brain; CPUs are more particular.

    We’ll probably get there, in the same sense that we can ultimately produce human-level AI for anything, but I think that it’ll entail higher-level reasoning about a problem, which present generative text approaches don’t do.

    I did start with internet search…I could not find how to pass values into the function and return from a function easily,

    So, now, this I have a hard time with.

    When I search for “pass value function bash”, this is the first page I get, which clearly shows an example:

    https://stackoverflow.com/questions/6212219/passing-parameters-to-a-bash-function

    This isn’t where I’d consider generative AI to be a useful example; it’s something that there will be existing material already readily-available via a search.

    The other issue with using generative AI for coding is that for taking pre-existing code for common tasks and using it in multiple programs, we already have an approach: use libraries. That way code gets maintained and such, but doesn’t need to be reimplemented by humans over-and-over.

    Say someone says “I need linked-list code”. Okay, I mean, that’s a pretty common, plain Jane thing to need.

    But if you use a library, and there’s a bug in that code, and it gets fixed, then the bugfix propagates when you update to a newer library. If you generate a linked-list implementation, even if you wind up with working linked-list code at the end, then that isn’t gonna happen.

  • cum@lemmy.cafe
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    It’s a tool just like everything else, but people are just now sobering up after all the hype that it’s incredibly wrong a lot.

  • gandalf_der_12te@lemmy.blahaj.zone
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    People are in denial. AI is going to take programmer’s jobs away, and programmers perceive AI as a natural enemy and a threat. That is why they want to discredit it in any way possible.

    Honestly, I’ve used chatGPT for a hundred tasks, and it has always resulted in acceptable, good-quality work. I’ve never (!) encountered chatGPT making a grave or major error in any of the questions that I asked it (physics and material sciences).

  • socsa@piefed.social
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    Because most people on Lemmy have never actually had to write code professionally.

  • unmagical@lemmy.ml
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    It gives a false sense of security to beginner programmers and doesn’t offer a more tailored solution that a more practiced programmer might create. This can lead to a reduction in code quality and can introduce bugs and security holes over time. If you don’t know the syntax of a language how do you know it didn’t offer you something dangerous? I have copilot at work and the only thing I actually accept its suggestions for now are writing log statements and populating argument lists. While those both still require review they are generally faster than me typing them out. Most of the rest of what it gives me is undesired: it’s either too verbose, too hard to read, or just does something else entirely.

  • tabular@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    If the AI was trained on code that people permitted it to be freely shared then go ahead. Taking code and ignoring the software license is largely considered a dick-move, even by people who use AI.

    Some people choose a copyleft software license to ensure users have software freedom, and this AI (a math process) circumvents that. [A copyleft license makes it so that you can use the code if you agree to use the same license for the rest of the program - therefore users get the same rights you did]

  • MacStache@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    For me it’s because if the AI does all the work the person “coding” won’t learn anything. Thus when a problem does arise (i.e. the AI not being able to fix a simple mistake it made) no one involved has the means of fixing it.

    • oldfart@lemm.ee
      link
      fedilink
      English
      arrow-up
      0
      ·
      10 days ago

      But I don’t want to learn. I want the machine to free me from tedious tasks I already know how to do. There’s no learning experience in creating a Wordpress plugin or a shell script.

  • kibiz0r@midwest.social
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    Basically this: Flying Too High: AI and Air France Flight 447

    Description

    Panic has erupted in the cockpit of Air France Flight 447. The pilots are convinced they’ve lost control of the plane. It’s lurching violently. Then, it begins plummeting from the sky at breakneck speed, careening towards catastrophe. The pilots are sure they’re done-for.

    Only, they haven’t lost control of the aircraft at all: one simple manoeuvre could avoid disaster…

    In the age of artificial intelligence, we often compare humans and computers, asking ourselves which is “better”. But is this even the right question? The case of Air France Flight 447 suggests it isn’t - and that the consequences of asking the wrong question are disastrous.

  • leftzero@lemmynsfw.com
    link
    fedilink
    English
    arrow-up
    0
    ·
    10 days ago

    The other day we were going over some SQL query with a younger colleague and I went “wait, what was the function for the length of a string in SQL Server?”, so he typed the whole question into chatgpt, which replied (extremely slowly) with some unrelated garbage.

    I asked him to let me take the keyboard, typed “sql server string length” into google, saw LEN in the except from the first result, and went on to do what I’d wanted to do, while in another tab chatgpt was still spewing nonsense.

    LLMs are slower, several orders of magnitude less accurate, and harder to use than existing alternatives, but they’re extremely good at convincing their users that they know what they’re doing and what they’re talking about.

    That causes the people using them to blindly copy their useless buggy code (that even if it worked and wasn’t incomplete and full of bugs would be intended to solve a completely different problem, since users are incapable of properly asking what they want and LLMs would produce the wrong code most of the time even if asked properly), wasting everyone’s time and learning nothing.

    Not that blindly copying from stack overflow is any better, of course, but stack overflow or reddit answers come with comments and alternative answers that if you read them will go a long way to telling you whether the code you’re copying will work for your particular situation or not.

    LLMs give you none of that context, and are fundamentally incapable of doing the reasoning (and learning) that you’d do given different commented answers.

    They’ll just very convincingly tell you that their code is right, correct, and adequate to your requirements, and leave it to you (or whoever has to deal with your pull requests) to find out without any hints why it’s not.

    • JasonDJ@lemmy.zip
      link
      fedilink
      English
      arrow-up
      0
      ·
      9 days ago

      This is my big concern…not that people will use LLMs as a useful tool. That’s inevitable. I fear that people will forget how to ask questions and learn for themselves.

      • sugar_in_your_tea@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        0
        ·
        9 days ago

        Exactly. Maybe you want the number of unicode code points in the string, or perhaps the byte length of the string. It’s unclear what an LLM would give you, but the docs would clearly state what that length is measuring.

        Use LLMs to come up with things to look up in the official docs, don’t use it to replace reading docs. As the famous Russian proverb goes: trust, but verify. It’s fine to trust what an LLM says, provided you also go double check what it says in more official docs.

    • MrScottyTay@sh.itjust.works
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      9 days ago

      I’ve been finding it a lot harder recently to find what I’m looking for when it comes to coding knowledge on search engines. I feel with an llm i can give it the wider context and it figures it exactly the sort of things I’m trying to find. Even more useful with trying to understand a complex error message you haven’t seen before.

      That being said. LLMs are not where my searching ends. I check to see where it got the information from so I can read the actual truth and not what it has conjured up.

      • leftzero@lemmynsfw.com
        link
        fedilink
        English
        arrow-up
        0
        ·
        edit-2
        9 days ago

        I’ve been finding it a lot harder recently to find what I’m looking for when it comes to coding knowledge on search engines

        Yeah, the enshittification has been getting worse and worse, probably because the same companies making the search engines are the ones trying to sell you the LLMs, and the only way to sell them is to make the alternatives worse.

        That said, I still manage to find anything I need much faster and with less effort than dealing with an LLM would take, and where an LLM would simply get me a single answer (which I then would have to test and fix), while a search engine will give me multiple commented answers which I can compare and learn from.

        I remembered another example: I was checking a pull request and it wouldn’t compile; the programmer had apparently used an obscure internal function to check if a string was empty instead of string.IsNullOrWhitespace() (in C# internal means “I designed my classes wrong and I don’t have time to redesign them from scratch; this member should be private or protected, but I need to access it from outside the class hierarchy, so I’ll allow other classes in the same assembly to access it, but not ones outside of the assembly”; similar use case as friend in c++; it’s used a lot in standard .NET libraries).

        Now, that particular internal function isn’t documented practically anywhere, and being internal can’t be used outside its particular library, so it wouldn’t pop up in any example the coder might have seen… but .NET is open source, and the library’s source code is on GitHub, so chatgpt/copilot has been trained on it, so that’s where the coder must have gotten it from.

        The thing, though, is that LLM’s being essentially statistic engines that’ll just pop up the most statistically likely token after a given sequence of tokens, they have no way whatsoever to “know” that a function is internal. Or private, or protected, for that matter.

        That function is used in the code they’ve been trained on to figure if a string is empty, so they’re just as likely to output it as string.IsNullOrWhitespace() or string.IsNullOrEmpty().

        Hell, if(condition) and if(!condition) are probably also equally likely in most places… and I for one don’t want to have to debug code generated by something that can’t tell those apart.

        • MrScottyTay@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          0
          ·
          9 days ago

          If you know what you need to find, then yeah search engines are still good. But as a tool for discovery they’re massively shit now. You often need to be super specific to get what you want and almost at that point you already know it, you just need a reminder.

          • leftzero@lemmynsfw.com
            link
            fedilink
            English
            arrow-up
            0
            ·
            9 days ago

            Are search engines worse than they used to be?

            Definitely.

            Am I still successfully using them several times a day to learn how to do what I want to do (and to help colleagues who use LLMs instead of search engines learn how to do what they want to do once they get frustrated enough to start swearing loudly enough for me to hear them)?

            Also yes. And it’s not taking significantly longer than it did when they were less enshittified.

            Are LLMs a viable alternative to search engines, even as enshittified as they are today?

            Fuck, no. They’re slower, they’re harder and more cumbersome to use, their results are useless on a good day and harmful on most, and they give you no context or sources to learn from, so best case scenario you get a suboptimal partial buggy solution to your problem which you can’t learn anything useful from (even worse, if you learn it as the correct solution you’ll never learn why it’s suboptimal or, more probably, downright harmful).

            If search engines ever get enshittified to the point of being truly useless, the alternative aren’t LLMs. The alternative is to grab a fucking book (after making sure it wasn’t defecated by an LLM), like we did before search engines were a thing.

            • MrScottyTay@sh.itjust.works
              link
              fedilink
              English
              arrow-up
              0
              ·
              9 days ago

              Cool I’ll just try and find which book i need to read it from the millions and millions of books.

              I haven’t got an issue with reading books and whatnot. For coding specifically I always prefer to read documentation. But if I don’t know what is needed for my current use case and search isn’t helping. I’m not going to know where to begin. LLMs at least give me a jumping off point. They are not my be all and end all.

              Discoverability of new tools and libraries via search is awful. Through LLMs, it’s passable to point you in the right direction.