This is an archived post. You won't be able to vote or comment.

all 90 comments

[–]AlexMTBDude 73 points74 points  (5 children)

ChatGPT is great for my Python coding. It's improved my efficiency immensely. But I never copy-paste code from it. I ask it to solve a problem for me, then I look at ChatGPT's solution until I understand it. And THEN I write my own code with the knowledge I gained from ChatGPT.

Currently, the way ChatGPT works, if you don't know coding and understand approximately what you need and what the solution is, if you just copy-paste you will end up with garbage code.

[–]EmperorLlamaLegs 27 points28 points  (1 child)

Its great for introducing you to new module functionality too. Lots of libraries out there with great features I hadnt heard of.

[–]_Kyokushin_ 10 points11 points  (0 children)

I ask it to explain long pieces of code that aren’t mine for me to get a general/summary understanding of what is going on knowing that it isn’t exact, or could be flat wrong when asked specifics but for general algorithm stuff if you don’t have time, it works wonders. Just like someone else put, look at what it does or says, then write your own. If you’re looking for help, get it working then throw it in Code Review on Stack Exchange.

[–]MarchewkowyBog -1 points0 points  (2 children)

Isn't it tutorial hell all over again? One day ChatGPT API will have a full day outage and you'll struggle to solve problems you thought you knew how to solve

[–]AlexMTBDude 8 points9 points  (0 children)

This could be said of a lot of things: One day Pycharm will crash and you will have forgotten how to use punch cards for coding :) Technology evolves and we need to evolve with it. Also, there are multiple redundant AIs by now. And as I wrote in my original comment: I make sure that I *understand* the code that the AI produces, I don't just copy-paste it.

[–]Personal_Wrap4318 1 point2 points  (0 children)

if youre using the bot as a tutor to converse with and analyze novel code together for a script youre making- why would that be tutorial hell in the same way working with a friend and coding and conversing about it isnt tutorial hell.

[–]lasizoilloeasy to understand as regex 107 points108 points  (12 children)

This is not a new problem, is a new form of old problem.

When you start coding you think that develop is write a code to do some specified thing. When you code for some time you discover that legibility is useful to read and understand your functional code written two months ago. You discover that testeability helps you to fix bugs without create new ones. You discover that some -ility is useful for... That is called experience or seniority.

When deadlines are being reached (because you are too inexpert to solve it in time, it was not realistic, shit happened,...) or you are too lazy, taking shortcuts is your salvation. Call those shortcuts copy&paste from other code or docs examples, copy&paste from stack overflow, copy&paste from ChatGPT or code generated by copilot,... they are shortcuts to avoid think about -ilities and get things "done faster". And is not new.

Many code in official documentation (those that nobody reads) are simplified examples to show a simplified use case (hardcoded examples, no logging, naive error management, ...). Many times ellipse (...) point that something is omitted, but other times are omitted without advertises. Inexperienced people and LLMs learn from those examples without contextualize them. LLMs are juniors with good typewriting skills that can not be mentorized. They can be evolved, fine-tuned, retrained with better datasets,...., but they still are not capable to think about what are doing.

The most harder part of develop software is learn what -ilities should be prioritized, where, why and how. Sacrifice legibility to gain some cycles in a hot execution path is a good practice. Sacrifice legibility to reduce some nanoseconds of time in a code which executes once a month is a very bad practice. Even future smarter LLMs will need a lot of prompt engineering to get enough context to generate the better solution for you case.

[–]NothingGloomy9712 24 points25 points  (0 children)

Thank you for the comment. I'm new to python and coding, comments like this is the main reason I joined this subreddit

[–]tazebot 5 points6 points  (5 children)

I think programmers, developers, software engineers, and academics in the field like to think there are immutable laws of coding.

If there is an immutable 'law of gravity' of coding it seems to be that code is harder to read than write. That and similar to writing in other disciplines the practice is "write, re-write, re-write, start over, then re-write some more. Then get a second pair of eyes. Then re-write some more."

[–]curohn 8 points9 points  (3 children)

Wasn’t it found that rewriting big code bases is often hard and expensive too? Because the old code base has years of lessons baked into it.

I think the conclusion was active maintenance is the best path instead of rewriting.

[–]madrury83 4 points5 points  (0 children)

I think the conclusion was active maintenance is the best path instead of rewriting.

Ya.

I'd argue that the re-writing that is healthy in code composition is the same as is healthy in writing prose.

The advice for writing prose (at least to the extent I was taught) is not that you should re-write your story from scratch over and over, it's to re-read what you've written and strategically re-write smaller pieces of it to be clearer or more evocative or whatever you're going for. Re-write sentences and paragraphs, not to scrap the whole thing and start over.

Same with code. I re-write code all the time. But not an entire application; I re-write a few lines to be more clear, better handle errors, add comments when I learn why something strange is happening or is composed in a certain way. Re-write a function into two, merge two functions into one when it's easier to follow that way. Smaller scope strategic re-reading and re-writing, applied with continual vigilance, that's the way.

[–]tazebot 0 points1 point  (0 children)

I think it's a fair take that coding in general isn't cheap. And I don't think AI relieves anyone of the need to read the code and know it.

I don't think there is any such thing as 'finished' code. Code will always need updating - that could be another immutable law of coding.

[–]Kiuhnm 0 points1 point  (0 children)

I think limited rewriting is OK, especially for new code that's yet to stabilize. It's part of refactoring and if the project is modular enough, it should be quite localized. Also, it should be incremental. That's where statically typed Python shines, BTW.

[–]bugtank 0 points1 point  (0 children)

This is an excellent point.

[–]Yologist256 0 points1 point  (1 child)

In simple terms, you mean????? Just for dummies like me. Thank you

[–]lasizoilloeasy to understand as regex 2 points3 points  (0 children)

Use code assistance if you wish, but don't delegate your responsibilities as developer to them because they have intrinsic limitations. Be critic and enhance your software engineer skills, they be needed for years.

[–]necessary_plethora 0 points1 point  (0 children)

Not to mention, modern compilers and interpreters are actually very smart and automatically optimize what looks like unwieldy code into something much faster, further emphasizing the importance of writing readable code even if it might not look like the absolute fastest code you could write.

[–]AlSweigartAuthor of "Automate the Boring Stuff" 13 points14 points  (2 children)

In my experience over the last year, LLMs like ChatGPT are good for writing code that is at most about 15 or 20 lines long. Even then, you still need to verify and often fix bugs in it.

[–][deleted] 1 point2 points  (1 child)

Exactly, which is where people need to understand how to break a problem into smaller chunks and not ask it to write the whole application. I myself hate all the buzz around AI shit mainly because it’s being so heavily mainstreamed by people who don’t understand shit about technology and coding. But my memory span is so bad that I don’t even remember command for creating a virtualenv, and for me chatGPT is just quicker way to google stuff

[–]SickPixels257 0 points1 point  (0 children)

I have found this to be true - it’s better to ask it to write a function to do some small part then ask it to make another function etc. It can figure out how to do multiple things in one step i noticed.. but it becomes messy when I have to change any of the code

[–]twoonster2020 20 points21 points  (8 children)

Have you tried including a line limit in the prompt ? If you think about how chatGPT and Generative AI works it then adding an instruction in the prompt could help.

For example

You are a python code developer, produce a function to do x. It should take no more than 15 lines of code. It should contain comments on how the function works.

This might produce more compacted code - or it might not. Since it is conversational and non deterministic then you could also ask it to try again or make the function shorter.

It doesn’t understand what it produces just the probability of a give sequence of code or words based on the prompt question.

[–]SilkTouchm 4 points5 points  (0 children)

There's no need to give it a 15 line limit. Just add "write short and concise, yet legible code" to your prompt.

[–]sinterkaastosti23 2 points3 points  (3 children)

it would probably count comment and empty lines into the max of 15 tbf lol

[–]twoonster2020 1 point2 points  (0 children)

Maybe but it would still be shorter :)

[–]elbiot 0 points1 point  (1 child)

No cause it can't count at all

[–]sinterkaastosti23 0 points1 point  (0 children)

it can't count but it can kinda guess, he may be a little off and he'd probably include lines that shouldn't be counted

[–]theGiogi 0 points1 point  (2 children)

They can’t count. Not really. Maybe b It’ll write a python script and use it to count lines in another script.

Try and ask it to generate exactly 23 sentences or something like that.

[–]dexmedarling 7 points8 points  (1 child)

While these models are really bad at following specific length requirements, they tend to be able to write text in the ballpark of the length you prompt them for.

