AI has become prevalent in various domains, including software development. Many developers leverage generative AI to aid them in coding. Let’s explore the newcomer Llama3 and assess its suitability for C++ developers.
Related to Meta here’s a brief description of Llama3:
Our new 8B and 70B parameter Llama 3 models are a major leap over Llama 2 and establish a new state-of-the-art for LLM models at those scales. Thanks to improvements in pretraining and post-training, our pretrained and instruction-fine-tuned models are the best models existing today at the 8B and 70B parameter scale. Improvements in our post-training procedures substantially reduced false refusal rates, improved alignment, and increased diversity in model responses. We also saw greatly improved capabilities like reasoning, code generation, and instruction following making Llama 3 more steerable.
Certain developers may lack interest in AI generative tools due to their perception that the results are not yet mature. This sentiment is particularly pronounced among expert developers who swiftly identify areas for improvement in generated code. Nonetheless, I believe that for the majority of developers, generated code could serve as a valuable starting point for implementation, refactoring, or explanation purposes.
Let’s discover if Llama3 is suitable for C++ developers or not.
New coding:
We asked Llama3 to implement the dining philosophers problem in modern C++, and the outcome is interesting. It effectively utilizes modern C++ features, resulting in clean and comprehensible code.
However, we wonder if Llama3 is trained to utilize the most commonly used C++ libraries. To investigate this, we instructed it to employ the Boost library for implementing certain algorithms, and the outcome is impressive. LLama3 demonstrates adept utilization of Boost features.
Similarly, we tested Llama3’s proficiency with the Qt library by requesting it to implement a login form. Once again, the results are noteworthy, showcasing Llama3’s capabilities in utilizing the Qt library effectively.
Code Refactoring
After testing the refactoring of some pieces of C++ code, we remark that the refactoring not concern only these aspects:
- The variable renaming.
- Remove duplicate code.
- Reformat code style.
- Removing unecessary code.
- Modernizing C++ code.
But it refactor also the design by splitting methods in many other methods to make the code more clean and more maintainable.
Explains existing code:
Understanding a legacy C++ code become an important task, specially for new developers joining a C++ project. And asking Llam3 to explain a piece of code worth it, it describe in details what the code does.
Master C++ features:
When prompted to discuss a C++ feature, LLama3 provides concise documentation accompanied by numerous examples.
Conclusion:
Following our tests, we’ve found that Llama3 serves as an excellent assistant for C++ developers. It proves beneficial for tasks such as new coding, refactoring, explaining legacy code, and mastering C++ features. Therefore, to all C++ developers, I recommend giving it a try—you may be pleasantly surprised by its results.