I have worked a lot with trying to get ChatGPT to refactor some simple, working Ruby on Rails lib files (classes).
On all but the most simple code snippets and short methods, ChatGPT fails miserably:
See, for example today when I asked ChatGPT to refactor some prototype code, which works fine but has not been refactored:
Shared Refactoring Attempt with ChatGPT
ChatGPT Attempts to Refactor a Rails Library File (usda.rb) and Fails Repeatedly.
This is not abnormal. This is par-for-the-course for ChatGPT, generating nonsense as a generative AI chatbot who cannot understand "the big picture" when rewriting code.
I'm growing weary of all the ChatGPT and generative AI hype of how AI will replace highly skilled computer scientists and programmers. This is simply marketing hype by business and folks who do not actually develop production code.
As I have tried to explain to many people generative AI is nothing but a text completion engine based on a large language model, and as far a refactoring code goes, it's very primitive and seriously error prone.
I would call it "form over substance", meaning ChatGPT uses a trained LLM to cobble together code snippets and syntax but ChatGPT does not "understand" what it is doing.
The AI-world, businesses and the media have "super-hyped" ChatGPT and generative AI and the results will not be good for our industry as a whole.
Maybe we should post more experiences about how ChatGPT (can or cannot) refactor code? Businesses need to be made aware of the serious pitfalls of relying on generative AI for code refactoring, in my view.