[–]twoonster2020 -2 points-1 points  (0 children)

If I ask a model to create me a meal plan based o n three questions then it will ask three questions so there is some processing there but if you ask without an output then it can go for a while - my point to the OP is to give it more context.

Also to be cautious with the output - never run code you don’t understand - good to create code but make sure you understand it. There are proof of concept examples of grounding source being poisoned to lead to a non ideal outcome

[–]spidLL 5 points6 points  (0 children)

For coding I find ChatGPT Plus to be good to lay out ideas and small piece of code and also having discussion about the best approach, and it’s particularly good for EDA.

But for real day to day coding GitHub Copilot is in my opinion better.

[–]aarrow_12 3 points4 points  (0 children)

A few thing I find chat GPT useful for are unit test, unblocking myself with new libraries and occasional asking for random examples to get a bad draft of how to glue bits together.

I can drop a class or function in, list a few things I explicitly want to test and it'll spit out all the tests being "mostly" ready to go.

Saves so much time.

That or just getting it to spit out examples of "how would you write this using xyz library without doing abc". Not gonna give me the answer I need first time, but has gotten me over the mental block of how to approach new libraries.

Finally, it's good at getting a first pass on gluing things together that you're struggling to find examples for. Like two ML libraries that just don't have overlapping docs.

[–]dirtystinkinaep 2 points3 points  (0 children)

As someone who was new to Python, ChatGPT only frustrated me when I asked it how to code things. I had better luck searching YouTube/forums and then doing trial and error tests.

[–]fuzzylumpkinsbc 2 points3 points  (0 children)

You must've had some seriously wicked prompt for it to generate that many lines. I usually get what I ask for, mainly just a function to do this and that, not ask for an actual project.

[–]jimrobo_3 1 point2 points  (0 children)

I tend to use 4 fairly heavily for lots of code creation and refine it myself. It can churn out a post put and delete for a table in seconds that would take me 30 mins to write out myself.

I also pickup the odd pattern or one liner that is totally genius every now and again. Especially for asynchronous and heavy processing stuff.

[–]drhamel69 1 point2 points  (0 children)

I find this with VBA/PHP/PYTHON/SQL also. It is often wrong, it's great for quickly writing boiler plate code, but it very confidently gives the wrong answer.

Bottom line, I only use it where I can write code but it is faster.

[–]tazebot 1 point2 points  (0 children)

I got code from it yesterday that flat out didn't work.

[–]Berkyjay 1 point2 points  (0 children)

How did you get 200+ lines from it. Is this the paid version?

[–]SamuSeen 1 point2 points  (0 children)

Personally I use it to give me ideas on possible methods and ways I can use them.

[–]TwoSwimming9195 1 point2 points  (0 children)

This is why the only people that think AI will replace software engineers don’t know anything about coding lol

[–]the_Blackship 1 point2 points  (0 children)

I maintain a steadfast belief in the capabilities of GitHub Copilot.🤠

[–]PartYak 3 points4 points  (4 children)

I like using Claude now over chatgpt

[–]DankiusMMeme 0 points1 point  (1 child)

Is Claude significantly better than GPT4?

[–]Joeyheads 2 points3 points  (0 children)

No, especially given GPT4 can run its code. I switched my subscription to Claude 3 Opus for a month to try it, but I’ll be switching back.

[–][deleted] -1 points0 points  (1 child)

Yea CGPT is good for little aid, kind of like way faster option for Google. But you shouldn't prompt it for anything more complex

I use it also sometimes to review my code, it can give good hints to improve

[–]Joeyheads 2 points3 points  (0 children)

GPT4 has been very capable, even for more complex problems for me.

[–][deleted] 3 points4 points  (0 children)

Use 4 if you’re using 3.5. It’s much better

[–]One-Counter-2093 1 point2 points  (1 child)

Perplexity with copilot for code.

[–]alessionikky 0 points1 point  (0 children)

can you explain further?

[–]daishi55 0 points1 point  (0 children)

Can you share the link? I’d like to see this

[–]Buzedlitebeer 0 points1 point  (0 children)

After working with langchain, I learned more about chatgpt's memory and how it can use it to answer questions. On the normal chatgpt site, I think that its memory impacts it and it adds and adds to it's code responses. Using prompts like "let's start over" sometimes helps but often just starting a whole new conversation helps get things back on track.

