Live data from Hacker News

I'm tired of fixing customers' AI generated code

medium.com

141–150 of 345 posts

Re: I'm tired of fixing customers' AI generated code

#141
post #92

Earlier quoted context omitted.

LOL, are you kidding me? LLMs including the gpt family copilot uses are very good at sneaking in these sorts of thing.

Show me 1 example.

There's more than one mistake in the code given, and I tried just once.

"Create Python code for iterating a file with a cache."

    class CachedFileIterator:
        def __init__(self, file_path):
            self.file_path = file_path
            self.cache = []  # List to store cashed lines
            self.current_index = 0  # Index for the current line to read

        def _read_lines_from_file(self):
            """Read lines from the file and cache them."""
            with open(self.file_path, 'r') as openFile:
                for line in f:
                    self.cache.append(line.strip())  # Strip newline characters and save to cache

        def __iter__(self):
            """Return the iterator object itself."""
            return self

        def __next__(self):
            """Return the next line in the iteration."""
            if self.current_index 

Re: I'm tired of fixing customers' AI generated code

#142
post #55

I had a related episode at work when my coworker asked me why his seemingly trivial 10 line piece of code was misbehaving inexplicably. It turned out he had two variables `file_name` and `filename` and used one in place of another. I asked him how he ended up with such code, he said he used copilot to create it. Using code from a generative AI without understanding what it does is never a good idea.

And any decent IDE will highlight a variable that is declared but unused. We already have "artificial intelligence" in the form of IDEs, linters, compilers, etc. but some people apparently think we should just throw it all away now that we have LLMs.

Re: I'm tired of fixing customers' AI generated code

#143
post #55

I had a related episode at work when my coworker asked me why his seemingly trivial 10 line piece of code was misbehaving inexplicably. It turned out he had two variables `file_name` and `filename` and used one in place of another. I asked him how he ended up with such code, he said he used copilot to create it. Using code from a generative AI without understanding what it does is never a good idea.

We hired a new guy at work. In one of his first tasks he had chosen to write some bash, and it was pure nonsense. I mean it contained things like: if [ -z "${Var}+x" ] Where I can see what the author was trying to do, but the code is just wrong. I dont mind people not knowing stuff, especially when it's essentially Bash trivia. But what broke my heart was when I pointed out the problem, linked to the documentation, b…

Everyone working with shell scripts should know shellcheck

Re: I'm tired of fixing customers' AI generated code

#144
post #55

I had a related episode at work when my coworker asked me why his seemingly trivial 10 line piece of code was misbehaving inexplicably. It turned out he had two variables `file_name` and `filename` and used one in place of another. I asked him how he ended up with such code, he said he used copilot to create it. Using code from a generative AI without understanding what it does is never a good idea.

We hired a new guy at work. In one of his first tasks he had chosen to write some bash, and it was pure nonsense. I mean it contained things like: if [ -z "${Var}+x" ] Where I can see what the author was trying to do, but the code is just wrong. I dont mind people not knowing stuff, especially when it's essentially Bash trivia. But what broke my heart was when I pointed out the problem, linked to the documentation, b…

And you didn't sack him?

Re: I'm tired of fixing customers' AI generated code

#145

> Often this takes the form of trying to access an endpoint that does not exist, or read a property off the API response that does not exist. After probing a bit more, my suspicions are usually confirmed — ChatGPT hallucinated that endpoint or property In some cases, you might be able to use this to your advantage to improve the product. When working with third-party APIs, I've often run into situations where my code…

> It's possible that ChatGPT is "thinking" the same thing here; that most APIs have an X endpoint to make a task easier, so surely yours does too?

While this is possible, I would caution with an anecdote from my ongoing side project of "can I use it to make browser games?", in which 3.5 would create a reasonable Vector2D class and then get confused and try to call .mul() and .sub() instead of the .multiply() and .subtract() that it had just created.

Sometimes it's exceptionally insightful, other times it needs to RTFM.

Re: I'm tired of fixing customers' AI generated code

#146
post #118

Earlier quoted context omitted.

I don’t see how typing relates to this.

Probably one of the variables is undefined, and static typing could catch that.

It's not the language, it's the IDE and laziness. They're doing this in notepad or maybe VSCode and don't have anything configured for highlighting or checking. Heck they probably don't even know how to interpret the error message saying "file_name is not declared".

I'm the first to bash JS, but this is not a JS issue. It's 100% a "bad and lazy" human actor that is throwing spaghetti on the wall to see what sticks. In this case, they have a minigun cannon called ChatGPT/CoPilot that is letting them do more of it than what they used to.

Re: I'm tired of fixing customers' AI generated code

#147
post #3

I'm always a little surprised at how many people out there want to develop software yet haven't put in the effort to gain even the most basic computer nerd programming chops. You see this all the time in the more newbie-friendly game engine communities. Maybe you don't want to pursue a career in software, but anyone can spend a week learning Python or JavaScript. I suspect/hope a lot of these people are just kids who…

I am not, I see it happening even within companies. They figure that for some junior tech related roles they don't need to hire people with the education and just teach them in house. Often not developing itself, but things like automated tests in a QA role.

The result is people that have no technical background, no real interest in it either, no basic framework to start from learning to use a specific set of tools and a very basic understanding of programming.

Re: I'm tired of fixing customers' AI generated code

#148
post #55

I had a related episode at work when my coworker asked me why his seemingly trivial 10 line piece of code was misbehaving inexplicably. It turned out he had two variables `file_name` and `filename` and used one in place of another. I asked him how he ended up with such code, he said he used copilot to create it. Using code from a generative AI without understanding what it does is never a good idea.

> Using code from a generative AI without understanding what it does is never a good idea.

True, but the anecdote doesn't prove the point.

It's easy to miss that kind of difference even if you wrote the code yourself.

Re: I'm tired of fixing customers' AI generated code

#149

Someone mentioned "hallucination-based API design" on twitter (I cannot find it now). It's designing API by LLM hallucination. If there is a common hallucination API call, just add that API. This will make the API more "friendly" and resemble common similar APIs. Considering that LLM can hallucinate in different ways unpredictably, not sure whether it will work in practice.

I doubt LLM hallucinations will produce good secure code.

In my opinion, using code from LLMs, which might see your program come to life a bit quicker, will only enhance the time needed for debugging and testing, as there might be bugs and problems in there ranging from trivial things (unused variables) to very subtle and hard to find logic issues which require a deeper knowledge of the libraries and frameworks cobbled together by an LLM.

Additionally, it takes out a lot of the knowledge of these things in the long run, so people will find it more and more challenging to properly do this testing and debugging phase.

Re: I'm tired of fixing customers' AI generated code

#150
post #5

Hilariously, the target market for the author's API seems to be the same as the top post on HN today[0]: "traders". I think amateur "trading" attracts a specific brand of idiot that is high/left on the Dunning Kruger curve. While taking money from idiots is a viable (even admirable) business strategy, you may want to fully automate customer service to retain your sanity. [0]: https://news.ycombinator.com/item?id=4130…

Yeah the customer demographic here likely does worsen the situation. Although I am sure that this is happening elsewhere as well.
Post reply on HN