欢迎来到编程世界 | Welcome to the Programming World
欢迎来到编程世界 | Welcome to the Programming World
---
开启你的编程之旅 | Starting Your Programming Journey
你有没有想过,手机上的应用程序是如何诞生的?你玩的游戏、使用的社交软件、甚至智能音箱的语音助手,它们的背后都离不开编程的力量。编程不仅仅是编写代码,它是一种表达创意、解决问题的方式,更是连接人类想象力与数字世界的桥梁。
Have you ever wondered how the apps on your phone come to life? The games you play, the social media apps you use, even voice assistants like smart speakers—all of them exist because of programming. Programming is more than just writing code; it's a way to express creativity, solve problems, and connect human imagination with the digital world.
在这个数字化时代,编程已经不再是少数人的专属技能。从医生使用程序分析医学影像,到音乐家利用算法创作旋律,从建筑师借助软件设计建筑,到环保主义者通过数据分析保护地球——编程正在改变各行各业,也在改变我们看待世界的方式。无论你是对科技充满好奇的学生,还是渴望掌握新技能的终身学习者,编程都将为你打开一扇通往无限可能的大门。
In this digital age, programming is no longer a skill reserved for a select few. From doctors using programs to analyze medical images, to musicians creating melodies with algorithms, from architects designing buildings with software, to environmentalists protecting the planet through data analysis—programming is transforming every industry and changing how we see the world. Whether you're a curious student eager to explore technology, or a lifelong learner seeking new skills, programming will open a door to infinite possibilities for you.
本章将带你踏上一段激动人心的编程探索之旅。我们将从最基础的概念开始,了解什么是编程、为什么值得学习、如何培养计算思维。你将认识两款强大而又易于上手的编程工具——Scratch和Python,并亲手搭建你的第一个编程环境。准备好了吗?让我们一起揭开编程世界的神秘面纱!
In this chapter, we'll take you on an exciting journey of programming exploration. We'll start from the most fundamental concepts, understanding what programming is, why it's worth learning, and how to develop computational thinking. You'll get to know two powerful yet beginner-friendly programming tools—Scratch and Python—and set up your very first programming environment. Ready? Let's uncover the mysteries of the programming world together!
---
什么是编程?| What is Programming?
编程的定义 | Definition of Programming
编程(Programming),简单来说,就是告诉计算机要做什么以及如何做的过程。想象一下,当你给朋友写一份详细的食谱时,你需要用清晰的语言告诉他每一步该做什么——要准备什么材料、先放什么后放什么、火候要多大、煮多长时间。编程其实就是给计算机写“食谱”,只不过这个“厨师”只能理解非常精确和具体的指令。
Programming, in simple terms, is the process of telling a computer what to do and how to do it. Imagine writing a detailed recipe for a friend—you need to use clear language to explain each step: what ingredients to prepare, what goes in first and what comes after, how much heat to use, how long to cook. Programming is essentially writing a "recipe" for the computer, except this "chef" can only understand very precise and specific instructions.
计算机是一种神奇的机器,它本身并不聪明——至少不像人类那样天生聪明。它不会阅读我们写的文章,不会理解我们说的话,不能自己做出判断。它唯一能做的,就是极其快速地执行一条又一条极其简单的指令。就像一台精密的钢琴,它能弹出美妙的音乐,但前提是必须有人坐在琴凳上,按照乐谱一个音符一个音符地演奏。程序员的工作,就是创作这些“乐谱”,让计算机能够演奏出我们想要的“乐曲”。
A computer is a wonderful machine, but it's not inherently intelligent—not in the way humans are. It cannot read our articles, understand our spoken words, or make decisions on its own. The only thing it can do is execute extremely simple instructions at incredible speed. Like a precision piano that can play beautiful music, but only if someone sits at the bench and plays each note according to the sheet music. A programmer's job is to create these "sheet music" so that computers can play the "symphonies" we want.
编程语言 | Programming Languages
既然要编写“食谱”,我们就需要一种计算机能够理解的“语言”。这就引出了编程语言(Programming Language)的概念。编程语言是一种人造的语言,专门用于人与计算机之间的沟通。就像世界上有中文、英语、日语等多种人类语言一样,编程语言也有许多种,每种都有自己的特点和适用场景。
Since we need to write "recipes," we need a "language" that computers can understand. This brings us to the concept of programming language. A programming language is a human-made language specifically designed for communication between humans and computers. Just as there are many human languages like Chinese, English, and Japanese, there are also many programming languages, each with its own characteristics and suitable scenarios.
为什么会有这么多种编程语言呢? Why are there so many programming languages?
想象一下医院和餐厅的区别。医生需要听诊器、手术刀这些专业工具,而厨师需要锅碗瓢盆、炉灶这些厨房用具。虽然都是“做事情”,但工具和方法完全不同。编程语言也是一样的:有些语言擅长处理网页,有些适合做数据分析,有些专门用于开发游戏,还有些专为教育初学者设计。没有哪一种语言是“最好的”,只有“最适合的”。
Imagine the difference between a hospital and a restaurant. Doctors need stethoscopes and scalpels—specialized tools, while chefs need pots, pans, and stoves—kitchen equipment. Although both are about "getting things done," the tools and methods are completely different. Programming languages work the same way: some are great at handling websites, some are suitable for data analysis, some are specifically designed for game development, and others are meant for teaching beginners. No single language is "the best"—only "the most suitable."
让我们认识两种特别适合初学者的编程语言:Scratch和Python。
Let's get to know two programming languages that are especially suitable for beginners: Scratch and Python.
---
Scratch:你的动画和游戏创作工具 | Scratch: Your Animation and Game Creation Tool
Scratch简介 | Introduction to Scratch
Scratch是由麻省理工学院媒体实验室(MIT Media Lab)开发的一款图形化编程语言,于2007年正式发布。它的设计初衷就是让编程变得有趣、简单、触手可及,尤其适合8到16岁的青少年学习。通过Scratch,你可以创建动画故事、互动游戏、音乐艺术作品,甚至可以用它来讲述数学和科学概念。
Scratch is a visual programming language developed by the MIT Media Lab, officially released in 2007. Its design goal was to make programming fun, simple, and accessible, especially for young people ages 8 to 16. With Scratch, you can create animated stories, interactive games, musical artworks, and even use it to explain math and science concepts.
Scratch这个名字有几个含义。首先,它在英文中有“赤手空拳、从头开始”的意思,象征着每个人都可以从零开始学习编程。其次,这个名字也致敬了嘻哈音乐中的“打碟”文化——程序员就像DJ一样,用代码块“混搭”出独特的作品。
The name Scratch has several meanings. In English, it means "starting from scratch" or "with nothing," symbolizing that everyone can learn programming from zero. The name also pays homage to hip-hop DJ culture—programmers are like DJs, "mixing" code blocks to create unique works.
图形化编程的魅力 | The Charm of Visual Programming
与传统代码不同,Scratch采用图形化编程(Visual Programming)的方式。你不需要记住复杂的英文单词和语法规则,而是通过拖拽彩色积木块来构建程序。每一个积木块代表一个指令,比如“移动10步”、“播放声音”、“重复执行”等。你可以像搭积木一样,把这些指令块拼接在一起,形成完整的程序。
Unlike traditional code, Scratch uses visual programming. You don't need to memorize complex English words and syntax rules—instead, you build programs by dragging and dropping colorful code blocks. Each block represents an instruction, like "move 10 steps," "play sound," or "repeat." You can connect these instruction blocks together like building with LEGO bricks to form complete programs.
想象一下,你要让一只小猫在屏幕上走动。在Scratch中,你只需要把几个积木块组合在一起:首先,让小猫“移动10步”;然后,让它等待0.2秒;最后,让这个过程“重复执行10次”。就这么简单!你不需要写任何文字代码,只需动动鼠标,就能让小猫跑起来。
Imagine you want to make a cat walk across the screen. In Scratch, you just need to combine a few blocks: first, make the cat "move 10 steps"; then, make it "wait 0.2 seconds"; finally, make this process "repeat 10 times." That's it! No text code needed—just use your mouse, and you can make the cat run.
这种图形化的方式大大降低了编程的门槛。它消除了拼写错误和语法错误的可能性,让学习者能够专注于理解程序的逻辑和流程,而不是纠结于技术细节。同时,彩色积木和卡通角色的设计让学习过程变得生动有趣。
This visual approach greatly lowers the barrier to programming. It eliminates the possibility of spelling mistakes and syntax errors, allowing learners to focus on understanding program logic and flow rather than getting bogged down in technical details. At the same time, colorful blocks and cartoon character designs make the learning process lively and fun.
Scratch的应用场景 | Application Scenarios for Scratch
Scratch的应用范围远超你的想象。除了创建游戏和动画,许多教育工作者还用它来教授数学概念。例如,你可以用Scratch制作一个“分数可视化”程序,让分数的大小关系一目了然;或者创建一个“找最大公约数”的交互工具,帮助理解数学原理。
Scratch's application range exceeds what you might imagine. Beyond creating games and animations, many educators use it to teach mathematical concepts. For example, you can use Scratch to create a "fraction visualization" program that makes fraction sizes immediately clear; or build an interactive "finding GCD" tool to help understand mathematical principles.
更令人惊叹的是,Scratch社区拥有来自世界各地的数千万个项目和创作者。你可以在社区中浏览别人分享的作品,学习他们的创意,甚至在此基础上进行改编和创新。这种开放共享的精神,正是编程文化的重要组成部分。
What's even more amazing is that the Scratch community has tens of millions of projects and creators fro