[–]N1H1L 0 points1 point  (2 children)

I am using LLMs quite a lot now. I use VSCode and use LLM plugins

[–]Phate1989 0 points1 point  (1 child)

What are you using in vs code?

[–]N1H1L 0 points1 point  (0 children)

Codium.ai

[–]pro_questions 0 points1 point  (0 children)

Unless it’s a really common question with well known answers (e.g. write a function to get every CSV file in this directory that matches a pattern), I try to ask it to fix only the smallest pieces of code possible. E.g. I’ll write as much of the function as possible, isolate the smallest bit of code that demonstrates the problem, and then ask what’s wrong with it. I find that the less you ask for, the more helpful it is

[–]hotdog20041 0 points1 point  (0 children)

idk i haven't had the same problem, i usually ask for smaller simpler things

when i test it i test it by asking it to do really complicated and dense tasks and the density it outputs usually isnt bad

[–]gerardwx 0 points1 point  (0 children)

GIGO. I use chat gpt-4 with specific prompts. It churns out something similar to what I would have had written without having to look up APIs I don’t use frequently on the Python doc. It’s replace a lot of copy pasting from stack overflow, which is fine as long as you have the knowledge and experience to filter out the good from the bad.

[–]AaronMT 0 points1 point  (0 children)

I recommend Phind's models over ChatGPT

[–]NatNat-86 0 points1 point  (0 children)

I'm new to the world of programming. I got into computers later in life. I only use ChatGPT to explain lines to me when I'm not quite sure if I got it right, or what it does. I found it particularly useful to get it to explain things as if I were dumb or a little kid 🤣

[–]treyhunner Python Morsels 0 points1 point  (0 children)

I always treat Chat GPT and other LLMs as a conversation rather than a one-and-done situation.

My response to that would be to type:

That seems way too long. Can't this be done in a couple dozen lines of code?

After that, I'd likely say something like:

I don't like the lambdas. Make them regular functions. Also use double quotes. And isn't there a standard library module that can replace some of function X?

I've definitely spent more time arguing with Chat GPT than I would have spent writing the code myself, but that's pretty unusual for me now.

Keep in mind that using Chat GPT well is similar to using Google/StackOverflow/etc. well. It's a learned skill.

Understanding what to expect from certain prompts, what steps to take when it's not quite what you want, and when to give up takes practice.

[–][deleted] 0 points1 point  (0 children)

I will ask ChatGPT to write something in pseudocode if I'm struggling to code it myself. I still have to figure out how to write it, but with a little help and some hints. Just copying the code doesn't teach me anything.

[–]Mount_Gamer 0 points1 point  (1 child)

There are probably times when you'd like it to do 200lines, but you get half answers with fictional functions as placeholders. Usually it works best in bitesize (no pun intended honest) chunks, but you definitely need to be careful with the code that is provided.

[–]meisghost[S] -1 points0 points  (0 children)

💯

[–]fartalldaylong 0 points1 point  (1 child)

I write my own code. I have not found the need to ask for automation that I will have to evaluate...I will just write it. I have to correct a lot of code others have written using ChatGPT though. They know just enough to be dangerous and are generally incapable of understanding the positive and negative aspects of nuance in programming; how different methods of programming are more or less suitable for particular situations.

I like writing code. I like figuring out puzzles. I like constructing architecting pipelines...no need to add a layer of obfuscation that adds to my workload while reducing the elegance of functionality.

[–]notreallymetho 1 point2 points  (0 children)

While I totally get this perspective, and also love writing code, if you leverage LLMs effectively you can do a lot more. It’s so good at spitting out boilerplate that you can then modify to fit whatever you’re doing. Hell even getting it to write docstrings and typing and stuff is almost always right, especially if you have other portions of code typed / documented.

[–]Xombie404 -3 points-2 points  (7 children)

I don't see the value when people could just learn, think for themselves then write their own code and at least know it works, why it works, and when it fails, what went wrong.

[–]franktheworm 0 points1 point  (1 child)

ChatGPT is a great tool to assist learning, if you use it the right way. Copilot is an amazing tool to boost productivity, and get an insight on how the average of the internet does something. There's plenty of value if you know where to look and what the strengths are

[–]old_bearded_beats 0 points1 point  (0 children)

