45
submitted 9 hours ago by [email protected] to c/[email protected]

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?

top 50 comments
sorted by: hot top controversial new old
[-] [email protected] 7 points 1 hour 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.

[-] [email protected] 11 points 2 hours ago

People who use LLMs to write code incorrectly perceived their code to be more secure than code written by expert humans.

https://arxiv.org/abs/2211.03622

[-] [email protected] 10 points 3 hours ago
  • AI Code suggestions will guide you to making less secure code, not to mention often being lower quality in other ways.
  • AI code is designed to look like it fits, not be correct. Sometimes it is correct. Sometimes it’s close but has small errors. Sometimes it looks right but is significantly wrong. Personally I’ve never gotten ChatGPT to write code without significant errors for more than trivially small test cases.
  • You aren’t learning as much when you have ChatGPT do it for you, and what you do learn is “this is what chat gpt did and it worked last time” and not “this is what the problem is and last time this is the solution I came up with and this is why that worked”. In the second case you are far better equipped to tackle future problems, which won’t be exactly the same.

All that being said, I do think there is a place for chat GPT in simple queries like asking about syntax for a language you don’t know. But take every answer it gives you with a grain of salt. And if you can find documentation I’d trust that a lot more.

[-] [email protected] 9 points 3 hours 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.

[-] [email protected] -1 points 1 hour ago

A lot of people spent many many nights wasting away at learning some niche arcane knowledge and now are freaking out that a kid out of college can do what they can with a cool new machine. Maybe not fully what they do but 70% there and that makes them so hateful. They'll pull out all these articles and studies but they're just afraid to face the reality that their time and life was wasted and how unfair life can be

[-] [email protected] 1 points 12 minutes ago

Who hurt you?

[-] [email protected] 14 points 4 hours 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]

[-] [email protected] 0 points 2 hours ago

I hate big tech too, but I'm not really sure how the GPL or MIT licenses (for example) would apply. LLMs don't really memorize stuff like a database would and there are certain (academic/research) domains that would almost certainly fall under fair use. LLMs aren't really capable of storing the entire training set, though I admit there are almost certainly edge cases where stuff is taken verbatim.

I'm not advocating for OpenAI by any means, but I'm genuinely skeptical that most copyleft licenses have any stake in this. There's no static linking or source code distribution happening. Many basic algorithms don't follow under copyright, and, in practice, stack overflow code is copy/pasted all the time without that being released under any special license.

If your code is on GitHub, it really doesn't matter what license you provide in the repository -- you've already agreed to allowing any user to "fork" it for any reason whatsoever.

[-] [email protected] 3 points 2 hours ago

Be it a complicated neural network or database matters not. It output portions of the code used as input by design.

If you can take GPL code and "not" distribute it via complicated maths then that circumvents it. That won't do, friendo.

[-] [email protected] 0 points 1 hour ago

For example, if I ask it to produce python code for addition, which GPL'd library is it drawing from?

I think it's clear that the fair use doctrine no longer applies when OpenAI turns it into a commercial code assistant, but then it gets a bit trickier when used for research or education purposes, right?

I'm not trying to be obtuse-- I'm an AI researcher who is highly skeptical of AI. I just think the imperfect compression that neural networks use to "store" data is a bit less clear than copy/pasting code wholesale.

would you agree that somebody reading source code and then reimplenting it (assuming no reverse engineering or proprietary source code) would not violate the GPL?

If so, then the argument that these models infringe on right holders seems to hinge on the verbatim argument that their exact work was used without attribution/license requirements. This surely happens sometimes, but is not, in general, a thing these models are capable of since they're using loss-y compression to "learn" the model parameters. As an additional point, it would be straightforward to then comply with DMCA requests using any number of published "forced forgetting" methods.

Then, that raises a further question.

If I as an academic researcher wanted to make a model that writes code using GPL'd training data, would I be in compliance if I listed the training data and licensed my resulting model under the GPL?

I work for a university and hate big tech as much as anyone on Lemmy. I am just not entirely sure GPL makes sense here. GPL 3 was written because GPL 2 had loopholes that Microsoft exploited and I suspect their lawyers are pretty informed on the topic.

[-] [email protected] 15 points 5 hours ago

One point that stands out to me is that when you ask it for code it will give you an isolated block of code to do what you want.

In most real world use cases though you are plugging code into larger code bases with design patterns and paradigms throughout that need to be followed.

