How Coders Can Survive—and Thrive—in a ChatGPT World 
4 tips for programmers to stay ahead of generative AI

编码人员如何在 ChatGPT 世界中生存和发展
程序员领先于生成式 AI 的 4 个技巧

 

Artificial intelligence, particularly generative AI powered by large language models (LLMs), could upend many coders’ livelihoods. But some experts argue that AI won’t replace human programmers—not immediately, at least.
人工智能,特别是由大型语言模型(LLM)驱动的生成AI,可能会颠覆许多程序员的生计。但一些专家认为,人工智能不会取代人类程序员——至少不会立即取代。

“You will have to worry about people who are using AI replacing you,” says Tanishq Mathew Abraham, a Ph.D. candidate in biomedical engineering at the University of California, Davis and the CEO of medical AI research center MedARC.
“你将不得不担心使用人工智能的人取代你,”加州大学戴维斯分校生物医学工程博士候选人、医学人工智能研究中心MedARC首席执行官Tanishq Mathew Abraham说。

So how can software developers make themselves more useful and relevant in what appears to be a coming age of LLM-centered coding? Here are some tips and techniques for coders to survive and thrive in a generative AI world.
那么,软件开发人员如何在即将到来的以LLM为中心的编码时代使自己更加有用和相关呢?以下是编码人员在生成式 AI 世界中生存和发展的一些技巧和技术。

Stick to Basics and Best Practices
坚持基础知识和最佳实践

While the myriad AI-based coding assistants could help with code completion and code generation, the fundamentals of programming remain: the ability to read and reason about your own and others’ code, and understanding how the code you write fits into a larger system.
虽然无数基于人工智能的编码助手可以帮助完成代码和代码生成,但编程的基础知识仍然存在:阅读和推理自己和他人代码的能力,以及理解你编写的代码如何适应更大的系统。

“I believe AI can dramatically increase the productivity of software developers, but there is a lot more to software engineering than just generating code—from eliciting user requirements to debugging, testing, and more,” says Priyan Vaithilingam, a Ph.D. student working in the intersection of human-computer interaction and programming languages at Harvard University’s John A. Paulson School of Engineering and Applied Sciences.
“我相信人工智能可以大大提高软件开发人员的生产力,但软件工程不仅仅是生成代码 - 从引发用户需求到调试,测试等等,”哈佛大学约翰·A·保尔森工程与应用科学学院人机交互和编程语言交叉领域的博士生Priyan Vaithilingam说。

One of the most integral programming skills continues to be the domain of human coders: problem solving. Analyzing a problem and finding an elegant solution for it is still a highly regarded coding expertise.
最不可或缺的编程技能之一仍然是人类编码人员的领域:解决问题。分析问题并为其找到优雅的解决方案仍然是备受推崇的编码专业知识。

“There’s a creative aspect to it, and a lot of those skills of approaching a problem are more important than the actual language or tools,” says Ines Montani, a Fellow of the Python Software Foundation and cofounder and CEO of Explosion, a software company specializing in developer tools for AI and natural-language processing. “Don’t fall into the trap of comparing yourself to the AI, which is more or less a statistical output of a large model. There are differences in what a developer does versus what the model outputs—there’s more to being a developer than just writing arbitrary lines of code.”
“它有一个创造性的方面,很多解决问题的技能比实际的语言或工具更重要,”Python软件基金会研究员,Explosion的联合创始人兼首席执行官Ines Montani说,Explosion是一家专门从事人工智能和自然语言处理开发工具的软件公司。“不要陷入将自己与AI进行比较的陷阱,AI或多或少是大型模型的统计输出。开发人员所做的事情与模型输出的内容存在差异 - 开发人员不仅仅是编写任意代码行。

Additionally, good software-engineering practices are proving even more valuable than before. These practices include planning out the system design and software architecture, which serves as a good context for AI-based tools to more effectively predict what code you need next.
此外,良好的软件工程实践被证明比以前更有价值。这些实践包括规划系统设计和软件架构,这为基于 AI 的工具提供了良好的上下文,可以更有效地预测您接下来需要什么代码。

“A human coder is still the one who has to figure out the structure of a piece of code, the right abstractions around which to organize it, and the requirements for different interfaces,” says Armando Solar-Lezama, an associate director and chief operating officer of MIT’s Computer Science and Artificial Intelligence Laboratory, and who leads the lab’s computer-aided programming group. “All of those are central to software-engineering practice, and they’re not going to go away soon.”
“人类编码人员仍然是必须弄清楚一段代码的结构,组织它的正确抽象以及对不同接口的要求的人,”麻省理工学院计算机科学和人工智能实验室副主任兼首席运营官Armando Solar-Lezama说,他领导实验室的计算机辅助编程小组。“所有这些都是软件工程实践的核心,而且它们不会很快消失。

