Artificial intelligence (AI) and machine learning (ML) are rapidly changing the way we code and develop software. One of the newest additions to the AI-assisted programming toolset is ChatGPT, a large language model developed by OpenAI. This model can generate human-like text, making it a valuable tool for code generation and documentation. Another tool that’s gaining popularity is GitHub Copilot, which can help developers write code faster and more efficiently.
In this blog post, we’ll explore how these two tools can be used together to enhance the programming experience and achieve faster time-to-market.
ChatGPT can be used to generate code snippets, complete functions, or even entire programs. It can also be used to generate documentation, comments, and explanations for code. This can save developers a significant amount of time and effort and can also improve the quality of the code by reducing errors.
Here’s an example of how I used ChatGPT to assist in programming where I’m asking ChatGPT to create Products microservice using Asp.net Core and C#.
The following results were generated by ChatGPT.
General overview wasn’t good enough for me. So, I instructed ChatGPT to “Write code for Product model and Products Controller” and the code was generated as shown below:
It also created a set of comments as shown below. If there are algorithms generated, it provides detailed comments about the program.
Now, I want the products to be retrieved from a products service instead of a static list of products. I instructed ChatGPT to get products from a products service.
This can go on and on in a conversational manner. You get the idea.
GitHub Copilot, on the other hand, is a code completion tool that uses machine learning to predict what you’re going to type next. Copilot harnesses the power of OpenAI’s generative pre-trained language model, codex to suggest code and entire functions in real-time, right from your code editor such as Visual Studio. With Copilot, you can write code quickly and efficiently. Copilot uses context from comments and code and immediately suggests individual lines and whole functions. The product was also trained on natural language text and source code from several publicly available sources, including GitHub’s public repositories. It can also suggest and complete entire lines of code, making the coding process faster and more efficient.
Using these two tools together can enhance the programming experience by reducing the time and effort required to write code, and by increasing the quality of the code. The combination of ChatGPT’s ability to generate code and documentation with GitHub Copilot’s ability to predict and complete code can make programming more efficient and less error-prone.
One of the most important things to remember about ChatGPT is that it’s not here to replace developers. Instead, it’s here to be a conversationalist that helps developers boost their productivity by providing them with helpful information that they wouldn’t otherwise have access to. ChatGTP does this by building on the conversations developers already have with each other, and adding in context-relevant information from a variety of sources. For example, in the event of an error, ChatGPT can provide more context-specific information about what went wrong than you would find on StackOverflow or Google.
Marlabs created “Code Craft”, which is an accelerator that can generate code and unit tests based on pre-defined models and templates. Code Craft now harnesses the power of AI-assisted programming using ChatGPT and Github Copilot to accelerate application building and unit testing by 45%.