News for hackers. Stuff that matters.
Re:I'm Tired of Fixing Customers' AI Generated Code by alexeiz on Thursday August 22, 2024 @12:01AM (#41316705)
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.
Re:I'm Tired of Fixing Customers' AI Generated Code by frumper on Thursday August 22, 2024 @12:18AM (#41316775)
I knew a guy that made a good living as a freelance web developer decades ago. He would pretty much just copy and paste code from tutorials or stack overflow and had no real idea how anything worked. Using code without understanding it is never a good idea, it doesn’t need to be from AI for that to be true.
Re:I'm Tired of Fixing Customers' AI Generated Code by f6v on Thursday August 22, 2024 @03:11AM (#41317591)
Or maybe you’re just exaggerating. I’ve done my fair share of copy pasting and it never worked to just do it without understanding what’s going on.

I think the problem with “AI” code is that many people have almost a religions belief. There’re weirdos on internet who say that AGI is couple years away. And by extension current AI models are seen as something incapable of making a mistake when writing code.

Re:I'm Tired of Fixing Customers' AI Generated Code by n4r9 on Thursday August 22, 2024 @03:33AM (#41317692)
The other downside to AI code vs stackoverflow is that a stackoverflow post can be updated, or a helpful reply might point out the error. With the advent of LLMs we may be losing this communal element of learning and knowledge-sharing.
Re:I'm Tired of Fixing Customers' AI Generated Code by Piskvorrr on Thursday August 22, 2024 @04:02AM (#41317885)
We aren't. LLMs may have been useful for a moment in time, before the trick "it's now MY OWN creation, no IP strings attached - when it comes through the plagiarism machine" became apparent, and before the models started eating their own tail. Now they're just spiralling down, and it will IMNSHO take something else than an iterative "a future version will surely fix this, One Day, have faith."
Re:I'm Tired of Fixing Customers' AI Generated Code by n4r9 on Thursday August 22, 2024 @04:12AM (#41317931)
There are signs of a decline in people asking and answering questions on sites like stack exchange: https://meta.stackexchange.com/questions/387278/has-stack-ex...

So I hope you're right, but the evidence is currently that you're wrong. Let's see how it plays out, I suppose.

Re:I'm Tired of Fixing Customers' AI Generated Code by Piskvorrr on Thursday August 22, 2024 @04:53AM (#41318129)
- Which might be a different matter: of specifically SE declining. (A very different, and long-running, tragedy, but one that began long before the current AI boom and prompted by very different, non-technical issues.)

- That said, surely traffic will decline for Q&A sites. "How do I connect tab A into slot B" is something that people are likely to query LLMs for; the response will surely sound authoritative, and could be even correct. That's definitely a task where LLMs could help: common questions that have been asked many times (and as such, are likely to be well-answered in the human-made training data). A 20001st question of "how do I right-align a paragraph in HTML" has not been posted? Good. Rote tasks are well-suited to automation. (Which, again, brings us back to the issue "how to distinguish the response quality?")

Re:I'm Tired of Fixing Customers' AI Generated Code by jtbayly on Thursday August 22, 2024 @12:13PM (#41321813)
But what happens with the next generation of questions? The reason LLMs can answer how to right-align a paragraph in HTML is at least in part because it has been asked and answered publicly so many times.

Now imagine that HTMZ comes along and people just go straight to asking how to full justify text in HTMZ for their smart bucket. What happens? I doubt we’ll get good answers.

It feels like the test of whether LLMs can stay useful is actually whether we can stop them from hallucinating API endpoints. If we could feed the rules of a language or API into the LLM and have it actually reason from that to code, then my posed problem would be solved. But I don’t think that’s how they fundamentally work.

Re:I'm Tired of Fixing Customers' AI Generated Code by mhuffman on Thursday August 22, 2024 @02:53PM (#41323325)
>Now imagine that HTMZ comes along and people just go straight to asking how to full justify text in HTMZ for their smart bucket. What happens? I doubt we’ll get good answers.

So, I think the answer is that since all useful data is already in a LLM somewhere all new data will be stolen/scraped and inserted in real time. So if real people are answering the question it will work as normal. The real question is what happens when people are trying to mine karma by answering questions using an LLM that is hallucinating. We have seen such with the Bug Bounty silliness going on.

Re:I'm Tired of Fixing Customers' AI Generated Code by davidthewatson on Thursday August 22, 2024 @02:28PM (#41323110)
I upvoted your comment because I'm afraid you may be correct. I say, "afraid" because I can remember the day when a member of my team was fired for copy pasta from SO with little, if any understanding, into "production" code.

The problem, of course, is that this might work once in a while for low hanging fruit, until the web inherited things like DICOM and we now have medical imaging in the web browser (I've heard in Apple Vision Pro), where robotics implies the price of unforeseen bugs is not accidental death or dismemberment of one patient, but potentially many.

Re:I'm Tired of Fixing Customers' AI Generated Code by johnnyanmac on Friday August 23, 2024 @01:33PM (#41331057)
I've seen it too. You can get away with a lot of inefficiencies and still technically get the job done.
Re:I'm Tired of Fixing Customers' AI Generated Code by Laakeri on Thursday August 22, 2024 @12:23AM (#41316800)
But he made a good living out of it, so in the end it was a good idea?
Re:I'm Tired of Fixing Customers' AI Generated Code by thephyber on Thursday August 22, 2024 @02:04AM (#41317286)
He may have made a good living, but his customer / employer bought low quality code with lots of tech debt.

That business model only works until customers are sophisticated enough to understand tech debt. In the future, more customers will be less willing to pay the same good wages for low quality code.

Re:I'm Tired of Fixing Customers' AI Generated Code by throwaway2037 on Thursday August 22, 2024 @02:36AM (#41317438)

    > but his customer / employer bought low quality code with lots of tech debt.
Sarcastic reply: Isn't that most tech? Even good (above average) developer produce lots of tech debt and sometimes low quality code.
Re:I'm Tired of Fixing Customers' AI Generated Code by datavirtue on Thursday August 22, 2024 @08:47AM (#41319669)
Yeah, and the business people could not care less. I am on a team taking in millions of dollars from a Delphi Windows app from 1997. Zero tests, horribly mangled business logic embedded in UI handlers. Maintaining that app is not feasible. I'm rebuilding a modern version of it only because it is embarrassing to demo and is such a UX nightmare that our distributor made us commit to a new app.
Re:I'm Tired of Fixing Customers' AI Generated Code by bbarnett on Thursday August 22, 2024 @08:57AM (#41319745)
"Webdev" makes me think of wordpress, which is like planting 20 onions in your backyard, and comparing yourself to a farmer with acres of crops.

I can completely believe someone had no idea what they were doing when copy/pasting, and working on wordpress.

Re:I'm Tired of Fixing Customers' AI Generated Code by prisenco on Thursday August 22, 2024 @12:31AM (#41316843)
It certainly puts a ceiling on a career. And I'd argue it probably gave him a pretty rough shelf life. At some point he has to understand what he's doing.

Unless he's so good at selling his services he can consistently find new clients. And if that's the case, he'd probably kill it in sales.

Re:I'm Tired of Fixing Customers' AI Generated Code by dazzawazza on Thursday August 22, 2024 @01:55AM (#41317248)
I'll bet the ceiling is CTO.
Re:I'm Tired of Fixing Customers' AI Generated Code by fragmede on Thursday August 22, 2024 @12:44AM (#41316891)
sales engineer is quite a lucrative career. don't have to be really good at it, just enough to be useful.
Re:I'm Tired of Fixing Customers' AI Generated Code by snoxy on Thursday August 22, 2024 @04:10AM (#41317918)
Sales engineers have to be good enough to bluff their way through the layers of hyperbole/minor exaggeration/utter bullshit (delete as applicable) the sales team have spun. Whether their conscience gets involved before the deal closes, different question.
Re:I'm Tired of Fixing Customers' AI Generated Code by gizmo686 on Thursday August 22, 2024 @06:54PM (#41324979)
Not at my work. Around here sales engineers just say "this is a proof of concept, X will be different in the final version". Then, after they close the deal, they give us their half implemented feature they developed that none of us heard about before, and tell ys that we need to finish it and include it in the next release.
Re:I'm Tired of Fixing Customers' AI Generated Code by efilife on Thursday August 22, 2024 @01:31AM (#41317129)
Cope. People often make money on things they know nothing about
Re:I'm Tired of Fixing Customers' AI Generated Code by HeyLaughingBoy on Thursday August 22, 2024 @04:27PM (#41324113)
Most people never reach the theoretical ceiling of their careers, so he probably did quite well.
Re:I'm Tired of Fixing Customers' AI Generated Code by Cthulhu_ on Thursday August 22, 2024 @07:04AM (#41318876)
This is a known issue from like the 2000s where there were so many bad PHP tutorials, a lot of SQL injection and XSS etc came from those.
Re:I'm Tired of Fixing Customers' AI Generated Code by jazz9k on Thursday August 22, 2024 @10:45AM (#41320869)
I knew someone similar. They would just get free templates and sell them as a website to customers, with almost no changes, aside from logos and text. Most had no Javascript or css and looked terrible, even by 2005 standards.

His clients were usually older small business owners that just wanted a web presence. His rate was $5000/site.

Within a few years, business dried up and he had to do something completely different.

He also hosted his own smtp server for clients.It was an old server on his cable modem in a dusty garage. I helped him prevent spoofing/relaying a few times, but he kept tinkering with the settings and it would happen all over again.

Re:I'm Tired of Fixing Customers' AI Generated Code by falcor84 on Thursday August 22, 2024 @10:47AM (#41320897)
>a guy that made a good living ... never a good idea

Arguably the term for a bad idea that works is "good idea"

Re:I'm Tired of Fixing Customers' AI Generated Code by macksd on Thursday August 22, 2024 @12:20PM (#41321875)
There are plumbers who make a living but whose work results in leaks in people's homes. They're making a living, but I don't consider the way they work "a good idea".
Re:I'm Tired of Fixing Customers' AI Generated Code by digging on Thursday August 22, 2024 @12:14PM (#41321825)
Or maybe "good" and "bad" aren't useful descriptors in this context.
Re:I'm Tired of Fixing Customers' AI Generated Code by frumper on Thursday August 22, 2024 @11:34AM (#41321435)
That's fair. From a personal perspective it was a good idea. He regularly had sites get compromised though, so for his customers it wasn't always a good product. He generally kept his customers happy though.
Re:I'm Tired of Fixing Customers' AI Generated Code by JKCalhoun on Thursday August 22, 2024 @10:57AM (#41321045)
At least AI comments their code.
Re:I'm Tired of Fixing Customers' AI Generated Code by mooreds on Thursday August 22, 2024 @01:06AM (#41317007)
> Using code from a generative AI without understanding what it does is never a good idea.

Hear hear!

I feel like genAI is turning devs from authors to editors. Anyone who thinks the latter is lesser than the former has not performed both functions. Editing properly, to elevate the meaning of the author, is a worthy and difficult endeavor.

Re:I'm Tired of Fixing Customers' AI Generated Code by FanaHOVA on Thursday August 22, 2024 @01:30AM (#41317124)
Copilot wouldn't make a typo. He just made that up and / or broke the code himself.
Re:I'm Tired of Fixing Customers' AI Generated Code by creesch on Thursday August 22, 2024 @01:59AM (#41317263)
LOL, are you kidding me? LLMs including the gpt family copilot uses are very good at sneaking in these sorts of thing.
Re:I'm Tired of Fixing Customers' AI Generated Code by FanaHOVA on Thursday August 22, 2024 @02:18AM (#41317351)
Show me 1 example.
Re:I'm Tired of Fixing Customers' AI Generated Code by shakna on Thursday August 22, 2024 @03:38AM (#41317719)
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 < len(self.cache):
                result = self.cache[self.current_index]
                self.current_index += 1
                return result
            else:
                # If we reach the end of the cache, we read more lines from the file if necessary
                if len(self.cache) == 0:  # Cache is empty, read file
                    self._read_lines_from_file()
                    
                if self.current_index < len(self.cache):
                    result = self.cache[self.current_index]
                    self.current_index += 1
                    return result
                else:
                    # If still no lines, we stop iteration
                    raise StopIteration

    # Example usage:
    if __name__ == "__main__":
        file_path = 'example.txt'  # Replace with your file path
        
        iterator = CacheingFileIterator(file_path)
        for line in iterator:
            print(line)
Re:I'm Tired of Fixing Customers' AI Generated Code by yifanl on Thursday August 22, 2024 @05:29AM (#41318319)
Garbage code is bad enough, but it's not like people have never had to walk juniors through mistakes before LLMs.

But this is actually so much worse for that same reason - the type of developer who'd submit Copilot output (I can call it that, as it's definitely not code) for a PR is unable to respond to any comment beyond asking Copilot again and wasting everyone's time with 6 more rounds of reviews. I've literally had to write test cases for someone else and told them "You can't ask for another code review until your code passes these."

Re:I'm Tired of Fixing Customers' AI Generated Code by creesch on Thursday August 22, 2024 @07:58AM (#41319260)
Bit of a tangent, though related. It looks like you accidentally stumbled into a version of test driven development ;)

With the big difference obviously being that typically the developer who writes the test also will write the code.

In some situations, this actually makes sense to do with junior developers as part of their training. Where a senior developer sits down with them and write out the tests together, then with the tests as a guide they are thrown into the waters to develop the functionality.

Of course, I suspect that in this case, you were not dealing with a junior. Rather the sort of person who looks at your tests, still is confused and asks for a "quick call" to talk about the tests.

Re:I'm Tired of Fixing Customers' AI Generated Code by cutemonster on Thursday August 22, 2024 @05:57AM (#41318455)
> "You can't ask for another code review until your code passes these."

Such a good idea :-) Maybe for job applications too and any at home work sample tests

Re:I'm Tired of Fixing Customers' AI Generated Code by viraptor on Thursday August 22, 2024 @09:53AM (#41320283)
What do you see as mistakes? I see some weirdness, but the spec is just not complete - there was no requirement for rewinding, multiple users, etc. in the request so it's not implemented.

The only thing I'd call an actual mistake is using an empty list to mean both an empty file and an uninitialised value.

Re:I'm Tired of Fixing Customers' AI Generated Code by shakna on Thursday August 22, 2024 @11:31AM (#41321402)
The file object is named "openFile", but used as "f". The class is defined as "CachedFileIterator", but used as "CacheingFileIterator". That's two typos, before discussing the actual code.
Re:I'm Tired of Fixing Customers' AI Generated Code by yifanl on Thursday August 22, 2024 @10:50AM (#41320943)

    for line in f:
is multiple mistakes in a single line.
Re:I'm Tired of Fixing Customers' AI Generated Code by falcor84 on Thursday August 22, 2024 @11:04AM (#41321127)
What are the mistakes there?
Re:I'm Tired of Fixing Customers' AI Generated Code by yifanl on Thursday August 22, 2024 @12:09PM (#41321776)
f doesn't refer to anything.

iterating over the file object at all instead of just calling self.cache = openFile.readlines() means that calling strip() the line below removes data beyond just the trailing newlines.

Re:I'm Tired of Fixing Customers' AI Generated Code by dpassens on Thursday August 22, 2024 @11:49AM (#41321577)
One is that the variable is called openFile and not f. I don't know enough python to see something else wrong with that but would love to know too, since I've written such a line just last week.
Re:I'm Tired of Fixing Customers' AI Generated Code by galbar on Thursday August 22, 2024 @11:41AM (#41321501)
The most obvious one:

    with open(self.file_path, 'r') as openFile:
        for line in f:
`f` does not exist. It should be `openFile`.
Re:I'm Tired of Fixing Customers' AI Generated Code by harpiaharpyja on Thursday August 22, 2024 @04:53PM (#41324308)
Well, there's also the fact that the entire thing could be replaced with...

    def cached_file_iterator(file_path):
        with open(file_path, 'r') as f:
            lines = [ line.strip() for line in f.readlines() ]
        yield from iter(lines)

    # Example usage:
    if __name__ == "__main__":
        file_path = 'example.txt'  # Replace with your file path
        
        iterator = cached_file_iterator(file_path)
        for line in iterator:
            print(line)

Which is functionally identical and FAR less code to maintain.
Re:I'm Tired of Fixing Customers' AI Generated Code by creesch on Thursday August 22, 2024 @02:30AM (#41317403)
Show me that copilot never makes a mistake or introduces variables that never have been initialized...
Re:I'm Tired of Fixing Customers' AI Generated Code by brigadier132 on Thursday August 22, 2024 @02:32AM (#41317414)
This is a strawman, he never said it didn't make mistakes.
Re:I'm Tired of Fixing Customers' AI Generated Code by creesch on Thursday August 22, 2024 @02:35AM (#41317434)
Oh for crying out loud, I obviously mean these specific mistakes. If you have worked in any capacity with LLMs like this you would have seen them variables or suddenly switch up the convention of how they're written.

Certainly if you are in a conversation mode after a few back and forths this happens from time to time.

I am just not going to spend my time digging to previous prompts of code I might not want to share just to satisfy a random internet person .

Re:I'm Tired of Fixing Customers' AI Generated Code by FanaHOVA on Thursday August 22, 2024 @03:05AM (#41317568)
No, it doesn't certainly happen. An LLM will not, under normal circumstances, give you a code block with misspelled variables. It's easy to intuitively understand why: generating a token with the same variable name is MUCH MORE likely than generating a different one. You probably do not use the tools at all, but subscribe to the cynic internet view of dismissing new tools. Too bad. Have a good rest of your week.
Re:I'm Tired of Fixing Customers' AI Generated Code by fzeroracer on Thursday August 22, 2024 @03:24AM (#41317654)
Not the OP. I have certainly seen LLM coding tools generate blocks of code with misspelled variables and typos. Trying to shove someone into a box of being a cynic because they have had bad personal experiences with tools is a good way to ensure people filter out your opinions.
Re:I'm Tired of Fixing Customers' AI Generated Code by brigadier132 on Thursday August 22, 2024 @02:36AM (#41317442)
The models I've used don't make typos on variable names that already exist in the context. Typos are not the failure mode, this is literally the easiest text prediction task they can do.
Re:I'm Tired of Fixing Customers' AI Generated Code by sixfiveotwo on Thursday August 22, 2024 @02:55AM (#41317534)
What you guys probably want to do instead is get to a common definition of what a typo is. Personally, I understand it as a typographic error, which is a fancy way of saying a spelling mistake (a mistake on a letter), not a mistake where one use a word for another.

Maybe you meant the latter?

Re:I'm Tired of Fixing Customers' AI Generated Code by Mashimo on Thursday August 22, 2024 @03:37AM (#41317712)
I, for one, have not have this experience with LLM creating new variable names when they already defined one.

Lots of mistakes, but never this one.

Re:I'm Tired of Fixing Customers' AI Generated Code by boredhedgehog on Thursday August 22, 2024 @03:18AM (#41317625)
What likely happened is that he asked the AI two separate questions and fused the answers himself.
Re:I'm Tired of Fixing Customers' AI Generated Code by nope1000 on Thursday August 22, 2024 @02:27AM (#41317387)
I don't know about copilot but I've seen typos from ChatGPT (although it was english, not code)
Re:I'm Tired of Fixing Customers' AI Generated Code by brigadier132 on Thursday August 22, 2024 @02:32AM (#41317411)
You are getting downvoted but you are right, a typo in a variable that already exists in a file like this is not the failure mode for LLMs. The failure mode is logic bugs, making up methods / functions.
Re:I'm Tired of Fixing Customers' AI Generated Code by varjag on Thursday August 22, 2024 @03:23AM (#41317652)
No, you can get variable names "mutated" on follow up requests. The thing is like sculpting with toothpaste.
Re:I'm Tired of Fixing Customers' AI Generated Code by brigadier132 on Thursday August 22, 2024 @12:23PM (#41321896)
I've been using copilot for as long as it has existed and what you are describing has not happened to me once. Literally on in the background 8 hours a day. Excuse me for not trusting the internet hivemind that hates everything that is hyped just a little bit.
Re:I'm Tired of Fixing Customers' AI Generated Code by varjag on Thursday August 22, 2024 @12:46PM (#41322087)
My goto check of AI assistants is asking to write a function calculating the first N digits of Pi in Common Lisp. On at least two attempts when prompted to fix its code the model would change one of the variable names to T, which is a reserved symbol. So yeah pretty sure it does happen.
Re:I'm Tired of Fixing Customers' AI Generated Code by fragmede on Thursday August 22, 2024 @02:21AM (#41317360)
would someone invent that and bother the author with that? I mean I suppose it's possible, but that seems like such a waste of time to me that I find that more unlikely. and while it's a typo, it's not fleinaem or something that's totally wrong, just a choice in breaking up the word filename. having written file handling code, the various permutations of filename and path and dirname get to be a bit much sometimes.
Re:I'm Tired of Fixing Customers' AI Generated Code by brigadier132 on Thursday August 22, 2024 @12:24PM (#41321909)
People are unhinged about AI so yes I think someone would invent a scenario like this for internet points
Re:I'm Tired of Fixing Customers' AI Generated Code by wredue on Thursday August 22, 2024 @12:42PM (#41322044)
>people are unhinged about AI.

Well. We definitely agree on that.

Re:I'm Tired of Fixing Customers' AI Generated Code by Glyptodon on Thursday August 22, 2024 @01:37AM (#41317160)
At least for me stupid bugs like this turn out to be some of the most time wasting to debug, no AI involved. Like accidentally have something quoted somewhere, or add an 's' to a variable by accident and I may not even correctly process what the error message is reporting at first. Always feel a bit silly after.
Re:I'm Tired of Fixing Customers' AI Generated Code by Noumenon72 on Thursday August 22, 2024 @01:42AM (#41317178)
These kinds of problems are often avoidable by linters or asking ChatGPT what is wrong, though I was just tearing my hair wondering why TSC_COMPILE_ERROR wasn't skipping TypeScript because I spelled it TSX_COMPILE_ERROR in my environment variable.
Re:I'm Tired of Fixing Customers' AI Generated Code by viraptor on Thursday August 22, 2024 @09:42AM (#41320181)
Not only asking ChatGPT what is wrong, but also using an agent which does self-reflection by default. I'm sad every time I see people using the bare chat interface to generate code. We've got API tools which are so much better at it today. Use Aider at the very least.
Re:I'm Tired of Fixing Customers' AI Generated Code by floydnoel on Thursday August 22, 2024 @10:07AM (#41320433)
does aider have an executable installer yet? i tried installing it but the python experience is terrible. last time i messed with python installs on my mac everything worked like shit until o reinstalled the OS.
Re:I'm Tired of Fixing Customers' AI Generated Code by viraptor on Thursday August 22, 2024 @10:14AM (#41320531)

    python -mvenv aider
    aider/bin/pip install aider-chat
    aider/bin/aider
And you're done. There's also a docker version https://aider.chat/docs/install/docker.html

Just don't mess with the system-wide installed version of python and it will be fine. This isn't a python specific issue though.

Re:I'm Tired of Fixing Customers' AI Generated Code by trees101 on Thursday August 22, 2024 @04:06PM (#41323942)
`pipx install aider-chat`

(https://aider.chat/docs/install/pipx.html will install it globally on your system within its own python environment. This way you can use aider to work on any python project, even if that project has conflicting dependencies.)

if you want to run the most bleeding edge version at the same time without breaking anything,

`pipx install --suffix=@dev git+https://github.com/paul-gauthier/aider.git`

then run it with `aider@dev`

if you do that at the moment you will get access to prompt-caching from Claude, saving you $$$ by avoiding re-sending context with each query.

```aider@dev --sonnet --no-auto-commits --cache-prompts```

Re:I'm Tired of Fixing Customers' AI Generated Code by Glyptodon on Saturday August 24, 2024 @03:24AM (#41336298)
Subtle typos easily misread are
Re:I'm Tired of Fixing Customers' AI Generated Code by arcticfox on Thursday August 22, 2024 @03:00AM (#41317548)
This type of bug is trivial for GPT to fix though. It was born for this. Sometimes it does generate real footguns but this sounds like an example from an earlier generation of generative AI.
Re:I'm Tired of Fixing Customers' AI Generated Code by EVa5I7bHFq9mnYK on Thursday August 22, 2024 @02:07AM (#41317303)
Sounds like javascript "code". A normal language with proper type system would not allow that.
Re:I'm Tired of Fixing Customers' AI Generated Code by CalRobert on Thursday August 22, 2024 @02:18AM (#41317348)
I don’t see how typing relates to this.
Re:I'm Tired of Fixing Customers' AI Generated Code by mkl on Thursday August 22, 2024 @02:40AM (#41317468)
Probably one of the variables is undefined, and static typing could catch that.
Re:I'm Tired of Fixing Customers' AI Generated Code by normie3000 on Thursday August 22, 2024 @03:33AM (#41317693)
Is it the compiler that would catch it?
Re:I'm Tired of Fixing Customers' AI Generated Code by mkl on Thursday August 22, 2024 @04:16AM (#41317958)
Yes. This would be caught by the compiler in C, C++, Java, Rust, Haskell, etc.: https://stackoverflow.com/questions/1517582/what-is-the-diff...

Many statically typed languages do have escape hatches to do some dynamic typing at runtime, but this is not the default (hence the classification), and it requires some additional effort to use.

Re:I'm Tired of Fixing Customers' AI Generated Code by zo1 on Thursday August 22, 2024 @03:55AM (#41317827)
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 by timeon on Thursday August 22, 2024 @03:30AM (#41317675)
Also warning for unused variable.
Re:I'm Tired of Fixing Customers' AI Generated Code by delusional on Thursday August 22, 2024 @02:37AM (#41317452)
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, but recieved the response "I dont know what it means, I just used copilot" followed by him just removing the code.

What a waste of a learning opportunity.

Re:I'm Tired of Fixing Customers' AI Generated Code by woctordho on Thursday August 22, 2024 @03:43AM (#41317748)
Everyone working with shell scripts should know shellcheck
Re:I'm Tired of Fixing Customers' AI Generated Code by swah on Thursday August 22, 2024 @05:49AM (#41318421)
And Python...
Re:I'm Tired of Fixing Customers' AI Generated Code by rwmj on Thursday August 22, 2024 @03:47AM (#41317776)
And you didn't sack him?
Re:I'm Tired of Fixing Customers' AI Generated Code by delusional on Thursday August 22, 2024 @10:07AM (#41320442)
I don't have hiring privileges. Either way. I like the guy, and I'd rather work to build him up. That doesn't mean it's not frustrating, but I have a process that seems to build a pretty good culture.
Re:I'm Tired of Fixing Customers' AI Generated Code by OJFord on Thursday August 22, 2024 @05:16AM (#41318244)
And of a salary...
Re:I'm Tired of Fixing Customers' AI Generated Code by steelframe on Thursday August 22, 2024 @10:46AM (#41320878)
Wait until a manager who's evaluating a technical decision you're making copies and pastes ChatGPT's "analysis" of your proposal and asks you to respond to it.
Re:I'm Tired of Fixing Customers' AI Generated Code by falcor84 on Thursday August 22, 2024 @11:01AM (#41321093)
I agree that it's a waste of a learning opportunity, but from my experience it is still often rational.

There were many times in my career when I had what I expected to be a one-off issue that I needed a quick solution for and I would look for a quick and simple fix with a tool I'm unfamiliar with. I'd say that 70% of the time the thing "just works" well enough after testing, 10% of the time it doesn't quite work but I feel it's a promising approach and I'm motivated to learn more in order to get it to work, and in the remaining 20% of the time I discover that it's just significantly more complex than I thought it would be, and prefer to abandon the approach in favor of something else; I never regretted the latter.

I obviously lose a lot of learning opportunities this way, but I'm also sure I saved myself from going down many very deep rabbit holes. For example, I accepted that I'm not going to try and master sed&awk - if I see it doesn't work with a simple invocation, I drop into Python.

Re:I'm Tired of Fixing Customers' AI Generated Code by OJFord on Thursday August 22, 2024 @02:12PM (#41322942)
I feel similarly that some such learning opportunities are just going to be larger rabbit holes than the thing is worth, but in those cases I'll just prefer to do it a different way that I do know or is worth learning.

E.g. maybe it would be very 'elegant' or rather concise awk if I could overcome the learning opportunity, but like you I would probably decide not to; I'll do it with the sed I do know even if it means some additional piping and cutting or grepping or whatever that awk could've done in one, because I already know it and it's going to be clearer to me and probably anyone else I'm working with.

I think we're saying quite similar things, but my point is I wouldn't be deleting it, dismissing the idea, and disappointing the colleague ready to teach me about it - because I never would've been willing to blindly try broken AI generated (or however sourced) code that I didn't understand in the first place.

Re:I'm Tired of Fixing Customers' AI Generated Code by valval on Monday August 26, 2024 @03:06PM (#41360579)
I like learning a little about a lot of things as I’m the entrepreneurial type, but I’m really good at very few things. I appreciate having workers who specialize in one or two things really deeply though.
Re:I'm Tired of Fixing Customers' AI Generated Code by xorcist on Monday August 26, 2024 @05:38PM (#41362486)
You don't have to master it. But some things are just well worth learning at least the basics of: Your programming language of choice, your shell, your editor, your version control system.

An afternoon learning your way around bash or vim will save you countless of hours of work, just because you will know what the building blocks are, you will be able to ask the right questions directly instead of chasing down alleys.

It's not the same thing as learning yet another language. It's a separate type of tool. Developing software without knowing an editor or a shell is like refusing to learn what a file is or what an ip address is. Sure, you can probably get work done in roundabout ways, but it's certainly not rational.

Re:I'm Tired of Fixing Customers' AI Generated Code by imtringued on Friday August 23, 2024 @02:05AM (#41326497)
https://stackoverflow.com/a/13864829

It is not nonsense. You use that expression if you want to check if a variable exists or not (as opposed to being set to an empty string) which is an extremely common problem.

Re:I'm Tired of Fixing Customers' AI Generated Code by dezgeg on Friday August 23, 2024 @03:48AM (#41326984)
The +x needs to belong inside the {}, ie. "${var+x}" not "${var}+x"

But I agree I wouldn't extrapolate too much from one such brain fart

Re:I'm Tired of Fixing Customers' AI Generated Code by delusional on Friday August 23, 2024 @03:19PM (#41332185)
That what I meant by "I can see what they were trying to do". It's would have been correct if the "+x" was inside the braces, even in context. He did in fact want to check if the variable was unset and error out, and that's what hurts so much.

There was a real and correct analysis that, hey, I want to make sure the variable is set here. Only to then drop it because you get told the syntax is wrong. The response I'm looking for when I say "This syntax won't do what you're looking to do" would be something like "what am I trying to do? and why wont this do it?" not "well it's just some AI code, I'll just remove it".

Re:I'm Tired of Fixing Customers' AI Generated Code by Tainnor on Thursday August 22, 2024 @03:40AM (#41317733)
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 by tomrod on Thursday August 22, 2024 @08:23AM (#41319471)
No need for quotes, the best AI integrations are the ones you see as just part of the tech stack like spell check and linters.
Re:I'm Tired of Fixing Customers' AI Generated Code by wiseowise on Thursday August 22, 2024 @04:12PM (#41323986)
But that’s WoOoOrK. These stupid sobs want magic that does everything automatically.
Re:I'm Tired of Fixing Customers' AI Generated Code by tomrod on Thursday August 22, 2024 @05:29PM (#41324551)
Yes, labor costs aren't magically replaced by trained AI models, MBA protestations aside
Re:I'm Tired of Fixing Customers' AI Generated Code by cqqxo4zV46cp on Thursday August 22, 2024 @09:01PM (#41325495)
I trust that you’re all done patting each other on the back now, yes?
Re:I'm Tired of Fixing Customers' AI Generated Code by tomrod on Thursday August 22, 2024 @09:12PM (#41325519)
Therefore, what?
Re:I'm Tired of Fixing Customers' AI Generated Code by hayley-patton on Friday August 23, 2024 @01:49PM (#41331237)
Right, your static analysis tools will likely use Abstract Interpretation.
Re:I'm Tired of Fixing Customers' AI Generated Code by sa-code on Thursday August 22, 2024 @11:00AM (#41321083)
Unless you're using Python and said variable was meant to be reassigned, but you used a different name instead. E.g. file_name = 1 filename = 2
Re:I'm Tired of Fixing Customers' AI Generated Code by aidos on Thursday August 22, 2024 @11:57AM (#41321658)
Fairly sure the linters would catch that (unless you referenced both of them in later code).
Re:I'm Tired of Fixing Customers' AI Generated Code by romwell on Thursday August 22, 2024 @03:45PM (#41323788)
>unless you referenced both of them in later code

Generative AI: hold my bear

Re:I'm Tired of Fixing Customers' AI Generated Code by snikch on Thursday August 22, 2024 @04:09PM (#41323960)
Sounds dangerous.
Re:I'm Tired of Fixing Customers' AI Generated Code by ben_w on Thursday August 22, 2024 @03:57AM (#41317841)
> 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 by latexr on Friday August 23, 2024 @09:36AM (#41328890)
> It's easy to miss that kind of difference even if you wrote the code yourself.

The developer in the story had no idea what the code did, hence they would not have written it themselves, making it impossible for them to “miss” anything.

Re:I'm Tired of Fixing Customers' AI Generated Code by planb on Thursday August 22, 2024 @10:31AM (#41320722)
In my experience this is exactly the kind of mistake an AI would not make.
Re:I'm Tired of Fixing Customers' AI Generated Code by yawnxyz on Thursday August 22, 2024 @11:18AM (#41321273)
Claude gave me something similar, except these were both used, and somehow global variables, and it got confused about when to use which one.

Asking it to refactor / fix it made it worse bc it'd get confused, and merge them into a single variable — the problem was they had slightly different uses, which broke everything

I had to step through the code line by line to fix it.

Using Claude's still faster for me, as it'd probably take a week for me to write the code in the first place.

BUT there's a lot of traps like this hidden everywhere probably, and those will rear their ugly heads at some point. Wish there was a good test generation tool to go with the code generation tool...

Re:I'm Tired of Fixing Customers' AI Generated Code by danenania on Thursday August 22, 2024 @11:40AM (#41321499)
One thing I've found in doing a lot of coding with LLMs is that you're often better off updating the initial prompt and starting fresh rather than asking for fixes.

Having mistakes in context seems to 'contaminate' the results and you keep getting more problems even when you're specifically asking for a fix.

It does make some sense as LLMs are generally known to respond much better to positive examples than negative examples. If an LLM sees the wrong way, it can't help being influenced by it, even if your prompt says very sternly not to do it that way. So you're usually better off re-framing what you want in positive terms.

I actually built an AI coding tool to help enable the workflow of backing up and re-prompting: https://github.com/plandex-ai/plandex

Re:I'm Tired of Fixing Customers' AI Generated Code by withinboredom on Thursday August 22, 2024 @12:47PM (#41322098)
As someone who uses LLMs on my hobby projects to write code, I’ve found the opposite. I usually fix the code, then send it in saying it is a refactor to clarify things. It seems to work well enough. If it is rather complex, I will paste the broken code into another conversation and ask it to refactor/explain what is going on.
Re:I'm Tired of Fixing Customers' AI Generated Code by danenania on Thursday August 22, 2024 @01:06PM (#41322263)
Fixing the mistake yourself and then sending the code back is a positive example, since you're demonstrating the correct way rather than asking for a fix.

But in my experience, if you continue iterating from that point, there's still a risk that parts of the original broken code can leak back into the output again later on since the broken code is still in context.

Ymmv of course and it definitely depends a lot on the complexity of what you're doing.

Re:I'm Tired of Fixing Customers' AI Generated Code by gopher_space on Thursday August 22, 2024 @02:52PM (#41323320)
I’m attempting to keep the context ball rolling by reiterating key points of a request throughout the conversation.

The challenge is writing in a tone that will gently move the conversation rather than refocus it. I can’t just inject “remember point n+1” and hope that’s not all it’ll talk about in the next frame.

If nothing else, LLMs have helped me understand exactly why GIGO is a fundamental law.

Re:I'm Tired of Fixing Customers' AI Generated Code by davidthewatson on Thursday August 22, 2024 @02:13PM (#41322952)
I'd refer you to a comment I made a few weeks ago on an HN post, to the same effect, which drew the further comment from gwern here:

https://news.ycombinator.com/item?id=40922090

LSS: metaprogramming tests is not trivial but straightforward, given that you can see the code, the AST, and associated metadata, such as generating test input. I've done it myself, more than a decade ago.

I've referred to this as a mix of literate programming (noting the traps you referred to and the anachronistic quality of them relative to both the generated tests and their generated tested code) wrapped up in human-computer sensemaking given the fact that what the AI sees is often at best a lack in its symbolic representation that is imaginary, not real; thus, requiring iterative correction to hit its user's target, just like a real test team interacting with a dev team.

In my estimation, it's actually harder to explain than it is to do.

Re:I'm Tired of Fixing Customers' AI Generated Code by berniedurfee on Thursday August 22, 2024 @11:48AM (#41321568)
I burned a couple hours debugging some generated code only to finally realize copilot was referencing a variable as ‘variableO1’.

Artificial Incompetence indeed!

Re:I'm Tired of Fixing Customers' AI Generated Code by bckr on Thursday August 22, 2024 @12:47PM (#41322093)
> Using code from a generative AI without understanding what it does is never a good idea.

Yes.

AI as a faster way to type: Great!

AI as a way to discover capabilities: OK.

Faster way to think and solve problems: Actively harmful.

Re:I'm Tired of Fixing Customers' AI Generated Code by morgango on Thursday August 22, 2024 @05:02PM (#41324371)
Interestingly, a great application for GenAI is to copy and paste code and ask it, "Why is this not working?". It works even better if you give it the specific error you are getting (and it is a well understood system).