Find the Tool That Fits Your Needs
找到适合您需求的工具

Finding the right AI-based tool is essential. Each tool has its own ways to interact with it, and there are different ways to incorporate each tool into your development workflow—whether that’s automating the creation of unit tests, generating test data, or writing documentation.
找到合适的基于 AI 的工具至关重要。每个工具都有自己的交互方式,并且有不同的方法可以将每个工具合并到开发工作流中 - 无论是自动创建单元测试、生成测试数据还是编写文档。

GitHub Copilot and other AI coding assistants, for instance, can augment programming, offering suggestions as you code. ChatGPT and Google’s Bard, on the other hand, act more like conversational AI programmers and can be used to answer questions about APIs (application programming interfaces) or generate code snippets.
例如,GitHub Copilot和其他AI编码助手可以增强编程,在编码时提供建议。另一方面,ChatGPT和谷歌的Bard更像是对话式AI程序员,可用于回答有关API(应用程序编程接口)的问题或生成代码片段。

The trick is to experiment. Play around with the AI tool, get a feel for how it works, consider the quality of its outputs—but keep an open mind for other tools. “AI is such a fast-moving field. You don’t want to just settle on a tool and then use that for the rest of your life, so you’ll need to adapt quickly to new ones,” Abraham says.
诀窍是实验。试用 AI 工具,感受它的工作原理,考虑其输出的质量,但对其他工具保持开放的态度。“人工智能是一个快速发展的领域。你不想只满足于一个工具,然后在你的余生中使用它,所以你需要快速适应新的工具,“亚伯拉罕说。

Think about appropriate use cases as well. Generative AI tools can provide a swift route to learning new programming languages or frameworks, and they can also be a quicker way to kick off small projects and create prototypes.
还要考虑适当的用例。生成式人工智能工具可以为学习新的编程语言或框架提供快速途径,它们也可以是启动小型项目和创建原型的更快方式。

Clear and Precise Conversations Are Crucial
清晰准确的对话至关重要

When using AI coding assistants, be detailed about what you need and view it as an iterative process. Abraham proposes writing a comment that explains the code you want so the assistant can generate relevant suggestions that meet your requirements.
使用 AI 编码助手时,请详细说明您的需求并将其视为一个迭代过程。亚伯拉罕建议写一个注释来解释你想要的代码,这样助手就可以生成满足你要求的相关建议。

For conversational AI programmers, you’ll need to know the best way to frame your prompts. This is where prompt engineering comes in.
对于对话式 AI 程序员,您需要知道构建提示的最佳方式。这就是快速工程的用武之地。

One approach Abraham suggests is chain-of-thought prompting. This involves a divide-and-conquer strategy where you break down a problem into multiple steps and tackle each one to solve the entire problem. “Asking the model to do too much at a given time can lead to disaster. You want it to be able to work with manageable chunks of information and produce manageable chunks of code,” he says.
亚伯拉罕建议的一种方法是思维链提示。这涉及分而治之的策略,您将问题分解为多个步骤,并解决每个步骤以解决整个问题。“要求模型在特定时间做太多可能会导致灾难。你希望它能够处理可管理的信息块并生成可管理的代码块,“他说。

Instead of asking an AI programmer to code an entire program from scratch, for example, consider the different tasks the program is trying to accomplish. Divide those tasks further and ask the model to write specific functions for each. You might need to reason with the model about the steps it needs to take to achieve a task, resulting in a back-and-forth conversation.
例如,与其要求AI程序员从头开始编写整个程序,不如考虑程序试图完成的不同任务。进一步划分这些任务,并要求模型为每个任务编写特定的函数。您可能需要与模型推理完成任务需要采取的步骤,从而导致来回对话。

“Treat it almost like a smart intern who knows a lot about a subject but isn’t that experienced,” Abraham says.
“对待它几乎就像一个聪明的实习生,他对一个主题了解很多,但没有经验,”亚伯拉罕说。

Precision and clarity are vital with prompt engineering. “You need to ask the model very clearly what you want, be very precise about what you’re asking it to do, and make sure you’re following up,” Abraham says.
精度和清晰度对于快速工程设计至关重要。“你需要非常清楚地问模型你想要什么,非常准确地说明你要求它做什么,并确保你正在跟进,”亚伯拉罕说。

It can also be valuable to learn the basic concepts of artificial intelligence and machine learning, as well as get a sense of how large language models work and their strengths and weaknesses. You don’t need to dive deep, but having some general knowledge can give you important context about the results.
学习人工智能和机器学习的基本概念,以及了解大型语言模型的工作原理及其优缺点也很有价值。您不需要深入研究,但拥有一些一般知识可以为您提供有关结果的重要背景信息。

