
Since their first day of learning to code, software developers are told of the importance of including comments in their code. For those totally new to coding, comments explain how the following few lines of code work; they help future developers understand what you’re doing and why.
Very few developers enjoy writing comments, and a lot of production code lives out in the world with little or no commentary.
That’s where AI tools can help. Today’s generative AI tools can read lines of code and automatically generate comments so you don’t have to.
However, it’s important to discern the limits of these tools, because a developer who misuses them while coding can cause issues that ripple throughout an organization for years to come. For instance, they don’t analyze your code and create documentation for your end users (there are almost certainly companies starting to build such tools, but technologically speaking, we’re not quite there yet). Let’s jump in!
The Tool Rundown
ChatGPT: ChatGPT is the ubiquitous AI tool, and it’s pretty good at analyzing code. You can paste code into it and ask it to explain the code, and it will do so well. And it’s also free (if you’re not interested in a for-pay tier). If you’re on a tight budget, this might be the way to go for your commenting needs—however, pasting your code into its web site isn’t exactly the best way to go, as that’s kind of tedious. What other options are out there?
GitHub Copilot: GitHub Copilot is an entire set of tools for creating software; it integrates into several different IDEs. Like most AI tools, it includes a chatbot so you can enter prompts, including questions about coding in general or about your code. If you highlight a section of code, you can ask it to analyze the code and add comments. You can specify the type of comments you want; for example, you can ask it to be traditional API style comments, or you can ask it to create more lay-person human readable comments.
Amazon Q for Developer: Amazon recently announced big advances in its Q line of products, and with it comes a chatbot that integrates with various IDEs, including VS Code. Q is excellent at analyzing your code and making suggestions on how you can build and deploy code within the AWS cloud infrastructure. While analyzing code, it can also generate comments and documentation; all you must do is highlight the code and ask it to add in some comments.
IntelliJ: JetBrains, the maker of IntelliJ, has more than one AI plugin for its InteliJ IDE. Its plugin called AI Assistant requires a separate license from IntelliJ itself, but once you install it and set up the license, the plugin can access to your code and provide many different features, including code documentation. Like other tools such as GitHub Copilot, the IntelliJ AI Assistant can help you produce code as well as document your code.
Tabnine: Tabnine’s assistant offers many ways to help with your coding. Submit an idea for your app via a prompt, and it can help provide an overall summary of the necessary code, and from there offer coding suggestions. You can also ask it to build a class from a single prompt; from there, it can provide unit testing code. In other words, it’s a thorough app for helping with development, and it does include comment generation (it can provide in-line comments or javadoc comments).
Tabnine has a free version, which is a basic AI code assistant with code completion. Beyond that, the company offers a single developer level that’s currently $12 per month after a free 90-day trial. Our suggestion: Try it for 90 days and see what you think. This app has all the hallmarks of something that is going to be big soon. It provides much more than just code documentation.
Readable.ai: Readable brags that you will “never write comments again.” This might seem like a dream come true for many developers. Presently, it’s available as a plugin to Visual Studio Code, with promises to soon be available to the full Visual Studio, IntelliJ, and PyCharm portfolio. It can provide different types of comments, including Docstring and inline comments. And again, their website promises more soon. Our pro tip? Try out the VS Code version… and keep watch for more features.
Sourcery AI: Here’s another tool you’ll want to check out. What’s interesting about Sourcery AI is that it can perform code reviews, which are normally done by humans. When homo sapiens review code, we usually look for issues such as bugs. Can AI do the same thing with the same degree of effectiveness?
Maybe… maybe not. But Sourcery AI does find problems in the code that humans might not otherwise uncover. While this doesn’t directly pertain to code comments, it does align with making sure the code is correct, which you can then use in conjunction with other tools to generate comments.
Replit: We hesitate to include Replit in here, because it’s an online IDE that stores your code on their servers, and it’s limited on what it can do. However, its AI tools are indeed top tier, with code completion tools that rival Github Copilot. When you put code into Replit, you can then ask its built-in AI tools to explain the code to you and generate comments. It excels at both generating code and analyzing existing code. If you haven’t tried it, you might be surprised at its capabilities.
Docify: Unlike other tools mentioned that provide documentation in addition to loads of other features, Docify was created specifically for generating code documentation. Docify lets you create comments in any of a huge list of human languages, as well as numerous comment formats. JavaDoc is the default, and there’s support for several other formats, including Epytext, which is for Python, as well as Doxygen.
DocuWriter.ai: DocuWriter is an example of a tool that generates not only code comments but API documentation as well. It’s a little on the pricy side, starting at $29 per month, but it supports pretty much all the major programming languages today. The API documentation it produces is what’s known as “Swagger compliant.” (Swagger is a set of tools for testing APIs.)
Conclusion
Ultimately, many of these tools have similar functionality, but they each have their own personality and quirks in terms of generating comments and documentation. Many of them also go well beyond documentation and offer other AI-powered features. As such, you’ll want to spend time exploring them and determine which works best for you.
If you’re just starting out as a developer, you’ll want to start with the big names that we listed first, such as ChatGPT, GitHub CoPilot, and Amazon Q for Developer. Get to know them and learn their nuances; then go from there.