What to Learn and What to Avoid When Taking Coding Help from ChatGPT
Dr. Greeshma Sharma
Cognitive Neuroscience | Organisational Psychology| UX Research | Design Thinking| AI |VR
As a developer, it's not uncommon to seek assistance from AI tools like ChatGPT while coding. These tools can provide valuable guidance, debug issues, and even suggest optimized code. However, while they can be incredibly helpful, it's crucial to be vigilant about the code they generate.
Recently, while coding, I encountered a line suggested by ChatGPT:
import ace_tools as tools; tools.display_dataframe_to_user(name="Restructured Data", dataframe=all_data)
At first glance, this line seemed strange and unfamiliar, so I decided to investigate further. After some research, I stumbled upon an interesting article that highlighted the potential risks associated with blindly running code generated by AI, especially when it involves unfamiliar libraries or functions (Link).
Key Takeaways:
1. Always Verify Unfamiliar Code:
Whenever you see code that you're not familiar with, especially when it involves importing libraries or executing functions, take a moment to verify its legitimacy. A quick search can reveal whether the library or function is commonly used or if it's potentially harmful.
2. Understand the Code Before Running It:
It’s tempting to copy and paste code directly into your project, especially when you’re in a rush. However, understanding what the code does is critical. This not only helps in ensuring that the code is safe but also enhances your learning and debugging skills.
领英推荐
3. Beware of Potential Vulnerabilities:
The article I found raised concerns about the possibility of malicious actors exploiting AI-generated code to introduce vulnerabilities. For instance, a line of code that seems harmless might be designed to download or execute malicious software on your machine.
4. Avoid Using Unverified Libraries:
As a rule of thumb, never use or install libraries suggested by AI tools unless you’re sure they’re legitimate and safe. Stick to well-known libraries that have a good reputation in the developer community.
Final Thoughts:
AI tools like ChatGPT can be a great asset when coding, but they are not infallible. As developers, we have a responsibility to maintain the integrity and security of our code. Always double-check AI-generated suggestions, especially when dealing with external libraries or unfamiliar functions. When in doubt, do your research before proceeding.
Stay safe and happy coding!