Location>code7788 >text

AI Programming Assistant Things

Popularity:229 ℃/2024-08-06 07:57:09

Recently, when discussing the requirements with the old pole of programmers around me, I was surprised to find that he didn't use AI programming assistant. For a moment there were 2 thoughts flashing from the brain, and then there was a hint of contempt in the heart:

  1. It's amazing that you don't use something as good as an AI programming assistant.
  2. As an old programmer, I'm surprised you don't keep up with what's going on.

But it is true that there are some old poles are used AI programming assistant, and then choose to give up, what specific reasons, let's talk about it. First of all, let's talk about a few commonly used AI programming assistants on the market.

1. Several AI programming assistants

GitHub Copilot

GitHub Copilot, an AI programming assistant from GitHub and OpenAI, was one of the first programming assistants I used. I tried it immediately when it first launched and it was so good! At that time, I immediately felt that it liberated a lot of productivity. I'm still satisfied with the understanding of Chinese and the quality of the generated code.

However, because of the price (more than 1000 yuan a year), I have been using the student version and proxy version. But half a year ago found that GitHub for the proxy version and the student version of the check is more strict, Copilot often dropped, in addition to the server is originally in foreign countries, sometimes the response speed of the generated code is really a little slow, and gradually give up.

Wenshin Express

Comate is an AI programming assistant launched by Baidu. After giving up GitHub Copilot, I searched for it in China, and found that the one available at that time was basically Comate. After trying it for a while, I think the speed of generating code is okay, but the accuracy or adoption rate of the code is a bit worrying.

But at that time, I thought it was free, just use it, not the right code aESCThe key is also over, and the appropriate code aTABThe key is adopted, and it saves some work, more or less.

After all, at the time, I had ChatGPT generate code for unfamiliar domains or large sections of code, and the main scenario in which I used Wenshin Express was to assist in generating some simple or repetitive code.

Tongyi spiritual code

Tongyi Lingcode is an AI programming assistant from Alibaba, based on the powerful Qianwen2 big model. Tongyi Spirit Code is the AI programming assistant I am using recently.

By chance, I was invited to participate in an AI salon in Ali, and there was a small topic that talked about Tongyi spirit code. Originally, I felt that the effect was general when I used Wenxin fast code, and I thought that Tongyi spiritual code was just like that.

Later on, I saw that the buddy who preached about the Tongyi Spirit Code was full of passion and was especially proud of it, as if he had built this product. This aroused my curiosity. At that time, he proudly said that their big model how good and how cattle, Tongyi spirit code to do how much how much fine-tuning, how much how much optimization, how much importance they attach to security.

Granted, I don't believe all of what he said, but I really was infected by his passion at the time (perhaps out of empathy as a product person).

That night, I tried Tongyi Spirit Code. I don't know whether it is safe or not, but the speed of code generation is quite fast. Then, I wrote another 1 hour of code test, and found that the generated code correct rate and adoption rate is not bad, and then I have been using it.

Through this choice, one thing is made even more clearHelp yourself and God will help you... A product person must be full of themselves about their product. Even if you are a programmer, in the age of AI, you have to see yourself as a product person.

ChatGPT

ChatGPT is really always the No1, when it comes to code generation accuracy and natural language comprehension, even in Chinese scenarios, ChatGPT is the best.

The following is a small example of ChatGPT and Tongyi Lingcode implementing code for the same requirement, friends can feel it by themselves.

demand (economics)

I have an Html file and I want to batch replace the font-size value in it by twice the size. And also replace the value of line-height, also enlarged by two times. Can you please write the code in java

ChatGPT Realization

import .*;
import .*;
import .*;

public class HtmlFontSizeLineHeightMultiplier {
    
    public static void main(String[] args) {
        String filePath = "";
        try {
            String content = new String(((filePath)));
            String updatedContent = updateFontSizeAndLineHeight(content);
            ((""), ());
            ("File updated successfully.");
        } catch (IOException e) {
            ();
        }
    }

    private static String updateFontSizeAndLineHeight(String content) {
        // Pattern to match font-size and line-height in CSS
        Pattern fontSizePattern = ("font-size\\s*:\\s*(\\d+(\\.\\d+)?)(px|em|rem|%)", Pattern.CASE_INSENSITIVE);
        Pattern lineHeightPattern = ("line-height\\s*:\\s*(\\d+(\\.\\d+)?)(px|em|rem|%)", Pattern.CASE_INSENSITIVE);

        // Replace font-size values
        Matcher fontSizeMatcher = (content);
        StringBuffer updatedContent = new StringBuffer();
        while (()) {
            String originalValue = (1);
            String unit = (3);
            double newValue = (originalValue) * 2;
            (updatedContent, "font-size: " + newValue + unit);
        }
        (updatedContent);

        // Replace line-height values
        Matcher lineHeightMatcher = (());
        updatedContent = new StringBuffer();
        while (()) {
            String originalValue = (1);
            String unit = (3);
            double newValue = (originalValue) * 2;
            (updatedContent, "line-height: " + newValue + unit);
        }
        (updatedContent);

        return ();
    }
}

