2.1 Time to set up your computer to start learning
2.1 为接下来的学习做好准备工作
Learning how to write software requires that you perform the task of writing software, not just reading about it. If this were a book on how to play guitar, would you keep reading it without ever trying to play the guitar? We thought not. Reading this book without following along and trying it out yourself would be like watching a marathon runner finish the race and thinking you’re ready to go run one yourself. We’ll stop with the analogies, but seriously, you need to get your software installed and running before we go farther.
What scares us the most right now is that we just hit the most common point where novices, even those eager to learn programming, tend to fail, and we really want to see you succeed. Now, you might be thinking, “Wait, really? We’re just getting started.” Yes, that’s exactly the point. In Leo’s popular Coursera course about learning Java programming [1], can you guess the point when most new learners leave? Is it the challenging assignment at the end of the course that involves plotting earthquake markers on the globe in real time? No. It’s actually the warmup assignment where learners must set up their programming environment. As such, we understand this could be a hurdle for you. We hope that with this not-so-subtle nudge, we can help you achieve all the goals you had in mind when you bought this book. It all starts with installing the software.
2.1.1 Overview of the software in your programming environment
2.1.1 编程环境与软件概览
To set up and use Copilot easily, we’ll install the software editing tools used by novices and software engineers alike. The tools you will use are GitHub, Copilot, Python, and Visual Studio Code. Of course, if you already have all these tools installed, jump to section 2.5.
为了更好地设置和使用 Copilot,我们将会安装一些不论是初学者还是专业工程师都会用到的软件编辑工具。这些工具包括 GitHub、Copilot、Python 以及 Visual Studio Code。当然,如果你已经安装了所有这些工具,也可以直接跳转第 2.5 节。
GitHub account
GitHub 账号
GitHub is an industry-standard tool for developing, maintaining, and storing software. We won’t use GitHub in this book, however. We’re signing up for GitHub simply because you’ll need an account to access Copilot. Signing up for a GitHub account is free but, at the time of writing, they charge for Copilot. If you are a student, they will waive that fee. If you aren’t a student, as of writing, you can get a 30-day free trial.
You might ask why they charge for the service, and there’s a good answer. It’s expensive to build the GPT3 models (imagine thousands of computers running for a year to build the model), and GitHub incurs costs by providing predictions from the model (many machines are receiving your input, running it through the model, and generating your output). If you are not ready to commit to using Copilot, you could make a calendar note for roughly 25 days from the day you sign up, and if you aren’t using Copilot at that time, just cancel. If, on the other hand, you have succeeded in learning how to write software with Copilot and are using it to improve your productivity at work or just as a hobby, keep it.
Really any programming language would have worked for this book, but we picked Python because it is one of the most popular programming languages in the world and is the language we teach in our introductory courses at our universities. As we said in chapter 1, compared to other languages, Python is easier to read, easier to understand, and easier to write. For this book, Copilot will primarily generate the code, not you. However, you will want to read and understand the code generated by Copilot, and Python is great for that.
You can use any text editor to program. However, if you want a nice programming environment where you can write code, easily get suggestions from Copilot, and run your code, VS Code is our preferred tool. VS Code is used by novices learning software and is well liked by students [2]. It’s also used globally by professional software engineers, which means you can work and learn while using this environment after finishing the book.
你可以使用任何文本编辑器来进行编程。但如果你在寻找一个舒适的编程环境,既能写代码,又能轻松获得 Copilot 的建议,还可以运行代码,那么 VS Code 就是我们的首选。VS Code 不仅受到软件开发新手的欢迎,也经常获得学生群体的青睐 [2]。它同样被世界各地的专业软件工程师所使用,这意味着在你完成本书的学习之后,可以继续使用这一环境进行工作或进一步的学习。
For VS Code to work for this book, you’ll need to install a few extensions that enable working with Python and using Copilot, but one of the great things about VS Code is that it’s easy to install those extensions.
为了配合本书的使用,你需要安装几个扩展(俗称 “插件”),以便让 VS Code 支持 Python 编程,并启用 Copilot。值得一提的是,VS Code 的插件机制非常强大,安装这些插件也非常简单。
2.1 Time to set up your computer to start learning
2.1 为接下来的学习做好准备工作
Learning how to write software requires that you perform the task of writing software, not just reading about it. If this were a book on how to play guitar, would you keep reading it without ever trying to play the guitar? We thought not. Reading this book without following along and trying it out yourself would be like watching a marathon runner finish the race and thinking you’re ready to go run one yourself. We’ll stop with the analogies, but seriously, you need to get your software installed and running before we go farther.
学习编写软件的过程中,你需要亲自动手编程,而不仅仅是通过阅读来理解。如果这是一本教你如何弹吉他的书,你肯定不会在碰都不碰吉他的情况下就一直往下读,对吧?我们认为你不会。仅仅是阅读而不亲自实践,就像观看马拉松选手冲过终点,然后误认为自己也已经准备好参加马拉松一样。我们不再用类比来说明了,但请你认真对待:在我们进一步深入学习之前,你需要先安装并运行好所需的软件。
What scares us the most right now is that we just hit the most common point where novices, even those eager to learn programming, tend to fail, and we really want to see you succeed. Now, you might be thinking, “Wait, really? We’re just getting started.” Yes, that’s exactly the point. In Leo’s popular Coursera course about learning Java programming [1], can you guess the point when most new learners leave? Is it the challenging assignment at the end of the course that involves plotting earthquake markers on the globe in real time? No. It’s actually the warmup assignment where learners must set up their programming environment. As such, we understand this could be a hurdle for you. We hope that with this not-so-subtle nudge, we can help you achieve all the goals you had in mind when you bought this book. It all starts with installing the software.
眼下就是我们最担心的时间点,因为这是就是很多新手(甚至是那些最渴望学习编程的新手)最容易失败的阶段,我们真心希望你能跨过这道坎儿。或许你会惊讶地想,“真的吗?我们才刚开始啊。”确实,这正是关键所在。以利奥(Leo)在 Coursera 平台上广受欢迎的 Java 编程课程 [1] 为例,你能猜到大多数新手是在哪个阶段放弃的吗?是在课程末尾那个要求实时在地球仪上标记地震的高难度任务吗?不是的。实际上,是在课程的起步阶段,学习者需要配置他们的编程环境时。因此,我们理解这对你来说可能是一个障碍。我们期望通过这种直白的鼓励,能够帮助你达成购买本书时所设想的所有目标。一切都始于安装软件。
2.1.1 Overview of the software in your programming environment
2.1.1 编程环境与软件概览
To set up and use Copilot easily, we’ll install the software editing tools used by novices and software engineers alike. The tools you will use are GitHub, Copilot, Python, and Visual Studio Code. Of course, if you already have all these tools installed, jump to section 2.5.
为了更好地设置和使用 Copilot,我们将会安装一些不论是初学者还是专业工程师都会用到的软件编辑工具。这些工具包括 GitHub、Copilot、Python 以及 Visual Studio Code。当然,如果你已经安装了所有这些工具,也可以直接跳转第 2.5 节。
GitHub account
GitHub 账号
GitHub is an industry-standard tool for developing, maintaining, and storing software. We won’t use GitHub in this book, however. We’re signing up for GitHub simply because you’ll need an account to access Copilot. Signing up for a GitHub account is free but, at the time of writing, they charge for Copilot. If you are a student, they will waive that fee. If you aren’t a student, as of writing, you can get a 30-day free trial.
GitHub 在开发、维护和存储软件代码领域已是 “行业标准” 级别的工具。不过我们在本书中并不会用到 GitHub。注册 GitHub 的唯一原因是你需要一个可以访问 Copilot 的账号。虽然注册 GitHub 账号是免费的,但在撰写本书时,Copilot 还是一项收取服务。如果你是学生,可以免除这笔费用。如果你不是学生,截止到写书的当下,你可以享受 30 天的免费试用。
You might ask why they charge for the service, and there’s a good answer. It’s expensive to build the GPT3 models (imagine thousands of computers running for a year to build the model), and GitHub incurs costs by providing predictions from the model (many machines are receiving your input, running it through the model, and generating your output). If you are not ready to commit to using Copilot, you could make a calendar note for roughly 25 days from the day you sign up, and if you aren’t using Copilot at that time, just cancel. If, on the other hand, you have succeeded in learning how to write software with Copilot and are using it to improve your productivity at work or just as a hobby, keep it.
你可能会质疑为什么需要为这项服务支付费用,其实答案也很合理。训练 GPT-3 模型的成本极高(想象一下,需要成千上万台计算机运行一年时间才能训练出这个模型),并且模型在提供推理服务时也会产生成本(大量服务器在接收用户的输入,运行模型来处理这些输入,并且生成用户所需的结果)。如果你对于是否要长期使用 Copilot 还有些犹豫,那不妨在试用期开始后的 25 天左右设一个日历提醒,如果到那时你还没有使用 Copilot,取消订阅就好。反之,如果你已经利用 Copilot 成功学会了编程,并且它正在提高你的工作效率或者成为了你的一项爱好,那么就继续使用它。
Python
Python
Really any programming language would have worked for this book, but we picked Python because it is one of the most popular programming languages in the world and is the language we teach in our introductory courses at our universities. As we said in chapter 1, compared to other languages, Python is easier to read, easier to understand, and easier to write. For this book, Copilot will primarily generate the code, not you. However, you will want to read and understand the code generated by Copilot, and Python is great for that.
事实上,本书适用于任何一门编程语言,但我们选择了 Python,因为它是全球最流行的编程语言之一,并且是我们在大学的编程入门课程中教授的语言。如第一章所述,与其他语言相比,Python 更加易于阅读、理解和编写。本书中,生成代码的任务主要是由 Copilot 来完成,而不是你。尽管如此,你仍然需要阅读和理解 Copilot 生成的代码,而 Python 在这方面尤其合适。
Visual Studio Code (VS Code)
Visual Studio Code(VS Code)
You can use any text editor to program. However, if you want a nice programming environment where you can write code, easily get suggestions from Copilot, and run your code, VS Code is our preferred tool. VS Code is used by novices learning software and is well liked by students [2]. It’s also used globally by professional software engineers, which means you can work and learn while using this environment after finishing the book.
你可以使用任何文本编辑器来进行编程。但如果你在寻找一个舒适的编程环境,既能写代码,又能轻松获得 Copilot 的建议,还可以运行代码,那么 VS Code 就是我们的首选。VS Code 不仅受到软件开发新手的欢迎,也经常获得学生群体的青睐 [2]。它同样被世界各地的专业软件工程师所使用,这意味着在你完成本书的学习之后,可以继续使用这一环境进行工作或进一步的学习。
For VS Code to work for this book, you’ll need to install a few extensions that enable working with Python and using Copilot, but one of the great things about VS Code is that it’s easy to install those extensions.
为了配合本书的使用,你需要安装几个扩展(俗称 “插件”),以便让 VS Code 支持 Python 编程,并启用 Copilot。值得一提的是,VS Code 的插件机制非常强大,安装这些插件也非常简单。