Live data from Hacker News

I'm tired of fixing customers' AI generated code

medium.com

251–260 of 345 posts

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

#251
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…

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

#252
post #248

Earlier quoted context omitted.

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.

for line in f: is multiple mistakes in a single line.

What are the mistakes there?

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

#253
post #226

Earlier quoted context omitted.

Sorry, are you saying it takes 20 years for a self-taught developer to learn enough programming, especially when they start as kids? No offense, this is a you problem. I dabbled with PCs since I was 8, around 14 I had enough brain to start to understand BASIC and enough free time to get good enough to write half a decent mini OS by the time I was 17 [1] and got my first paying job (sysadmin and PHP dev) at 19. I'm 37…

wow its crazy that different people have different experiences (as it turns out, writing code for yourself is a different skillset than writing code for a boss!)

> (as it turns out, writing code for yourself is a different skillset than writing code for a boss!)

That was exactly the point I was trying to make

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

#254

Earlier quoted context omitted.

I've been programming since I was 4 years old but with literally zero resources or assistance beyond "take books out from the library" for 20 years. It wasn't until I was about 28 until I had the chops to get into the industry (largely down to never having a need or opportunity to learn SQL -- also I mean as a developer, I had a prior career in IT) and even then it wasn't until I was 31 before I had the confidence en…

This is very similar to my story. Once I got on a dev team I was flabbergasted at the lack of breadth and depth of knowledge of my fellow devs. It was only a few older devs that had any clue. Having gobs of time as a kid and in my twenties to experiment greatly enhanced my capabilities. Once I did start landing corporate jobs (which was exceedingly difficult) I was at or above architect level. As I gained more experi…

> Once I did start landing corporate jobs (which was exceedingly difficult) I was at or above architect level. As I gained more experience working on production systems I was promoted very quickly (created new positions for me etc).

Ditto and ditto.

I have had some positive experiences working with fresh grads from places like Waterloo (I'd hire 10 of their grads for any one grad from anywhere else...) but my professional experience very much matches yours.

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

#255
post #11

Earlier quoted context omitted.

Coding requires a willingness to understand and manipulate systems made of unbreakable rules. Most people don't want to deal with such an uncompromising method of communication.

Counterintuitively, it also requires a willingness to break what appear at first to be unbreakable rules. Most of the worst programmers I know seem to see their work as "how can I accomplish a task without breaking what I see as the rules", without having fully understood the system. That quickly turns into copypasta, extra layers of abstraction, over configurability, and many of the other plagues of programming.

I think the two errors - imagining non-existent rules, and ignoring rules that exist - are related errors. The foundational skill is accepting that the machine is never wrong because the machine is also never "right", the machine doesn't actually make decisions, it's a construct of physics following a pile of physical laws and not a person to be negotiated with.

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

#256
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 agree with the part that someone who wants to build something technical should gain at least some related knowledge, but a week is underselling the effort needed to learn how to code by a lot. After one week of teaching myself Python I couldn't code my way out of a paper bag, and I'm someone who enjoyed it enough to stick with it. The average person would need at least 10x that amount of time to be able to start building something interesting.

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

#258
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.

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...

Post reply on HN