Tongyi Spirit Code Realization

import .*;
import ;
import ;

public class HtmlFontSizeModifier {

    public static void main(String[] args) {
        String inputFilePath = "path/to/"; // Input file path
        String outputFilePath = "path/to/"; // Output File Path

        try {
            modifyFontSizesAndLineHeights(inputFilePath, outputFilePath);
        } catch (IOException e) {
            ("Error processing file: " + ());
        }
    }

    /**
     * modificationsHTMLin the filefont-sizecap (a poem)line-heightThe value is twice the original。
     *
     * @param inputPath Input file path
     * @param outputPath Output File Path
     * @throws IOException If an error occurs during file processing
     */
    public static void modifyFontSizesAndLineHeights(String inputPath, String outputPath) throws IOException {
        try (BufferedReader reader = new BufferedReader(new FileReader(inputPath));
             BufferedWriter writer = new BufferedWriter(new FileWriter(outputPath))) {

            String line;
            Pattern fontSizePattern = ("(font-size:\\s*([0-9]+)(px|em|rem))");
            Pattern lineHeightPattern = ("(line-height:\\s*([0-9]+)(px|em|rem))");

            while ((line = ()) != null) {
                Matcher fontSizeMatcher = (line);
                Matcher lineHeightMatcher = (line);

                if (()) {
                    String fontSize = (2);
                    String unit = (3);
                    double newSize = (fontSize) * 2;
                    line = ((), "font-size: " + newSize + unit);
                }

                if (()) {
                    String lineHeight = (2);
                    String unit = (3);
                    double newLineHeight = (lineHeight) * 2;
                    line = ((), "line-height: " + newLineHeight + unit);
                }

                (line);
                ();
            }
        }
    }
}

As you can see, ChatGPT is better in terms of understanding the requirements, and ChatGPT is also better in terms of implementing the logic of regular matching.

My recommended usage

My recommendation for the AI programming assistant option is a two-pronged approach:ChatGPT + AI programming assistant from one of the major domestic manufacturers

There are 3 core reasons:

  • ChatGPT has the strongest natural language understanding and the highest accuracy for generating code that can be used to generate small chunks of requirement code.
  • Although the AI programming assistant of a major domestic manufacturer may be weaker in terms of natural language comprehension and code accuracy, it is OK for generating simple repetitive code and fulfilling simple requirements. Moreover, domestic programming assistants are faster in generating code.
  • The development speed of the domestic big model we have seen with our own eyes, although there is still some gap with the foreign big model, but also keep catching up. We need to have confidence in the development of domestic large models.

2, the working principle of AI programming assistant

Big Language Models and Powerful Arithmetic Behind AI Programming Assistant.. On top of the big model, fine-tuning training of code and documentation in the programming domain was performed to make it more usable for programming scenarios.

Specifically when programming, the AI assistant will generate code snippets that have relevance to the current requirements based on contextual information such as your code comments, function names, code files, and so on, combined with open source code libraries that have been fed to it previously.

3, the advantages and disadvantages of AI programming assistant

There are still many developers who are repelled by AI programming assistants for various reasons, and we do have to recognize that AI programming assistants have drawbacks, but they also have many advantages.

vantage

  1. **Enhance efficiency and save time:** AI Programming Assistant generates code quickly and reduces the effort of manual writing. Especially in highly repetitive and routine logic programming tasks, it can significantly improve efficiency, giving developers more time to focus on core logic and innovation.
  2. Code Quality Improvement: Sometimes I can feel that the quality of AI-generated code is better than what I write myself.
  3. **Accelerated Knowledge Acquisition:** With the AI Programming Assistant, developers can quickly acquire a variety of programming knowledge and technical solutions, significantly shortening the learning curve. It is also able to provide instant advice when writing code, avoiding developers from searching and consulting information for a long time. This point, I feel very deeply, I remember two years ago when I learned Flink and Golang, when I swept through the documentation, should be how to practice the project is still no way to start, fortunately, there is an AI programming assistant, so that I quickly learn the knowledge of the unknown field, and can quickly make the project.
  4. Learning from AI: Developers are also constantly exposed to new code patterns and best practices as they interact with AI, thus improving their programming skills and technical proficiency.