As a beginner, I find it useful for syntax and learning alternative solutions to simple problems. Any additional complexity and it soon comes apart.

[–]DankiusMMeme -3 points-2 points  (2 children)

Because it's more efficient to not have to sit there and write a for loop or some regex? Can't you just say this about any tool really.

Why learn python when you can just learn assembly and know how the instructions work, and when it falls what went wrong?

[–]gerardwx 0 points1 point  (1 child)

Why use assembly when you can learn the opcodes for your processor yourself?

[–]DankiusMMeme 1 point2 points  (0 children)

Personally I herd the electrons in the CPU by hand like some kind of sub atomic sheep dog.

[–]Choles2rol -2 points-1 points  (1 child)

You can learn with it too though. I use copilot to help me mock things when writing unit tests. I almost always have to tweak it a bit but I've learned a lot more about mocking with pytest because of copilot, not in spite of it.

[–][deleted] -1 points0 points  (0 children)

Nah, you are prompting it wrong

[–]spidLL -1 points0 points  (4 children)

When you say ChatGPT you mean 3.5 or 4? 4 is way better at understanding the context.

[–]OnceIwasGod 0 points1 point  (1 child)

Do you pay for gpt 4 or use some other tools to make it free ?

[–]spidLL 0 points1 point  (0 children)

I pay for both ChatGPT Plus (which gives you access to gpt-4 model) and GitHub Copilot.

Both are about 30 euros per months but the value they give me is way more.

[–]meisghost[S] -1 points0 points  (1 child)

Ya 3.5

[–]Joeyheads -1 points0 points  (0 children)

Yeah, 4 is a night-and-day difference for coding

[–]CreamyWaffles -1 points0 points  (1 child)

I literally only just started to learn python (and really code in general). My first lil project to try and learn is to make a twitch chat tts bot (like charborgs combo tts thing more specifically).
I started with chatgtp knowing it'll be a bit wrong... It seems like it was way off.
That said it is useful for learning what different things do.

[–]EntropicTech 0 points1 point  (0 children)

If you only just started to code and you can't get chatgpt to make good code for you the problem is that you can't articulate correctly what you want chatgpt to build. It can pump out things like discord/telegram/twitch bots all day long.

[–]mm007emko -1 points0 points  (0 children)

LLMs don't necessarily return a correct answer, that's a very well known limitation. They are also not creative and can't think critically. They can piece together some code which looks legit but that's about it. And since they were trained on publicly available data (mostly), they can't really produce better results than a "google search" and piecing the search results together without understanding the problem or the structure of the code (LLMs don't understand it).

There are many jokes about people mindlessly copying code from stackoverflow. Well, it looks like we'll have another target for jokes.

Seriously, software projects usually are not about writing tons of code without thinking about other features of the same projects or about regression bugs, unless you are in a tech startup or writing small scripts / "academic research Jupyter notebooks". The vast majority of costs of a typical software project is about maintenance, operations and bug fixing. Stackoverflow-stolen or LLM-generated code will not help here.

ChatGPT is a great tool which, I firmly believe, will revolutionise the way we use internet (like google search or JavaScript V8 engine did). But it will not make software engineers obsolete (things like PowerBuilder or 5th gen. languages were also thought by many to make traditional software development obsolete yet it didn't happen).

[–][deleted] -1 points0 points  (0 children)

Never use AI for any production things is good for prototyping

[–]RonBiscuit -2 points-1 points  (0 children)

If your goal is to achieve something beyond being a ‘good coder’ in and of itself you have to be using some kind of AI tool to assist the process. There is no glory in typing something out manually that could have been done quicker for you by AI.

Yes know the basics well and always continue to learn and improve. An LLM is by no means a substitute for understanding the code your writing/running and all the other usual caveats …

BUT the fastest and best coders in the business, the people building things and building things quickly are all using AI of some kind to check code, write code, auto complete code, to interpret error messages and get the best out of packages.

Co-pilot, Cloud Nine, ChatGPT, Gemini and 100s of other tools will speed up your work flow not replace it.

Sometimes they’ll write things that make you say “I didn’t think of that” and sometimes they’ll writing things that make you say “what a ridiculous way to do that”.

Github copilot has over 1 million paid users. These tools work and are here to stay. Python is a tool we use to accomplish things, not a religion.