Skip to content

Commit db9b857

Browse files
committed
feat: add chapter(s)
1 parent 4ad9f73 commit db9b857

File tree

4 files changed

+180
-2
lines changed

4 files changed

+180
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
0. 序章
2323
* [欢迎加入](https://github.com/cssmagic/Learn-AI-Assisted-Python-Programming/issues/1)
24-
1. 基于 GitHub Copilot 介绍 AI 辅助编程
25-
* 1.1 How we talk to computers
24+
1. [借助 GitHub Copilot 走近 AI 辅助编程](https://github.com/cssmagic/Learn-AI-Assisted-Python-Programming/issues/2)
25+
* [1.1 我们如何与计算机对话](https://github.com/cssmagic/Learn-AI-Assisted-Python-Programming/issues/3)
2626
* 1.2 About the technology
2727
* 1.3 How Copilot changes how we learn to program
2828
* 1.4 What else can Copilot do for us?

chapter-1/100.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
id: 2
3+
title: "[译] [100] 借助 GitHub Copilot 走近 AI 辅助编程"
4+
---
5+
6+
# Introducing AI-Assisted Programming with Copilot
7+
8+
# 借助 GitHub Copilot 走近 AI 辅助编程
9+
10+
### This chapter covers
11+
12+
### 本章内容概要
13+
14+
* AI-assisted computer programming
15+
* How AI-assistants change how new programmers learn how to program
16+
* Why programming is never going to be the same
17+
* How AI assistants like Copilot work
18+
* How Copilot can solve many classic introductory programming problems
19+
* What else you can do with an AI coding assistant
20+
* Possible perils of AI assisted programming
21+
22+
<!-- -->
23+
24+
* AI 辅助的计算机编程
25+
* AI 助手如何改变新手程序员学习编程的方式
26+
* 为什么编程方式将发生永久性的变革
27+
* 像 GitHub Copilot 这样的 AI 助手是如何工作的
28+
* GitHub Copilot 为何能够解决众多入门级的经典问题
29+
* 利用 AI 编程助手还能做哪些事情
30+
* AI 辅助编程可能带来的风险
31+
32+
In this chapter, we’ll talk about how humans communicate with computers. We’ll introduce you to your **AI Assistant**, Copilot, an amazing tool that uses Artificial Intelligence (AI) to help people write software. More importantly, we’ll show you how Copilot can help you learn how to program. We’re not expecting that you’ve written any programs before. If you have, please don’t skip this chapter, even if you already know a little bit about programming.
33+
34+
在本章中,我们将探讨人类如何与计算机进行交流。我们会向您介绍您的 **AI 助手** GitHub Copilot,一个利用人工智能(AI)帮助人们编写软件的神奇工具。更为重要的是,我们将展示 GitHub Copilot 如何帮助您学习编程。我们并不假设您之前有编程经验。不过,即便您有所了解,也请不要跳过本章。
35+
36+
37+
Everyone needs to know why writing programs is different now that we have AI assistants like ChatGPT and Copilot, and that the skills we need to be effective programmers change. As we’ll see, we also need to be vigilant, because sometimes tools like ChatGPT and Copilot lie.
38+
39+
现如今,随着像 ChatGPT 和 GitHub Copilot 这样的 AI 助手的出现,编程方式已经发生了根本性的变化。这也意味着我们作为程序员所需掌握的技能也随之改变。同时我们也会看到,由于 ChatGPT 和 GitHub Copilot 这类工具有时可能会提供误导信息,我们还需保持警惕。
40+
41+

chapter-1/101.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
id: 3
3+
title: "[译] [101] 我们如何与计算机对话"
4+
---
5+
6+
## 1.1 How we talk to computers
7+
8+
## 1.1 我们如何与计算机对话
9+
10+
Would you be happy if we started by asking you to read and understand this?
11+
12+
如果我们开始时请您阅读并理解以下内容,您是否会感到满意?
13+
14+
```assembly
15+
section .text
16+
global _start
17+
_start:
18+
mov ecx, 10
19+
mov eax, '0'
20+
l1:
21+
mov [num], eax
22+
mov eax, 4
23+
mov ebx, 1
24+
push ecx
25+
mov ecx, num
26+
mov edx, 1
27+
int 0x80
28+
mov eax, [num]
29+
inc eax
30+
pop ecx
31+
loop l1
32+
mov eax, 1
33+
int 0x80
34+
section .bss
35+
num resb 1
36+
```
37+
38+
That monstrosity prints out the numbers from 0 to 9. It's written using code in assembly language, a low-level programming language. Low-level programming languages, as you can see, are very far from languages that humans can easily read and write. They’re designed for computers, not humans.
39+
40+
这段 “鬼画符” 能够输出从 0 到 9 的数字。它使用的是汇编语言编写的,这是一种低级编程语言。正如您所见,低级编程语言与人们能够轻松读写的语言大相径庭。它们主要为计算机而设计,并非面向人类。
41+
42+
No one wants to write programs like that. But, especially in the past, it was sometimes necessary. Programmers could use it to do exactly what they wanted the computer to do, down to individual instructions. This level of control was needed in order to squeeze every bit of performance out of underpowered computers. For example, the most speed-critical pieces of 1990s computer games such as Doom and Quake were written in assembly language like the code above. It simply wouldn't have been possible to make those games otherwise.
43+
44+
没人愿意像这样写代码。但特别是在早期,这有时候是不得已而为之的。程序员能够借此准确地控制计算机的每一条指令,实现他们所期望的确切操作。这种精确的控制对于充分利用计算能力有限的电脑以获得最大性能是必不可少的。举个例子,像《毁灭战士》和《雷神之锤》这样的90年代关键游戏速度敏感部分,就是使用类似上面的汇编语言编写的。否则,制作这些游戏将是不可能的。
45+
46+
47+
#### Making it a little easier
48+
49+
#### 让难度降低一点儿
50+
51+
Okay, no more of that. Let's move on. Would you be happier with this?
52+
53+
好的,不再是那样了。让我们继续。这会让你更满意吗?
54+
55+
56+
```python
57+
for num in range(0, 9):
58+
print(num)
59+
```
60+
61+
This, by contrast, is code in the Python language and is what many programmers use these days. Unlike assembly language, which is a low-level language, Python is considered a high-level language because it's much closer to natural language. Even though you don't know about Python code yet, you might be able to guess what this program is trying to do. The first line looks like it's doing something with the range of numbers from 0 to 9. The second line is printing something. It may not be too hard for you to believe that this program, just like the assembly language monstrosity, is supposed to print the numbers from 0 to 9. Unfortunately, something is wrong with it.
62+
63+
与此相对,这段代码是用 Python 语言编写的,是当前许多程序员所采用的。不同于低级语言的汇编语言,Python 被看作是一种高级语言,因为它更贴近自然语言。即便你对 Python 代码尚无了解,你或许能猜出这段程序的目的。第一行似乎在处理一个从 0 到 9 的数字范围。第二行在进行打印操作。不难理解,这个程序的目的,正如那段汇编语言代码一样,是要打印出从 0 到 9 的数字。遗憾的是,程序中存在一些错误。
64+
65+
While this code is closer to English, it isn’t English. It's a programming language that, like assembly language, has specific rules. As in the code above, misunderstanding the details of those rules can result in a broken program.
66+
67+
尽管这种代码更贴近英语,但它并非英语。它是一种拥有特定规则的编程语言,类似于汇编语言。如上所述,对这些规则的细节理解不当可能会导致程序运行错误。
68+
69+
The holy grail of communicating with a computer is to do so in a natural language such as English. We've been talking to computers using various programming languages over the past 70 years not because we want to, but because we have to. Computers were simply not powerful enough for the vagaries and idiosyncrasies of a language like English. Our programming languages improved—-from symbol soup assembly language to Python, for example—-but they are still computer languages, not natural languages.
70+
71+
与计算机沟通的终极目标是能够使用如英语这样的自然语言进行。在过去的 70 年中,我们之所以使用各种编程语言与计算机对话,并非出于愿望,而是迫于无奈。计算机的计算能力不足以应对英语这样语言的复杂性和特异性。我们的编程语言虽然有所进步——例如,从充满符号的汇编语言发展到了 Python,但它们依旧是计算机语言,并非自然语言。
72+
73+
This is changing.
74+
75+
然而,这种情况正在发生变化。
76+
77+
78+
#### Making it a lot easier
79+
80+
#### 让难度降低一大截
81+
82+
Using an AI assistant, we can now ask for what we want in English and have the computer code written for us in response. To get a correct Python program that does actually print the numbers from 0 to 9, we can ask our AI assistant (Copilot) in normal English language like this:
83+
84+
借助 AI 助手,我们现在可以用英文明确提出我们的需求,并让计算机相应地为我们编写代码。为了得到一个实际上能打印出 0 到 9 数字的正确 Python 程序,我们可以这样用日常英语向我们的 AI 助手(GitHub Copilot)提出指令:
85+
86+
```python
87+
# Output the numbers from 0 to 9
88+
```
89+
90+
```python
91+
# 打印出 0 到 9 的数字
92+
```
93+
94+
Copilot might respond to this prompt by generating something like this:
95+
96+
对此,GitHub Copilot 可能会根据这一指令生成如下代码:
97+
98+
```python
99+
for i in range(10):
100+
print(i)
101+
```
102+
103+
Unlike the example we showed you before, this piece of Python code actually works!
104+
105+
不同于我们之前展示的示例,这段 Python 代码确实能够正常运行!
106+
107+
AI coding assistants can be used to help people write code. In this book, we will learn how to use Copilot to write code for us. We will ask for what we want in English, and we will get the code back in Python.
108+
109+
AI 编程助手能够帮助人们编写代码。在本书中,我们会探索如何利用 GitHub Copilot 来编写代码。我们只需用英语描述我们的需求,便能收到用 Python 编写的代码作为回应。
110+
111+
More than that, we'll be able to use Copilot as a seamless part of our workflow. Without tools like Copilot, programmers routinely have two windows open: the one where they write code and the other where they ask on Google how to write code. This second window would have Google search results, Python documentation, or forums of programmers talking about how to write code to solve that particular problem. They're often pasting code from these results into their code, then tweaking it slightly for their context, trying alternatives, and so on. This has become a way of life for programmers—but you can imagine the inefficiency here. By some estimates, up to 35% of programmer’s time may be spent searching for code \[1\], and much of the code that is found is not readily usable. This will be much improved with Copilot helping us write our code.
112+
113+
更进一步,我们将能够无缝集成 GitHub Copilot 到我们的工作流程中。在没有 GitHub Copilot 这类工具的情况下,程序员通常需要同时打开两个窗口:一个用于编写代码,另一个用于在 Google 上查询编码方法。这第二个窗口可能充斥着 Google 搜索结果、Python 文档或是程序员论坛上讨论如何解决特定编码问题的帖子。他们经常需要从这些结果中复制代码到自己的项目中,随后进行适当的调整以符合自己的应用场景,尝试不同的解决方案等。这已经成为了程序员生活的一部分——但你可以想象这样做的低效率。据估计,程序员多达 35% 的时间可能花在搜索代码上\[1\],而且很多找到的代码并不是可以立即使用的。有了 GitHub Copilot 协助我们编写代码,这种情况将得到显著改善。

chapter-1/108.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
idxx: xx
3+
title: "[译] [108] 本章小结"
4+
---
5+
6+
7+
8+
## 1.8 **Summary**
9+
10+
## 本章小结
11+
12+
* Copilot is an AI Assistant, which is an Artificial Intelligence (AI) agent that helps you get work done.
13+
* Copilot changes how humans interact with computers, and the way that we write programs.
14+
* Copilot changes the focus of skills we need to hone (less focus on syntax, more focus on prompt engineering and testing).
15+
* Copilot is nondeterministic; sometimes it produces correct code, sometimes it doesn't. We need to be vigilant.
16+
* Issues around copyright of code, education and job training, and bias in Copilot results still need to be worked out.
17+
18+
<!-- -->
19+
20+
* GitHub Copilot 是一款 AI 助手,这是一个能够帮助你完成工作的人工智能代理。
21+
* GitHub Copilot 重新定义了人与计算机的交互方式及程序编写方法。
22+
* GitHub Copilot 转变了我们技能提升的焦点(减少对语法的关注,增加对提示词工程和测试的重视)。
23+
* GitHub Copilot 具有非确定性特点;它有时能生成正确的代码,有时却不能。我们需要时刻保持警惕。
24+
* 关于代码的版权、教育与职业培训以及 GitHub Copilot 结果中的偏见问题仍需要解决。代码版权、教育与职业培训问题,以及 GitHub Copilot 结果的偏见等问题,仍需寻找解决方案。

0 commit comments

Comments
 (0)