An experienced dev can take an isolated code block that does X and refactor it into something that fits in with the current code base etc, we already do this daily with Stackoverflow.

An inexperienced dev will just take the code block and try to ram it into the existing code in the easiest way possible without thinking about if the code could use existing dependencies, if its testable etc.

So anyway I don't see a problem with the tool, it's just like using Stackoverflow, but as we have seen businesses and inexperienced devs seem to think it's more than this and can do their job for them.

[-] [email protected] 28 points 6 hours ago

If you’re a seasoned developer who’s using it to boilerplate / template something and you’re confident you can go in after it and fix anything wrong with it, it’s fine.

The problem is it’s used often by beginners or people who aren’t experienced in whatever language they’re writing, to the point that they won’t even understand what’s wrong with it.

If you’re trying to learn to code or code in a new language, would you try to learn from somebody who has only half a clue what he’s doing and will confidently tell you things that are objectively wrong? Thats much worse than just learning to do it properly yourself.

[-] [email protected] 20 points 7 hours 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.

[-] [email protected] 82 points 9 hours ago

A lot of the criticism comes with AI results being wrong a lot of the time, while sounding convincingly correct. In software, things that appear to be correct but are subtly wrong leads to errors that can be difficult to decipher.

Imagine that your AI was trained on StackOverflow results. It learns from the questions as well as the answers, but the questions will often include snippets of code that just don't work.

The workflow of using AI resembles something like the relationship between a junior and senior developer. The junior/AI generates code from a spec/prompt, and then the senior/prompter inspects the code for errors. If we remove the junior from the equation to replace with AI, then entry level developer jobs are slashed, and at the same time people aren't getting the experience required to get to the senior level.

Generally speaking, programmers like to program (many do it just for fun), and many dislike review. AI removes the programming from the equation in favour of review.

Another argument would be that if I generate code that I have to take time to review and figure out what might be wrong with it, it might just be quicker and easier to write it correctly the first time

Business often doesn't understand these subtleties. There's a ton of money being shovelled into AI right now. Not only for developing new models, but for marketing AI as a solution to business problems. A greedy executive that's only looking at the bottom line and doesn't understand the solution might be eager to implement AI in order to cut jobs. Everyone suffers when jobs are eliminated this way, and the product rarely improves.

[-] [email protected] 30 points 8 hours ago

Generally speaking, programmers like to program (many do it just for fun), and many dislike review. AI removes the programming from the equation in favour of review.

This really resonated with me and is an excellent point. I'm going to have to remember that one.

load more comments (5 replies)
[-] [email protected] 40 points 9 hours 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.

load more comments (2 replies)
[-] [email protected] 6 points 6 hours 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.

load more comments (2 replies)
[-] [email protected] 22 points 9 hours ago

I agree AI is a godsend for non coders and amateur programmers who need a quick and dirty script. As a professional, the quality of code is oftentimes 💩 and I can write it myself in less time than it takes to describe it to an AI.

[-] [email protected] 3 points 3 hours ago

i love it when the AI declares and sets important sounding variables it then never uses 🙄

[-] [email protected] 4 points 8 hours ago

I think you’ve hit the nail on the head. I am not a coder but using chatGPT I was able to take someone else’s simple program and modify for my own needs within just a few hours of work. It’s definitely not perfect and you still need to put in some work to get your program to run exactly the way you want it to but it’s using chatGPT is a good place to start for beginners, as long as they understand that it’s not a magic tool.

[-] [email protected] 3 points 8 hours ago* (last edited 4 hours ago)

I think the process of explaining what you want to an AI can often be helpful. Especially given the number of times I've explained things to junior developers and they've said they understood completely, but then when I see what they wrote they clearly didn't.

Explaining to an AI is a pretty good test of how well the stories and comments are written.

[-] [email protected] 12 points 8 hours ago

It doesn't pass judgment. It just knows what "looks" correct. You need a trained person to discern that. It's like describing symptoms to WebMD. If you had a junior doctor using WebMD, how comfortable would you be with their assessment?

[-] [email protected] 17 points 9 hours 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.

[-] [email protected] 3 points 6 hours ago

I stopped using it after the third time it just wholesale made up powershell cmdlets that don’t exist.

Until it has fidelity it’s just a toy.

[-] [email protected] 10 points 8 hours ago

