Artificial intelligence (AI) is increasingly influencing our daily lives. Speech recognition and translation, virtual assistants like Siri and Alexa, self-driving cars and even medical diagnoses and treatments are benefiting from advances in AI research. In software development, AI is also becoming increasingly important as it can help work faster and more efficiently. I want to take a look with you at how AI can be used for code generation, automated testing, and much more. Let's dive into the world of artificial intelligence and learn how it can revolutionise work in the field of software development.
Perhaps you can guess already. ChatGPT wrote this paragraph for us and the result is quite respectable. Admittedly, this kind of introduction probably generates little more than a weary smile today, but at the beginning of 2022, the quality of this AI output would surely have caused many people to marvel in disbelief.
But let's forget this first attempt to impress with ChatGPT and instead try to start in the classic way with a joke. So, please ChatGPT, generate a joke about how AI will change software development in the future?
Why will developers no longer be tired in the future? Because AI systems will do all the repetitive work while developers sit back and watch them improve the programmes!
While the comedy industry seems to be safe from ChatGPT for the time being, some software developers may already be thinking about their future. However, according to the current state of development, AI tools will not be able to build complex, secure and high-quality software systems without human help in the foreseeable future. However, those who permanently refuse to work with AI tools such as ChatGPT or GitHub Copilot can quickly lose touch with the competition in terms of speed and efficiency.
In case there are actually still people who don't know about ChatGPT, we have summarised the most important facts compactly here:
The American company OpenAI released the chatbot ChatGPT on 30 November 2022. With its ability to understand natural language contextually and respond in natural language based on huge amounts of data, many researchers see this as the beginning of disruptive changes in countless industries. However, it remains to be seen how quickly and to what extent these changes will occur. One thing is certain, however: ChatGPT has aroused great interest. Microsoft, the largest investor in OpenAI, has also equipped the search engine Bing with a chatbot based on the same model as ChatGPT. Remarkably, these chatbots have also been trained with code and can therefore generate and understand code.OpenAI and Microsoft also play an important role in the second AI tool that we will focus on here: GitHub Copilot. In contrast to ChatGPT, this tool was trained and developed specifically for coding. Copilot is based on the OpenAI model Codex and GitHub (part of the Microsoft empire) released this AI helper on 21 June 2022 and has since gained well over one million active users.
Useful Helpers
In the following section, we would like to take a closer look at those use cases in which AI tools can provide valuable support in coding. Probably the most obvious scenario is to want to program something and have the code generated by an AI. The clearer or more general the task, the higher the chances that this approach will succeed. Every program consists largely of code that a large number of people have already programmed in this or a similar form. And this is precisely where the strengths of generative AI tools lie. They can adapt this code to the respective context and make it available. Because of their huge knowledge base and the context provided to them by the users, this task falls within their core competence. A use case for this could be wanting to remove unexpected blank lines from a CSV file. A precise question to ChatGPT is enough and executable code comes back as an answer.
Source: ChatGPT
Source: GitHub Copilot
However, as before the AI revolution: if there is a suitable software library that can solve the existing problem, we recommend using it. The code is well maintained there and potential security issues are dealt with. Sometimes, however, it is worth taking a shortcut and resorting to AI tools - especially in the case of boilerplate code.
Boilerplate code refers to those sections of code that do not really solve the core problem and are often copied from existing code and modified to work in the new project. Often these sections are the same in different projects. Modern programming languages and frameworks are characterised by reducing boilerplate code to a minimum. Nevertheless, this code cannot be completely avoided and it is precisely here that the use of AI tools can contribute significantly to reducing the workload.
Another use case, this time from the Java-Spring universe, could result from securing requests to an application. Software developers with Spring security experience know all too well that there is a lot of boilerplate code in this area that has to be searched for and copied over and over again. This task could just as well be outsourced and the initial design generated by an AI tool.
Of course, the greatest possible synergy effects result when the AI tool is directly integrated into the development environment, as is the case with GitHub Copilot, for example, but there are also IDE plugins for ChatGPT. Here, the developer only has to type the name of the method and Copilot promptly provides suggestions on how the respective method could be implemented. For comments in natural language, Copilot attempts to implement the logic described in it. Those who have not yet ventured into this or similar AI tools should be prepared for some impressive results.
AI tools are also particularly useful when you want to discover a new programming language or framework. Beginnings are always difficult, but a little easier if you can take your first steps with AI code completion. GitHub Copilot is often referred to by its users as auto-completion on steroids. A choice of words that is quite appropriate. Once you get used to the Copilot rocket, any standard autocomplete feels like a horse-drawn carriage by comparison.
Other topics that may not immediately come to mind with AI tools are automated tests and documentation. It is always surprising how much time is spent on test automation during development, and usually for one reason: tests mean stability and a low susceptibility to errors, even when the product is continuously growing. Unit tests (tests of small, self-contained logic units) are always particularly time-consuming because dependencies on other parts of the program must be simulated (mocking).
Anyone who sends the code to be tested to ChatGPT can have an initial template generated for a unit test. Usually, 99 % of the time, the result will not immediately look the way you wanted it to. However, depending on the complexity of the method to be tested, it can be much faster to adapt this AI template than to write everything from scratch. It works similarly with documentation. By asking for suitable documentation, the AI tool is sent the code and you get a first result back in response. Generally, the AI tool also adheres to the formatting of the corresponding programming language. Often, a satisfactory result can be achieved more quickly on this basis than when working entirely without a template.
When dealing with ChatGPT, it is important to consider carefully what code is shared with the AI system via the web application. OpenAI's current terms of use state that input to ChatGPT is visible to OpenAI staff. Sensitive information and critical pieces of code should therefore not be shared unconditionally with ChatGPT. For the GPT API, on the other hand, which is also provided by OpenAI, the principle applies that the content is not made accessible to OpenAI. As a company, you should therefore consider whether you offer your own version of ChatGPT internally, e.g. via the API, in order to increase productivity in software development in a secure way.
By the way, AI tools are also well suited for research to get a first overview. With ChatGPT, for example, you can not only find relevant literature tips on a certain topic, but also generate summaries of entire books.
Focus on the Core of the Problem
The code written by AI tools should always be checked. The generated code may be faulty or slow, and may also contain security issues. Even working code should not simply be adopted immediately, but only after it has been understood and is the best possible solution to the actual problem.
As impressive as generative AI tools may be, these models do not yet have the ability to check causal backgrounds and ensure the truth or functionality of the output. In the foreseeable future, however, it is very likely that AI tools will be developed that can automatically execute and test generated code. Nevertheless, even then there is no guarantee whether this code actually meets the specific requirements. Therefore, we recommend: Test and understand each solution before adopting it.
Anyone who is familiar with current AI tools will realise relatively quickly that they can be very helpful in important aspects of software development. However, their use is limited in those areas that are most valued by the stakeholders or are decisive for the awarding of a contract. The core functionality and the special features of a program or the reason why something has to be programmed in the first place instead of using an existing product is difficult to outsource to an AI tool.
The closer you get to this central logic in the code, the less helpful AI tools generally are. ChatGPT will rarely find an answer to a creative solution, for example, to get a few more milliseconds out of complex processes. And even if user-friendly interfaces can currently be generated by AI tools, truly innovative designs still need people to make them special. Software is created by people with the help of these tools, not the other way around.
In a few years, it may be different, but for now, software development remains rightly in the hands of humans. However, AI tools can greatly assist in automating repetitive and time-consuming programming tasks. This allows developers to focus on more exciting tasks and work through the rest more efficiently. This is an advantage that should not be underestimated.
We would like to conclude our blog post about the possible uses of AI tools in software development, as we started it, with ChatGPT. We asked the tool to summarise in one sentence what it thinks of all this:
AI tools optimise software development, but human creativity and critical thinking remain irreplaceable for first-class solutions.