POSTED ON 22 APR 2024

READING TIME: 9 MINUTES

The AI Advantage: Exploring the Power of LLMs in Software Development

author-image
Kamil Bonna
Senior Software Engineer

Generative AI (GenAI) is taking our daily lives and professional endeavors by storm, revolutionizing the way we use technology to reach our goals. This is especially true for the software engineering industry where it has proven to open up a world of possibilities ranging from integrating fine-tuned large language models (LLM) into software products, to creating next generation developer tools powered by AI. The latter use case is especially interesting for developers because we constantly strive to make our work simpler and more efficient. Tools like Github Copilot, Tabnine or just ChatGPT can greatly improve productivity if used effectively.

When ChatGPT first launched in late 2022, I was curious about its capabilities - especially when it comes to programming. I decided to give it a try by carefully crafting three coding challenges ranging from trivial to moderately challenging and asking ChatGPT to solve them. The result was astounding — not only did the model solve all challenges perfectly, but the solutions were accompanied by detailed explanations of the "thought process" behind them. This gave me the idea — I wanted to find the most effective ways that I can use it on a daily basis to boost my productivity as a software developer. I decided to battle-test the model at work by letting it assist me on a wide variety of tasks that all developers are facing every day. However, before I could start my experiment I had to find the answer to one crucial question — how to use ChatGPT safely?

According to Reuters, there are three major risks associated with using GenAI in the work environment: violation of intellectual property ("IP") rights, disclosure of confidential information and non-compliance with laws and regulations. Being aware of these risks from the very beginning of my experiment allowed me to come up with three simple rules which enabled me to use AI in a safe way. I decided to:

  1. Use a separate, dedicated account to interact with ChatGTP.
  2. Avoid directly copying any project code into ChatGPT conversation.
  3. Avoid directly copying any ChatGPT code into the project codebase.

You might now wonder — how GenAI can be useful if we forbid developers to move code between ChatGPT and their project codebase? The key lies in the word “directly”. To explain, let's consider another very popular resource for our daily work, our beloved Stack Overflow. I think it’s safe to assume that whenever we use solutions found online, we first modify it for our use case by refactoring. On the other hand, before we post our technical question with the code example online, we first sanitize that example by removing any sensitive information, for example domain-specific nomenclature. The same should apply to interacting with external AI systems — keeping the conversation abstract reduces the risk of breaching IP rights, leaking confidential information or breaking regulations.

After addressing safety considerations, I embarked on a three-month journey to test my new "private coding assistant" - ChatGPT. My approach was straightforward: whenever I got stuck, wished to consult a colleague or search on Google, I opted to first give ChatGPT the opportunity to solve my problem. I generated dozens of unique conversations with hundreds of messages and code examples. This unique experience enabled me to improve my interactions with AI and gain insights into the types of problems best suited for resolution by the model. Throughout this process, I found myself repeatedly surprised — sometimes ChatGPT was able to solve really complex problems, while at other times, it failed to answer seemingly trivial questions. I discovered three primary applications of generative AI that considerably enhanced my productivity: replacement for search engines, elucidating new concepts, and generating boilerplate code.

Replacement for search engines

The volume of knowledge required for daily tasks as a software developer can be daunting. That's why search engines have traditionally been a developer's best companion. How often do we find ourselves forgetting that one git command we rarely use or the precise regex syntax to match something that we need? My journey showed that ChatGPT can be significantly more efficient in addressing these types of problems compared to traditional Google searches. This is because it eliminates many cognitive steps that we have to take to find the answers. When searching for that forgotten git command, we often find ourselves opening multiple websites from the search results, swiftly scanning through them to assess their relevance, piecing together relevant context, correlating it with our situation to finally synthesize the answer. Yet, these steps not only consume time but also come with a hidden cost of mental effort that could be used in more productive ways. That’s why GenAI can be so powerful — it can act as a personal coding assistant, adept at conducting these miniature research tasks and reporting precise answers in next to no time. Because such problems are well defined and restricted to a very specific area of knowledge, ChatGPT is usually very accurate in solving them. You might assume that replacing search engines with GenAI to solve simple problems is unnecessary since these issues can be resolved quickly. However, the true efficiency boost stems from the scale. If you perform just ten of these searches daily and it typically takes five minutes to find the answer, but ChatGPT enables you to trim it down to three minutes, it effectively grants you nearly two extra weeks each year!