drawbacks

  1. Limited ability to handle complex logic: While the Programming Assistant is pretty good at handling simple and common code snippets, it is weak at handling complex logic. In cases involving complex algorithms or business logic, it basically can't give the right code. So, most of the time, the code generated by the AI programming assistant still needs to be gone through by itself.
  2. It's a safety hazard.: When using an AI programming assistant, you need to throw code to the AI programming assistant and then it goes and guesses the relevant code. There is no way of knowing if it gets the code and does something with it.
  3. Ease of dependency: For developers who have been using the AI programming assistant for a long time, it is easy to form a dependency. Most of the scenes will develop the habit of waiting for AI generation, and once they leave the AI programming assistant, it is indeed somewhat uncomfortable. But this point is sort of benevolent and wise, AI development is the general trend, just like the Internet back then, all the unaccustomed to the future will become as ubiquitous as the air.
  4. Easy to develop the habit of not thinking: Developers who have been using AI programming assistants for a long time are too lazy to think about most of the code implementation on their own, except for thinking about the business logic. In order to avoid becoming lazy, every time after the AI assistant generates code, I will go through it and then compare it with my own thinking. But this is not necessarily a disadvantage, AI is not to liberate our thinking and productivity, is not to let us from a simple implementer, into a manipulator.

4. Why some developers don't use AI programming assistants

I have read a data before that there are about 10 million programmers in China, and it is expected that more than 2 million of them are using AI programming assistants, and the number has been soaring. I also learned from some sources that some developers are reluctant to use AI programming assistants for the following reasons:

  • Auto-prompted disaster: When using AI programming assistants, prompt code is generated almost every time you tap, which makes many developers feel that the AI interrupts their thoughts, or sometimes compulsive and have to go to see if the AI prompt code is correct. This pain point the major manufacturers are trying to solve, recently I have obviously felt that the place of triggering the prompt has become less, I believe that it will become more and more intelligent.
  • a safety hazard: Some individuals and businesses are more worried that using an AI assistant will leak their core code, so they have been afraid to use it. Although all major vendors are trying to publicize their security strategies and strongly emphasize that they don't store and use code, no one seems to believe them.
  • Unwillingness to keep up with the timesSome developers are really conservative and stuck in their ways and don't want to try new things. I do think that no matter how good or bad a new thing is, at least try it first.
  • Underestimating AI's capabilities: Some developers feel that AI is not capable of writing bad code. I think the ability of AI has been enhanced, and some aspects are much stronger than people, there is no need to be so confident, try a few more times, you will find that AI in writing repetitive code and simple logic is still very strong. Throw things to the AI, and leave yourself more energy to think about complex business problems, is not more flavorful.

I have a few things to say about the security concerns of some developers and organizations:

  1. There is no need for a big manufacturer to take your code for secondary training, because if the big manufacturer wants the AI assistant to become better, he needs more quality code. The quality of your code may not be that good, he will only take quality open source code for training.
  2. If your main business is selling code, I'm guessing you're worried about leaking your core assets. There is no need to worry. Because AI will only generate code in small snippets, AI can't generate the complete code for a project.
  3. If you are worried about the big manufacturers taking your code to do business, that's not possible either. With the ability of big companies, if they want to do a certain piece of business, they will certainly combine it with their own business, and it is impossible to use your code directly. Moreover, if they really want to do a certain piece of business, the best way is to acquire you, not to take your code to use. To be honest, code is sometimes a liability, the real value is your business.

5. The future era of the super-individual

AI has always been positioned as an assistant, and AI will become more and more powerful.AI will definitely eliminate coders in the future, but AI will definitely coexist with excellent developers. Developers should seize the opportunity of this era and strive to make themselves a super individual.

In the future era of super individuals, knowledge mastery is no longer the only important factor. With the development of AI technology, more creativity, the ability to integrate resources and product capabilities will become core competencies.

AI programming assistants can handle a lot of repetitive tasks and unleash the creativity of developers. Developers can devote more time and energy to innovation and creativity to develop better products.

After this round of the economy, some businesses have closed down and some have survived. Even the businesses that survived are believed to have learned to be more flexible in the way they use labor. In the future, with the addition of AI, the ability of individuals will definitely be amplified. At that time, enterprises must be more inclined to find independent individuals to work with.

6. Summary

This post talks about a few AI programming assistants, how it works, its pros and cons, superindividuals, and more. I encourage developers to actively embrace AI and make themselves a full-stack developer and super individual, so that AI can help them unleash more productivity and creativity, and make themselves full of unlimited possibilities.

The end of this article! Welcome Follow, add micro letter (ylxiao) exchange, the whole network can be searched (programmer half a cigarette)!

Link to original article:/s/NwDlNIjqeRu4OuC1jVhEkA