To help you get started, Abraham recommends the OpenAI Cookbook, which has sections on prompting libraries and tools, prompting guides, and video courses, while Vaithilingam suggests reading up on the Illustrated Transformer to find out more about models and machine-learning basics.
为了帮助您入门,Abraham推荐OpenAI食谱,其中包含有关提示库和工具,提示指南和视频课程的部分,而Vaithilingam建议阅读Illustrated Transformer以了解有关模型和机器学习基础知识的更多信息。

Be Critical and Understand the Risks
保持批判性并了解风险

Software engineers should be critical of the outputs of large language models, as they tend to hallucinate and produce inaccurate or incorrect code. “It’s easy to get stuck in a debugging rabbit hole when blindly using AI-generated code, and subtle bugs can be difficult to spot,” Vaithilingam says.
软件工程师应该对大型语言模型的输出持批评态度,因为他们往往会产生幻觉并产生不准确或不正确的代码。“当盲目使用人工智能生成的代码时,很容易陷入调试的兔子洞,而细微的错误可能很难发现,”Vaithilingam说。

That’s why checking generated code is crucial, though it adds an extra step, which might harm more than help productivity. But Abraham argues that “it’s easier to verify the code than it is to write it from scratch in some cases, and it’s a faster approach to generate and then verify before incorporating into whatever codebase you have.”
这就是为什么检查生成的代码至关重要的原因,尽管它增加了一个额外的步骤,这可能弊大于提高生产力。但亚伯拉罕认为,“在某些情况下,验证代码比从头开始编写代码更容易,而且在合并到您拥有的任何代码库之前生成然后验证是一种更快的方法。

It might be worth putting the outputs of these models into perspective, asking the following questions: What data was this model trained on? What was filtered out and not included in that data? How old is the training data, and what version of a programming language, software package, or library was the model trained on? The answers to these questions could impact the results and provide more context about them.
可能值得对这些模型的输出进行透视,提出以下问题:此模型是在哪些数据上训练的?哪些内容被过滤掉了,但未包含在该数据中?训练数据有多旧,模型是在哪个版本的编程语言、软件包或库上训练的?这些问题的答案可能会影响结果,并提供有关它们的更多背景信息。

Developers should also be wary of entering proprietary code into these models. Some companies, such as Tabnine, offer enterprise versions of their AI coding assistants, providing privacy while still learning an organization’s coding patterns and style.
开发人员还应该警惕在这些模型中输入专有代码。一些公司,如Tabnine,提供企业版本的人工智能编码助手,在提供隐私的同时仍然学习组织的编码模式和风格。

Copyright is another factor to consider, though it’s less of a worry if you’re using these tools to complete a few lines of code or generate code for common or trivial tasks compared to producing bigger chunks of code.
版权是另一个需要考虑的因素,尽管与生成更大的代码块相比,如果您使用这些工具完成几行代码或为常见或琐碎的任务生成代码,则不必担心。

“Programmers should have some sense of how original what they’re trying to do is and to what extent is it unique to their context,” Solar-Lezama says. “If the model is producing a somewhat original piece of code, it’s important to be suspicious and skeptical before putting that in a production codebase.”
“程序员应该对他们试图做的事情有多原始,以及在多大程度上对他们的环境有独一无二的感觉,”Solar-Lezama说。“如果模型正在生成一段原始代码,那么在将其放入生产代码库之前,保持怀疑和怀疑是很重要的。

An even larger issue is security, as these models may generate code containing vulnerabilities. According to Vaithilingam, software-development best practices such as code reviews and strong test pipelines can help safeguard against this risk.
一个更大的问题是安全性,因为这些模型可能会生成包含漏洞的代码。根据Vaithilingam的说法,软件开发最佳实践(如代码审查和强大的测试管道)可以帮助防范这种风险。

“One of the things that more experienced software engineers bring to the table is the awareness of the most common vulnerabilities in code and the most common ways in which code can be made vulnerable,” says Solar-Lezama. “They build this intuition about what to pay attention to and what raises red flags. Moving forward, these kinds of techniques are going to become more important parts of the software engineering mix.”
“更有经验的软件工程师带来的一件事是意识到代码中最常见的漏洞以及代码可能变得脆弱的最常见方式,”Solar-Lezama说。“他们建立了这种直觉,关于要注意什么以及什么会引发危险信号。展望未来,这些技术将成为软件工程组合中更重要的一部分。

For programmers to survive in a generative AI world, they’ll need to embrace AI as a tool and incorporate AI into their workflow while recognizing the opportunities and limitations of these tools—and still relying on their human coding capabilities to thrive.
为了让程序员在生成式人工智能世界中生存,他们需要将人工智能作为一种工具,并将人工智能纳入他们的工作流程,同时认识到这些工具的机会和局限性,同时仍然依靠他们的人类编码能力来蓬勃发展。