Many LLM/AI services will generate computer code and some, such as GitHub Copilot, are designed specifically for code generation.
While these services can be valuable for writing code, concerns related to copyright and licenses have led to lawsuits from programmers, countries creating laws specifically regarding these services, and companies forbidding the use of code generation services.
Before you use these services for your own code, there are several things you should consider.
Will the code work?
There is no guarantee that the code generated from these services will work! While frequently called “AI” there is no “intelligence” behind them and they may generate incorrect, poorly optimized, or insecure code. Make sure to test any code they generate for you.
Where did the code come from?
Open Source code is generally released under licenses that state how the code can be used. Those contributing code to existing projects or expanding upon existing code must follow these license requirements. The services generating code have been “trained” on datasets of code that is publicly available online and released under many different licenses (though some, like Tabnine, are trained only on code with permissive licenses).
While stolen (or uncredited) code has been an issue for years, code generation is expanding this issue as LLMs have generated identical (or “nearly verbatim”) code without crediting the authors or following the terms of the licenses.
Some licenses now have specific guidelines for the use of AI-generated code. For example, the Apache Software Foundation has released a Generative Tooling Guidance document that provides information about how and when code generated by AI can be used in Apache-2.0 licensed projects. Other open-source developers have gone so far as to ask not to have derivative code uploaded to GitHub due to the way GitHub Copilot works.
What are you using the code for?