Coding and ChatGPT

Coding and ChatGPT#

Artificial Intelligence is a new resource that you can leverage to help you learn a programming language, to improve your programming skills, and for assistance with your programming tasks. To get the most out of, e.g., ChatGPT takes, however, also some testing and exploring to learn how to phrase your questions to get best results and for which tasks it can be most useful. Also, remember that the results you will get are not necessarily correct, which means that you cannot rely on these results completely. Whenever you use AI, make sure that you fully understand what your code is doing. If you don’t, there is no guarantee that the code is doing what it is supposed to do. This means that despite the advances in AI, you still need to learn how to program yourself.

Also, you may want to consider the environmental footprint of using AI, see e.g., this web article or this one.

How to use AI in your programming tasks#

Read this great Real Python tutorial on how to use ChatGPT as a Python coding mentor to become a better programmer. ChatGPT can be very useful in helping you, for example, to debug your code, to comment your code, to find alternative solutions for your coding problem (i.e., you may learn about new packages or features of the programming language), to discover new packages or functions that may help you to tackle a programming task, to write tests for your code, to improve the readability of your code, to refactor your code into smaller units, etc. You see, there are many applications, but always remember, to test and understand the code.

I have also asked ChatGPT (Academic AI) directly how it could help you best with learning a programming language and tackling programming tasks. Here is the short version of the response I got (I told it that this for a course on scientific programming):

  1. Explaining Concepts: clarifying programming concepts, breaking down complex topics, customizing explanations

  2. Code Examples and Demonstrations: providing code snippets, debugging examples, exploring libraries

  3. Problem-Solving Assistance: algorithm design, code debugging, optimization

  4. Learning Resources: recommending resources, explaining documentation

  5. Encouraging Best Practices: code readability, testing and debugging, version control

  6. Supporting Scientific Programming: numerical computation, data visualization, reproducibility

  7. Encouraging Independent Problem Solving: guided problem solving, debugging strategies

  8. AI-Specific Guidance: how to ask questions, limitations of AI, ethical use of AI

  9. Encouraging Exploration: experimentation, project ideas

  10. Providing Feedback: code review, alternative approaches

It ended with a list on how to use AI effectively for programming:

  1. Be Specific: Provide clear and detailed questions, including code snippets and error messages if applicable.

  2. Iterate: Use my responses as a starting point and refine their understanding or code based on feedback.

  3. Verify: Always test and verify AI-generated code or explanations to ensure correctness.

  4. Learn from Feedback: Use my suggestions to deepen their understanding of programming concepts and problem-solving techniques.

And I think this final piece of advice from ChatGPT summarizes it nicely: Use AI as a Supplement, Not a Substitute.