页面简介
Move from web-based AI coding to local development: understand IDE vs AI IDE, build a snake game with Trae, and learn practical AI collaboration tips.
正文摘录
Beginner Level 2: Learn AI Programming Tools Learn Actively with AI 💡 The most important learning rule: when you have a question, ask AI firstFrom now on, treat AI as your first place to ask for help. Whether a concept is unclear, a tool will not install, you do not know a command, your program reports an error, or you simply do not know what to do next, ask AI first and then try the answer yourself.Questions you would once have taken to a teacher, classmate, or group chat can usually go to AI first. It responds quickly, accepts follow-up questions, and can use your error message and project context to suggest the next step. Do not wait until you have been stuck for a long time, and do not use AI only when you want it to write code.AI-native learning is not merely completing work with AI. It means involving AI throughout the learning process: ask when a problem appears, try the answer, and ask again when the result raises a new question.The AI-Native Learning Loop Active learning with AI does not mean handing over the task and waiting. AI shortens the time needed to find an answer, so you can spend more time trying, checking, and understanding. Use this loop throughout the course:mermaidflowchart LR A["① Meet a problem<br/>State the goal and what happened"] --> B["② Ask AI immediately<br/>Include the context"] B --> C["③ Try it yourself<br/>Follow the suggestion"] C --> D{"Did it work as expected?"} D -- "Not yet" --> E["④ Give AI the result<br/>or the complete error"] E --> B D -- "Yes" --> F["⑤ Explain in your own words<br/>why it worked"] F --> G["Build a skill you can apply<br/>to a new problem"]Questions You Can Ask Directly What happenedWhat you can say to AIA concept is unclear“I have no programming background. Explain an API with an everyday analogy, then give me the smallest example.”You cannot install the environment“I use macOS and want to run this project. First check what I need, then guide me through one step at a time and explain what each step does.”A command reports an error“Here are the command and the complete error. First identify the most likely cause, then give me the smallest fix. If you need more information, tell me what to provide.”You do not know what comes next“My goal is to build Snake, and the game screen already appears. Tell me the smallest next step and how I will know it is finished.”AI wrote code you do not understand“Do not change more code yet. Explain the last change module by module and what problem each part solves.”You cannot choose between two options“I am a beginner and want a runnable version quickly. Compare options A and B under those conditions and recommend one clearly.”The result differs from your expectation“I expected the page to look like this: …; it currently looks like this: …. Compare them and fix only the most obvious difference first.”A reusable question templateMy goal is …; I have completed …; I tried …; the actual result or full error is …; please explain the cause first, then give me the smallest next action.The more concrete the information, the more useful the answer will be. It is normal if the first answer does not solve the problem. Send the new result back to AI—that follow-up is part of AI-native learning.Chapter Overview 🎯Learning ObjectivesLocal Development Environment SetupIDE vs AI IDEEfficient Development TipsPreviously, we experienced AI programming on z.ai, but the web version has many limitations — you can't save your work anytime, it's hard to manage files, and you can't handle complex projects. This chapter helps you move your development environment to your own computer so you can truly build things independently.We'll first clarify what the difference is between an IDE and an AI IDE, and why the latter can double your efficiency. Then we'll walk you through step by step using Trae to build a Snake game locally, covering the complete workflow from installation to running. Finally, we'll share some practical tips for communicating with AI so you can avoid common pitfalls.After completing this chapter, you'll have mastered a development workflow similar to that of professional programmers.💡 Advanced TipIf you have some programming experience and want to use more powerful tools early on, you can refer to Modern CLI Coding Tools to develop using the command line. ⏱️ Estimated TimeAbout 1 day, can be completed in multiple sessions 📦 Expected Output1 original game you createBuilt using Trae1. What Environment and Tools Do You Need to Write Code 1.1 Mindset Shift: When in Doubt, Ask AI First Before we introduce the various environments and tools, here's an important reminder: you need to change your thinking habits.In traditional programming learning, if you need to install Python, configure Conda, or fix an npm installation failure, you'd typically open a search engine, find a tutorial, and follow the steps one by one. If you hit an error along the way, you'd search for the error message and try again repeatedly.Wrong! ❌In the AI era, especially when using an AI IDE, remember one core principle: For any task, you can ask AI first, or even let it do it for you.Don't know how to set up your environment? Just ask AI in the sidebar: "I want to write Python. Please check if Python is installed, and if not, install it for me."Network stuck? If installing dependencies keeps spinning or throwing errors, just throw the error to AI: "The download failed. Is it a network issue? Can you help me switch to a different mirror source?"Can't remember commands? No need to memorize Git or Conda commands. Just tell AI: "Help me create a new virtual environment called demo."1.2 Why You Need an Environment and Tools Going from "trying to write a few lines of code" to "building a long-term maintainable project" requires completely different environments and tools.In theory, you could write code with the system's built-in Notepad, but problems quickly arise:All code is plain black text — keywords, strings, and comments are all mixed together, making it hard to see the structure at a glanceNo smart suggestions — you have to type every word completely by hand, and a single typo means repeatedly checking your codeFiles become chaotic — switching back and forth between dozens of files, often unable to find the line you need to editDebugging is guesswork — when the program crashes, you don't know what went wrong and can only add print statements line by lineThat's why you need an IDE (Integrated Development Environment). It displays code in different colors, provides auto-suggestions as you type, organizes files by project, and lets you trace errors step by step — making development more efficient and less error-prone.2. What Is an IDE, and Why Do You Need One Pre-reading TipIf you're not yet familiar with what an IDE is or what each interface element does, we recommend reading IDE Basics first to learn the basic concepts and common features.In the early days of programming, all we needed was a simple text editor and a language processor. But as projects grew more complex, developers urgently needed a tool that could efficiently manage files, support syntax highlighting, and enable debugging — and thus the Integrated Development Environment (IDE) was born.You can think of an IDE as a program specifically designed to "edit, manage, run, and debug" code. Early IDEs looked very "primitive" and were operated almost entirely through the keyboard.Terminal Interface — Image source: https://en.wikipedia.org/wiki/File:Emacs-screenshot.pngWell-known and mature "built-in IDEs" like Vim are commonly used for remote server operations.For greater efficiency, we need modern IDEs that support mouse interaction, typically including:Source Code Editor: Syntax highlighting, auto-completion.Build and Run Tools: Built-in compiler/interpreter.Debugger: Breakpoint debugging, variable inspection.Modern IDEs often also include built-in tools like Git. The most popular is Microsoft's Visual Studio Code (VS Code), which is lightweight and extensible. While there are also professional IDEs like the JetBrains suite, VS Code is the most beginner-friendly.VS Code's core philosophy is "everything is a plugin." Through its plugin system, it supports various languages — install the Python plugin and it becomes a Python IDE, install the C++ plugin and it becomes a C++ IDE. Without plugins, it's just an advanced text editor.You can even use it to edit Markdown documents.In short, an IDE is a set of tools that helps developers write code and run programs efficiently.For more detailed explanations, check out the Virtual IDE Visualization section in the Appendix.3. How Is an AI IDE Different from a Regular IDE A regular IDE (like the original VS Code) is essentially a "toolbox": You can open projects, write code, run and debug, and install plugins — but the prerequisite is that you need to know what to do and how to do it yourself:When there's an error, you read the message yourself and figure out which line has the problem;When you want to add a new page or API endpoint, you find the right file and write the code yourself;When you want to configure the environment or build the project, you look up the documentation and follow the steps yourself.But in an AI IDE, you can directly use a large language model to help you code and modify files:Just say "make a login page," and it generates the basic code structure first;Throw the error message and related code at it, and let it analyze the cause and suggest fixes;After you confirm, let it automatically create files, batch-edit code, and handle cross-file grunt work.For example, you can select a piece of code and ask it to "refactor this" or "add comments." You can also ask in the sidebar "How is this project designed?" and specify the reference scope using @filename or @entire project, completing the tedious operations of creating files, writing code, and running with a single sentence.In the latest version of VS Code, a large language model assist