Lots of good comments here. I think there's many reasons, but AI in general is being quite hated on. It's sad to me - pre-GPT I literally researched how AI can be used to help people be more creative and support human workflows, but our pipelines around the AI are lacking right now. As for the hate, here's a few perspectives:

  • Training data is questionable/debatable ethics,
  • Amateur programmers don't build up the same "code muscle memory",
  • It's being treated as a sole author (generate all of this code for me) instead of like a ping-pong pair programmer,
  • The time saved writing code isn't being used to review and test the code more carefully than it was before,
  • The AI is being used for problem solving, where it's not ideal, as opposed to code-from-spec where it's much better,
  • Non-Local AI is scraping your (often confidential) data,
  • Environmental impact of the use of massive remote LLMs,
  • Can be used (according to execs, anyways) to replace entry level developers,
  • Devs can have too much faith in the output because they have weak code review skills compared to their code writing skills,
  • New programmers can bypass their learning and get an unrealistic perspective of their understanding; this one is most egregious to me as a CS professor, where students and new programmers often think the final answer is what's important and don't see the skills they strengthen along the way to the answer.

I like coding with local LLMs and asking occasional questions to larger ones, but the code on larger code bases (with these small, local models) is often pretty non-sensical, but improves with the right approach. Provide it documented functions, examples of a strong and consistent code style, write your test cases in advance so you can verify the outputs, use it as an extension of IDE capabilities (like generating repetitive lines) rather than replacing your problem solving.

I think there is a lot of reasons to hate on it, but I think it's because the reasons to use it effectively are still being figured out.

Some of my academic colleagues still hate IDEs because tab completion, fast compilers, in-line documentation, and automated code linting (to them) means you don't really need to know anything or follow any good practices, your editor will do it all for you, so you should just use vim or notepad. It'll take time to adopt and adapt.

[-] [email protected] 3 points 5 hours ago

Spot-on.

I spend a lot of time training people how to properly review code, and the only real way to get good at it is by writing and reviewing a lot of code.

With an LLM, it trains on a lot of code, but it does no review per-se… unlike other ML systems, there’s no negative and positive feedback systems in place to improve quality.

Unfortunately, AI is now equated with LLM and diffusion models instead of machine learning in general.

[-] [email protected] 16 points 9 hours 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.

[-] [email protected] 6 points 9 hours ago

It's great for regurgitating pre written text. For generating new or usable code it's largely useless. It doesn't have an actual understanding of what it says. It can recombine information and elements its seen before. But not generate anything truly unique.

load more comments (3 replies)
load more comments (8 replies)
[-] [email protected] -1 points 3 hours ago

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

[-] [email protected] 3 points 6 hours ago

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.

Last time I checked (because I was writing Bash scripts based on the same assumption), Python was actually present on more Linux systems out of the box than Bash.

[-] [email protected] 10 points 9 hours ago

Many lazy programmers may just copy paste without thinking too much about the quality of generated code. The other group of person who oppose it are those who think it will kill the programmer job

[-] [email protected] 10 points 9 hours ago

There is an enormous difference between:

rm -rf / path/file

vs.

rm -rf /path/file

[-] [email protected] 7 points 9 hours ago

Many lazy programmers may just copy paste without thinking too much about the quality of generated code

Tbf, they've been doing that LONG before AI came along

[-] [email protected] 1 points 1 hour ago

Sure, but if you're copying from stack overflow or reddit and ignore the dozens of comments telling you why the code you're copying is wrong for your use case, that's on you.

An LLM on the other hand will confidently tell you that its garbage is perfect and will do exactly what you asked for, and leave you to figure out why it doesn't by yourself, without any context.

An inexperienced programmer who's willing to learn won't fall for the first case and will actually learn from the comments and alternative answers, but will be completely lost if the hallucinating LLM is all they've got.

[-] [email protected] 3 points 7 hours ago

I use it as a time-saving device. The hardest part is spotting when it's not actually saving you time, but costing you time in back-and-forth over some little bug. I'm often better off fixing it myself when it gets stuck.

I find it's just like having another developer to bounce ideas off. I don't want it to produce 10k lines of code at a time, I want it to be digestible so I can tell if it's correct.

load more comments
view more: next ›
this post was submitted on 21 Sep 2024
45 points (73.7% liked)

Technology

58164 readers
3489 users here now

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related content.
  3. Be excellent to each another!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, to ask if your bot can be added please contact us.
  9. Check for duplicates before posting, duplicates may be removed

Approved Bots


founded 1 year ago
MODERATORS