|
| 1 | +--- |
| 2 | +idxx: xx |
| 3 | +title: "[译] [102] About the technology" |
| 4 | +--- |
| 5 | + |
| 6 | + |
| 7 | +## 1.2 About the technology |
| 8 | + |
| 9 | +We’ll be using two main technologies in this book: Python and GitHub Copilot. |
| 10 | + |
| 11 | +Python is a programming language. It’s a way to communicate with a computer. People use it to write all kinds of programs that do useful things, like games, interactive websites, visualizations, apps for file organization, automating routine tasks, and so on. |
| 12 | + |
| 13 | +There are other programming languages, too, like Java, C++, Rust, and many others. Copilot works with those, too, but at the time of writing, it works really well with Python. Python code is a lot easier to write compared to many other languages (especially assembly code). Even more importantly, Python is easy to _read_. After all, we’re not going to be the one writing the Python code. Our AI assistant is! |
| 14 | + |
| 15 | +Computers don’t actually know how to read and run Python code. The only thing computers can understand is something called _machine code_, which looks even more ridiculous than assembly code as it is the binary representation of the assembly code (yep, just a bunch of 0s and 1s!). Behind the scenes, your computer takes any Python code that you provide and converts it into machine code before it runs, as shown in Figure 1.1. |
| 16 | + |
| 17 | +**Figure 1.1 Your Python program goes through several steps before you see the output on your screen** |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | +#### Copilot, your AI Assistant |
| 22 | + |
| 23 | +What is an _AI Assistant_? An AI Assistant is an Artificial Intelligence (AI) agent that helps you get work done. Maybe you have an Amazon Alexa device at home, or an iPhone with Siri-—these are AI assistants. Those ones help you order groceries, learn the weather, or determine that, yes, the woman who played Bellatrix in the Harry Potter movies really was in Fight Club. An AI assistant is just a computer program that responds to normal human inputs like speech and text with human-like answers. |
| 24 | + |
| 25 | +Copilot is an AI Assistant with a specific job: it converts English into computer programs. (It can also do a whole lot more as we will soon see.) There are other AI assistants like Copilot, including CodeWhisperer, Tabnine, and Ghostwriter. We chose Copilot for this book by a combination of the quality of code that we have been able to produce, stability (it has never crashed for us!), and our own personal preferences. We encourage you to check out other tools as well when you feel comfortable doing so. |
| 26 | + |
| 27 | +#### How Copilot works behind the scenes-—in 30 seconds |
| 28 | + |
| 29 | +You can think of Copilot as a layer between you and the computer program you’re writing. Instead of writing the Python directly, you simply describe the program you want in words—this is called a _prompt_—and Copilot generates the program for you. |
| 30 | + |
| 31 | +The brains behind Copilot is a fancy computer program called a **large language model**, or LLM. An LLM stores information about relationships between words, including which words make sense in certain contexts, and uses this to predict the best sequence of words to respond to a prompt. |
| 32 | + |
| 33 | +Imagine that we asked you what the next word should be in this sentence: "The person opened the ________". There are many words that you could fill in here, like “door” or “box” or “conversation,” but there are also many words that would not fit here, like “the” or “it” or “open.” An LLM takes into account the current context of words to produce the next word, and it keeps doing this until it has completed the task. |
| 34 | + |
| 35 | +Notice that we didn't say anything about Copilot having an understanding of what it is doing. It just uses the current context to keep writing code. Keep this in mind throughout your journey: only we know whether the code that's generated actually does what we intended it to do. Very often it does, but you should always exercise healthy skepticism regardless. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | +Figure 1.2 will give you an idea of how Copilot goes from prompt to program. |
| 40 | + |
| 41 | +**Figure 1.2 Going from prompt to program with Copilot** |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +You might wonder why Copilot writes Python code for us and not machine code directly. Isn’t Python an expendable intermediate step now? Well, no, and the reason is that Copilot is going to make mistakes. And if it’s going to make mistakes, and we need to get them fixed, then it’s a lot easier to do that with Python than with machine code. |
| 50 | + |
| 51 | +In fact, virtually no one checks if the machine code produced from Python is correct. This is partially because of the determinism of the Python language specification. One could imagine a future where Copilot conversations are so accurate that inspecting the Python is unnecessary, but we’re a long way from that. |
0 commit comments