Using ChatGPT to Generate Code

Yep, that’s right. I’ve been using ChatGPT to generate wordpress compliant Code AND VB.NET compliant code. Full disclosure here… I have over 30+ years of code-development experience in multiple languages from Java, to C, C++, Pascal, Assembler, PHP, Perl, JavaScript and so on. So it’s not that I’m a slouch. But, in terms of productivity – I see a massive gain when leveraging ChatGPT to actually generate code or code snippets.

I’ve paid for the upgrade (monthly fee), to get the latest AI and to allow it to research the web for current specifications. I’ve even provided it with URL’s (like LearnDash REST API V2 specification) and asked it to parse the documentation and provide me with a core class that works with the variables / attributes defined.

It’s quite the journey. But the productivity gains are worth it. ChatGPT doesn’t make me “smarter”, it simply makes me more efficient. For example: I asked ChatGPT to build a REST class based on wordpress WP_REST_Controller, and provided it with parameters, and a few routes I need to handle. It did a great job writing the core class and core functionalities, including arguments, permission callback, methods supported, etc…

All of the “research and reading” that I normally would do to write my own class, were handled for me by ChatGPT. Thus saving me about 2 hours of “research and reading” just for this one object class. ChatGPT has made mistakes, for example I asked it to generate a REST API call that would list all taxonomies. It did – but it did not return them in a hierarchical format. So, I asked it to modify the code to retrieve hierarchies of taxonomies. Voila – it did!!

The Moral of the Story?

The moral here is: if you aren’t experimenting with ChatGPT to generate your base-code or code snippets, then you aren’t being as efficient as you can be. With the paid version, you can actually ask it to modify existing code segments to enhance, enrich, add parameters and variables, etc… In this particular case I asked ChatGPT to ensure that the REST API routes it generated, were authenticated with wordpress permissions.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *