How Artificial Intelligence Changed Programming

It is no secret that in 2024 neural networks became an accessible and convenient tool that is used everywhere. Almost every service now claims to have functions with AI, but of course, various models are actively used in development.

My name is Denis, I have been working in the SEO and IT industry for about 15 years, I started working in technical support for internal products of Kokoc Group, then moved to development and for the last 2 years I have been holding the position of Python developer. I studied how IT works with neural networks in general and in my department. And I was surprised that AI penetration in the company is greater than in the industry. Colleagues even have their own AI community Kokoc ДрAIв (they developed an AI assistant, a digital strategist bot). Although, unfortunately, as the study showed, we do not use all the possibilities of artificial intelligence. But let's take everything in order …

You can scroll down to the second part of the post if you are familiar with the AI ​​background.

Main areas for using AI

Code generation

Neural networks trained on code work data can create fragments of them or create full-fledged functions according to the text description specified by the programmer. Training neural networks on code work data takes place in several stages. These stages include data collection, preprocessing, model training and testing.

  1. Data collection:

    • Data sources: Neural networks are trained on data from various sources, such as code repositories on GitHub, questions and answers on forums like StackOverflow, and other open-source programming-related resources.

    • Data types: Includes code examples, code comments, discussions of problems and solutions, documentation, and tutorials.

  2. Data preprocessing

    • Data Clearing: This step removes duplicates, comments that are not related to the code, and any other irrelevant data. Important data, such as programmer comments, can be retained for context analysis.

    • Data Markup: Code is marked up for syntax and semantics. This includes identifying code structures such as functions, classes, variables, and comments.

    • Data separation: The data is divided into training, validation and test sets for subsequent training and testing of the model.

  3. Model training

    • Model architecture: A neural network architecture suitable for natural language and software code processing tasks is selected.

    • The learning process: The model is trained to predict the next line of code or bug fix based on previous context. Machine learning techniques such as gradient descent and backpropagation are used.

    • Using context: The model learns to understand the context of the code. This is achieved by training on large sequences of code, where the model learns to predict code fragments based on the surrounding context.

  4. Testing and Validation

    • Performance evaluation: The model is evaluated on a test set, where its accuracy in predicting correct code fragments and fixes is measured.

    • Bug fixes: The model is tested for its ability to detect and correct errors in the code. It is checked how effectively it can suggest correct fixes.

    • Iterative improvement: Based on the testing results, the model is refined and further trained to increase its accuracy and reliability.

These steps ensure the creation of powerful tools that can help developers write, fix, and optimize code based on extensive experience and data collected from many sources.

Finding errors and correcting syntax

By analyzing context and processing natural languages, neural networks can automatically find errors made when creating code and correct them. In performing this task, the technology is based on the syntax used when creating a software product – this allows you to offer developers accurate and effective solutions, saving their time.

Here are more specific aspects of this technology:

  1. Contextual analysis: Neural networks like Codex and Copilot analyze all available code context, including previous lines, functions, and comments. This allows them to understand how each part of the code interacts with the rest of the program, which is especially important when finding bugs.

  2. Programming language recognition: Neural networks are trained on a huge amount of data, including many programming languages, such as Python, JavaScript, Java, C++, Go and others. This allows them to automatically recognize the programming language and apply the appropriate rules of syntax and semantics.

  3. Detecting syntax errors: When analyzing code, neural networks can detect syntax errors such as incorrect use of parentheses, missing semicolons, or incorrect variable declarations. For example, if a colon is missing after an if statement in Python code, a neural network can notice this and suggest a fix.

  4. Semantic analysis: In addition to syntax errors, neural networks are also capable of detecting semantic errors that are related to the logic of a program. For example, they can detect incorrect use of data types or incompatibility between function arguments and its call.

  5. Accuracy and errors: Although neural networks are highly accurate at detecting and correcting errors, they are not infallible. In some cases, they may make mistakes, suggesting incorrect fixes or failing to notice more complex logical errors. Therefore, developers should review proposed changes and use them with caution.

  6. Feedback and training: Neural networks continue to improve thanks to user feedback. When developers accept or reject suggested corrections, this information is used to further train the models, which improves their accuracy and reliability over time.

This is how neural networks use context and knowledge of programming languages ​​to automatically detect and correct errors, making the development process more efficient and convenient.

Refactoring

Neural networks can also be used when working with already working code. Code refactoring is essentially its optimization and improvement. As they say, there is no limit to perfection. An AI assistant based on analysis can help make already written code better, more reliable, more readable, for example, point out some controversial points that the developer could have missed (suggest a more suitable package, point out the presence of an existing similar function in another part of the code that can be reused instead of writing a new one, etc.). By optimizing the code, the neural network improves the software product, adjusting it to the needs and interests of potential users. In addition, refactoring allows you to make the final code more structured and less loaded – it will be more convenient to work with in the future.

Using AI in Cocos

In July 2024, we conducted a survey among Cocos employees to understand how and how actively they use AI assistants in their work.

87% (!) of respondents indicated that they use neural networks in their work in one way or another. The frequency of use, of course, varies, but it is clear that most employees resort to their help at least several times a week, and 20% of respondents use neural networks in their work daily.

The basic distribution by types of tasks to be solved is as follows:

Below are some real cases shared by employees of the group of companies:

  • “Big data analysis validated competency models based on values”

  • “The most useful: Generating code for a text description, generating API documentation for Swagger based on code, tips for parsing and optimizing complex SQL queries”

  • “Once I had to throw a piece of code with layout onto a website. I jumped into GPT, wrote a technical task, corrected it a couple of times and took the finished piece when with html and css”

  • “Generation of photo and video materials”

  • “It helps me create a structure for my presentation, which I then layer on top of. It saves a lot of time.”

  • “Automatic generation of test cases based on the task description, which the performer can use to check their work. This also helps the tester see different scenarios faster without generating them themselves”

  • “At one time, GPT wrote truly unique articles for SEO. A colossal saving of time and money”

At the same time, 85% of respondents are satisfied with the results obtained in most cases. I will note that according to the survey results, chat bots built into various messengers are mainly used, as well as versions of neural networks on specialized resources. And only 15% use the integration of assistants into working IDEs and other more complex options for interacting with AI.

But it is precisely this possibility of using AI assistants that we would like to draw special attention to in the context of programming. Below we will consider integration based on GitHub Copilot, as the most popular tool at the moment.

What is GitHub Copilot?

Among the huge variety of neural networks, the number of which is only increasing every day, we can highlight several technologies that are capable of qualitatively processing and refining code. One of the most popular and well-known AI assistants is certainly GitHub Copilot. This is a modern tool designed for programmers using artificial intelligence technology. It helps to create code faster with minimal effort.

At the core of GitHub Copilot is the OpenAI Codex algorithm, a new artificial intelligence system. The software’s authors emphasize that it “understands” context much better than other products of this type on the market. Regardless of whether a developer is working on a document, comment, or feature, GitHub Copilot provides context-sensitive suggestions based on the data it collects. In just seconds, GitHub can present an example of how to use a new feature or object.

The program “learns” how a given programmer writes, and based on the collected information, offers autocompletion of certain code elements during work. The tool allows you to create code more efficiently and quickly, which makes GitHub Copilot increasingly popular.

A big plus is that GitHub Copilot is available for installation as an extension in many widely used IDEs, including products such as Visual Studio Code, Neovim, and JetBrains. This integration allows you to conveniently use all the features and benefits of AI directly during the usual development process, without having to be distracted by accessing third-party resources, separate chatbots, and websites.

Installation is most often carried out using the built-in IDE plugin, and setup also does not take much time and is carried out according to the instructions in a few clicks.

Inside the IDE, Copilot is presented as a separate item in the context menu, which allows you to quickly perform “hot” actions with the selected code fragment, or continue working in the window of the built-in chatbot plugin.

How can using GitHub Copilot help developers?

Using Copilot offers a number of useful features to make the programmer's work easier and simpler:

  • Generate code based on a request that specifies the purpose of your work

  • generating code based on a repeating pattern

  • code functionality check

  • Checking for errors and options for correcting them

  • suggestions for optimizations and replacement content for the specified code fragments

  • explanation of the principles of operation of the code and its individual fragments, taking into account the analysis of the code base of the current project

  • search and output of necessary documentation

  • automatic writing of documentation for program codes

It is very convenient that AI tips are offered directly during the development process. This allows you to immediately assess their usefulness and use the proposed solutions, or continue writing the code yourself.

For more detailed work, you can go to a separate chat window of the Copilot plugin, where all the above-mentioned features are fully available in the already familiar mode of dialogue with the bot.

For example, you can get a detailed explanation of what the highlighted code fragment does.

Or ask the AI ​​to optimize it. If the developer is satisfied with the result of execution, you can immediately replace the existing fragment with it by pressing one button in the chat. Thanks to the above, Copilot allows developers to significantly reduce the time spent on performing many routine tasks, searching for documentation and information on the use of individual commands, syntax and principles of operation of various functions and modules. Copilot will also be extremely useful for novice programmers, helping to avoid many common mistakes and quickly understand previously unfamiliar aspects of development.

Does GitHub Copilot generate perfect code? Unfortunately, no. On the official website, you can read that although the creators make every effort to ensure that the tool offers the best match, there is no guarantee that the proposed solutions will work in practice. Thus, as part of testing in Python, the program effectively handled 43% of requests on the first try and generated correct working code after 10 attempts in 57% of cases. For this reason, it is very important to carefully check and test each solution proposed by the neural network before exploitation.

In addition to Copilot, there are also many other specialized AI services, such as StarCoder, Wolverine, Blackbox AI. These tools are designed to support developers in various aspects of programming, including writing code, automatic debugging, analysis and suggestions for improving the code. I have only briefly familiarized myself with them, so I would appreciate it if you shared your impressions and experience in the comments!

Conclusion

Artificial intelligence, even at the current stage of development, is becoming an integral part of professional activity, especially in the field of programming. Examples of AI use in our company show that it can improve work processes, reduce the time for performing routine tasks and increase overall productivity. But of course, we will continue to integrate into work processes and train employees in effective use, otherwise you can stop at chat bots, and the possibilities are much wider, since even integration into IDE is just the tip of the iceberg.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *