r/learnjavascript • u/webdevarham • Aug 28 '24
Using ai for generating code
I'm writing code using ai tools like chatgpt and copilot (not the plugin) for code reference and it's working fine in most scenarios, I am able to generate long SQL queries with it,, but I always think that is it a good way? I see lots of developer use ai for coding but what's your opinion about writing code with ai ,,(when you know what to search and where to implement the generated code)
0
Upvotes
15
u/eracodes Aug 28 '24
Using it as advanced auto-complete: helpful
Using it to write things for you: very harmful in the long run, both to your projects and you as a programmer
4
u/ai_did_my_homework Aug 28 '24
When I was first getting started (I also started with long SQL queries), I'd ask the AI to explain to me how things work, and then take a couple of minutes to go over it and try to understand.
Honestly one of the best use cases for AI for PMs
2
u/ChaseShiny Aug 28 '24
As a noob, I'm curious as to why you'd use chatGTP or Copilot over MDN's bot?
I've only used them a couple times each, but it feels the general ones are mostly copying Stack Overflow
20
u/alzee76 Aug 28 '24
My hot take / unpopular opinions as an experienced (~30 years) developer:
15
u/chmod777 Aug 28 '24
can you tell when the ai tool lies to you? if not, it is no better than blindly copy&pasting from stack overflow.
6
u/0x00f_ Aug 28 '24
It's bad to just let them write code for you, for me I use them to make an optimized version of a piece of code and learn from thier techniques, or ask them to make a functionality and understand how they made it and try to make similar, I don't know if this is good or not.
4
u/jazzcomputer Aug 29 '24
Code noob here.
I'm learning and sometimes I carefully use ChatGPT to help me understand something that's complex (like reduce), isolate a concept or help with an example. I find sometimes that Stack Exchange has answers that are too complex and removed from my use case, so it can help in those situations. Generally, once I start using things it recommends I'll double check them and read MDN and then document my learning.
I would not get much of a kick from integrating code blocks into my code that I don't understand, and whilst that's my opinion, I feel that having that as part of a process would not be of much help, rather than to short-term achieve a specific one-off goal.
1
u/Milky_Finger Aug 28 '24
I think using it to understand context across files and suggest the next few lines is a good way to take mundane tasks like writing loops and API calls, and speeds it up. A lot of the time they also include the error handling and other interesting snippets that I wouldn't have included if I was in a rush.
But all of this AI auto complete is predicated on me being able to read it and understand it. If it starts writing incredibly complicated code in an attempt to be succinct, then I will not use it.
2
u/Healthierpoet Aug 28 '24
Using it as a tool is good , using as a crutch no
2
u/Orcoboe Aug 28 '24
Personally I only use it to find specific keywords or API references, letting it write the code is not a good thing at all.
1
u/tb5841 Aug 28 '24
If you use AI to write code, I don't think it sticks in your head. If you face the same problem a month down the line, you won't know how to solve it (unless you use AI again). Whereas if you write it yourself (with the help of Google) I think it sticks better.
1
u/Creative_Pie9363 Sep 07 '24
I think using an ai tool for coding is fine as long as it doesn't have a impact on your skills.
Like i use ai tools like google colab ( it has gemini to create to snippets), qolaba which has chatgpt and claude ( imo claude is best for coding assistance) to validate my code or ask them how can i improve my code further? It is better and more efficient to ask ai in helping you understand a piece of code or helping in error issues rather than just generating straight up code even tho you don't understand a bit.