Elucidating new concepts

The world of software development is constantly evolving, demanding that developers adapt and acquire new technologies throughout their career. Swift and efficient learning is vital to maintaining productivity. Each of us develops their own learning style — some like to read documentation, while others prefer diving straight into coding and tackling challenges hands-on. No matter your preferred approach to learn new technologies, one invaluable strategy can significantly accelerate your learning: seeking insights from a senior colleague who is experienced in the topic you're exploring. One issue with this approach is its practicality — it's not always feasible. Your colleagues might be busy with their own tasks, or there may not be anyone with expertise in the specific area you're looking into. When provided with suitable prompts, GenAI can act as your experienced colleague giving you very precise explanations to empower your learning. I’ve found that leveraging ChatGPT for learning proves highly effective, because it can explain technical concepts in a clear and concise manner. In some cases, the accuracy of the explanations may not be perfect, and our intuition may question the generated answers. To address these issues and enhance response accuracy, it might be beneficial to present contradictory evidence, provide additional context, or ask further questions to steer ChatGPT in the right direction. It is also crucial to double-check important facts and statements, as GenAI can sound confident and convincing even when presenting incorrect information. Despite these drawbacks, if used with caution, GenAI can serve as a valuable complementary source of information.

Generating boilerplate code

Most of the time we start coding from scratch, we require a basic template, commonly referred to as boilerplate code. This could be HTML for a blank page, sample code for a basic API endpoint within a web server, or initial configuration for a new CLI program. Boilerplate code is so prevalent in day-to-day software development that there are dedicated snippet repositories, IDE extensions and other tools aimed at quickly finding the appropriate template. However, a major drawback of these tools is their tendency to be language or framework-specific and lacking the capability to adjust the template to the user's requirements. It turns out that GenAI can serve as an exceptional "customized boilerplate code generator" for almost every widely-used coding language or framework. In my experimentation, ChatGPT provided me with numerous code snippets addressing a diverse array of issues, ranging from setting up a complete test framework in TypeScript and Jest to writing example Python CLI program capable of reading secrets from AWS and executing asynchronous HTTP requests with asyncio. Another widely used paid AI tool, Github Copilot, is also great at anticipating and generating code on the fly. While it may offer convenience, I still tend to prefer tools like ChatGPT for generating template code because it allows me to precisely specify my requirements and extend the boilerplate to align with my specific use case. This application of GenAI is particularly beneficial when learning a new language or framework, or when working outside one's primary area of expertise. In such scenarios, relying on tweaking and modifying example code is a great benefit, as it provides actual material for reference and experimentation.

Tips and tricks

I use ChatGPT and other GenAI tools in everyday software development to this day. Throughout these months of engaging with the model, I've discovered, through trial-and-error, several principles that enhance model response accuracy. Among the most important ones are:

  • Invest effort into writing well-thought-out prompts—try to be precise but avoid unnecessary complexity. If tackling a particularly difficult issue, break it down into smaller, more manageable problems and address them one by one.
  • If you are not satisfied with the answer, don't give up. Attempt to rephrase the problem or request clarifications and adjustments until you obtain a satisfactory response.
  • Use separate chat threads to ask questions about distinct domains. Dividing discussions based on programming language, framework, or area of expertise provides ChatGPT with additional context for subsequent questions.
  • Improve readability and comprehension by using Markdown syntax for code examples and code references within the text.

AI symbol levitating above human hand

Summary

My journey with GenAI in software development has been enlightening, and revealed the potential of tools like ChatGPT to revolutionize our approach to everyday challenges. From replacing search engines to accelerating learning new technologies, tools like ChatGPT consistently prove invaluable in boosting productivity and problem-solving. By adhering to safety protocols and employing effective strategies when engaging with generative AI models, developers can leverage their capabilities to tackle routine tasks, allowing for greater focus on the most intricate and creative problems. As we continue to explore the possibilities of generative AI, it becomes increasingly evident that it is not merely a tool, but a transformative force shaping the future of software engineering.

TECH LEADERS TRUST SONALAKE

We make software better every day

Get in touch

Copyright © 2024 Sonalake Limited, registered in Ireland No. 445927. All rights reserved.Privacy Policy

Nr Cert. 18611 ISO/IEC 27001