342
top 29 comments
sorted by: hot top controversial new old
[-] coffee_with_cream@sh.itjust.works 6 points 4 hours ago

I told it to generate a pretty complex react component and it worked on the first try yesterday. It even made a style sheet. And it actually looks good.

[-] computerscientistII@lemm.ee 15 points 17 hours ago

I haven't been in development for nearly 20 years now, but I assumed it worked like that:

You generate unit tests for a very specific function of rather limited magnitude, then you let AI generate the function. How could this work otherwise?

Bonus points if you let the AI divide your overall problem into smaller problems of manageable magnitudes. That wouldn't involve code generation as such...

Am I wrong with this approach?

[-] ChairmanMeow@programming.dev 4 points 6 hours ago

I tend to write a comment of what I want to do, and have Copilot suggest the next 1-8 lines for me. I then check the code if it's correct and fix it if necessary.

For small tasks it's usually good enough, and I've already written a comment explaining what the code does. It can also be convenient to use it to explore an unknown library or functionality quickly.

[-] 30p87@feddit.org 1 points 5 hours ago

"Unknown library" often means a rather small and sparely documented and used library tho, for me. Which means AI makes everything even worse by hallucinating.

[-] ChairmanMeow@programming.dev 2 points 5 hours ago

I meant a library unknown to me specifically. I do encounter hallucinations every now and then but usually they're quickly fixable.

It's made me a little bit faster, sometimes. It's certainly not like a 50-100% increase or anything, maybe like a 5-10% at best?

[-] yogthos@lemmy.ml 7 points 15 hours ago

The complexity here lies in having to craft a comprehensive enough spec. Correctness is one aspect, but another is performance. If the AI craps out code that passes your tests, but does it in really inefficient way then it's still a problem.

Also worth noting that you don't actually need AI to do such things. For example, Barliman is a tool that can do program synthesis. Given a set of tests to pass, it attempts to complete the program for you. Synthesis is performed using logic programming. Not only is it capable of generating code, but it can also reuse code it's already come up with as basis for solving bigger problems.

https://github.com/webyrd/Barliman

here's a talk about how it works https://www.youtube.com/watch?v=er_lLvkklsk

[-] Kanda@reddthat.com 2 points 7 hours ago

So it's like AI, but tailored for one purpose and without the marketing

[-] yogthos@lemmy.ml 4 points 7 hours ago

also doesn't require burning down a rain forest each time you run a query

[-] LodeMike@lemmy.today 8 points 16 hours ago

At that point you should be able to just write the code yourself.

The A"I" will either make mistakes even under defined bounds, or it will never make any mistakes ever in which case it's not an autocomplete, it's a compiler and we've just gone full circle.

[-] itslilith@lemmy.blahaj.zone 57 points 1 day ago

Don't copilot anything longer than a function of about 15 lines. That way you can quickly see if it made mistakes. Ensure it works, move on to the next.

And only do that for boring, repetitive work. The tough challenges and critical parts you're (for now) better off solving yourself.

[-] flashgnash@lemm.ee 20 points 19 hours ago

Absolutely, I think the people who say it's completely useless for code are in denial

Definitely not replacing anyone but my god it has sped up development by generating code I already know how to write 90% of

No more having to look up "what was the for loop syntax in this language again?"

[-] firelizzard@programming.dev 2 points 1 hour ago

I won't say copilot is completely useless for code. I will say that it's near useless for me. The kind of code that it's good at writing is the kind of code that I can write in my sleep. When I write a for-loop to iterate over an array and print it out (for example), it takes near zero brain power. I'm on autopilot, like driving to work. On the other hand, when I was trialing copilot I'd have to check each suggestion it made to verify that it wasn't giving me garbage. Verifying copilot's suggestions takes a lot more brain power than just writing it myself. And the difference in time is minimal. It doesn't take me much longer to write it myself than it does to validate copilot's work.

[-] xavier666@lemm.ee 16 points 18 hours ago* (last edited 2 hours ago)

"Copilot is really good at things which I already know" and that is perfectly fine

[-] flashgnash@lemm.ee 9 points 16 hours ago

Exactly.

It's to speed up boilerplate and save you having to look up function names or language specific syntax for that one feature you want to use, not to entirely do your job for you

[-] firelizzard@programming.dev 1 points 1 hour ago

If I've been working in the same language for at least a year or two, I don't have to look up any of that. Copilot might be actually helpful if I'm working in a language I'm not used to, but it's been a long time since I've had to look up syntax or functions (excluding 3rd party packages) for the language I work in.

[-] BudgetBandit@sh.itjust.works 8 points 22 hours ago

Tried to learn coding using chatGPT. Wanted to make my own game engine for a phone game. Ended up looking up tutorials.

[-] coffee_with_cream@sh.itjust.works 1 points 3 hours ago

If you are using "game engine" in the industry standard way, you would want to learn object oriented programming first, then learn how to use an existing game engine, and then MAYBE, in a long time, with a big team, build your own game engine.

[-] Bread@sh.itjust.works 1 points 11 hours ago

ChatGPT as a programming tool like any other tool works a whole lot better when you are well versed in how the process should go. It speeds up the workflow of a professional, it doesn't make a new worker better.

[-] CodingCarpenter@lemm.ee 20 points 1 day ago

Ai is great for finding small flaws or reciting documentation in a more succinct way. But writing new code and functions? That's a fools errand hoping it works out

[-] flashgnash@lemm.ee 10 points 19 hours ago* (last edited 18 hours ago)

I use it for writing functions and snippets all the time, at least in python and rust as long as you describe what you want it to do properly it works great

Example I used recently: "Please generate me a rust function that will take a u32 user id and return a unique RGB colour"

Generated the function, I plugged it in and it worked perfectly first time

[-] Flyberius@hexbear.net 6 points 18 hours ago

To be honest yes. That is the sort of thing that sounds great. I have a little project I'm about to start so I'll take a look

[-] walter_wiggles@lemmy.nz 4 points 1 day ago

Sloppy joes is the new spaghetti code

this post was submitted on 21 Oct 2024
342 points (96.5% liked)

Programmer Humor

32275 readers
989 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS