Chapter 1: 欢迎来到代码世界 | Welcome to Code World
窗外的阳光透过老旧的阁楼窗户,在满是灰尘的空气中形成一道道金色的光柱。十岁的小明正弯着腰,在堆积如山的旧物中翻找着。外婆去世后,妈妈让他来整理阁楼——这个他从小就觉得神秘无比的地方。
The sunlight streaming through the dusty attic window created golden pillars in the air. Ten-year-old Xiao Ming was bending over, rummaging through piles of old belongings. Since his grandmother passed away, his mother asked him to organize the attic—a place that had always seemed mysteriously fascinating to him since childhood.
阁楼里弥漫着时光的气味:陈旧的木头、褪色的报纸、落满灰尘的相册,还有各种叫不出名字的稀奇古怪的东西。小明已经找到了几本外公年轻时的笔记本、一套老式茶具,还有一台不知道什么年代的打字机。每一样东西似乎都在诉说着过去的故事。
The attic was filled with the scent of time: aged wood, faded newspapers, dusty photo albums, and all sorts of unidentifiable peculiar objects. Xiao Ming had already found several notebooks from his grandfather's youth, an antique tea set, and a typewriter from some bygone era. Each item seemed to be telling stories from the past.
就在小明以为今天的收获已经足够多的时候,他的目光被角落里一个蒙着灰布的东西吸引了。那东西的形状很奇特——方方正正的,有几根线从后面伸出来,像是什么机器的一部分。
就在小明以为今天的收获已经足够多的时候,他的目光被角落里一个蒙着灰布的东西吸引了。那东西的形状很奇特——方方正正的,有几根线从后面伸出来,像是什么机器的一部分。
As Xiao Ming thought he'd found enough treasures for the day, his gaze was drawn to something covered with a dusty cloth in the corner. The shape was peculiar—square and rectangular, with several wires extending from the back, like part of some machine.
“这会是什么呢?”小明自言自语,一边小心翼翼地掀开了那层灰布。
"What could this be?" Xiao Ming murmured to himself, carefully lifting the dusty cloth.
灰尘四散飞扬中,一台老式电脑显露了出来。那是一台带有CRT显示器的台式机——机身是米白色的,边角有些磨损,键盘上的字母因为年代久远而有些模糊。显示器的屏幕上落满了灰尘,但奇怪的是,机身背后有一根电源线还连接着,似乎从未被拔掉过。
Through the swirling dust, an old computer emerged. It was a desktop with a CRT monitor—cream-colored casing with worn corners, keys with faded letters, and a power cord still plugged in at the back, as if it had never been disconnected.
小明的心跳加快了。他记得外公以前是工程师,总是对各种机器着迷。难道这台电脑是外公的?
Xiao Ming's heart raced faster. He remembered that his grandfather was an engineer who had always been fascinated by machines. Could this computer have belonged to him?
好奇心驱使小明把电脑从角落里搬了出来。他找了一块干净的抹布,仔细地擦拭着这台沉睡多年的机器。屏幕亮了起来——不对,是闪烁了一下,然后又暗了下去。
Curiosity drove Xiao Ming to pull the computer out from the corner. He found a clean cloth and carefully wiped down this machine that had slept for many years. The screen lit up—no, it flickered—then went dark again.
小明以为是自己看错了,但就在他准备放弃的时候,屏幕再次亮了起来。这一次,闪烁更加剧烈,屏幕上的光芒从暗绿色变成了明亮的蓝白色,仿佛有什么东西正在试图从里面挣脱出来。
Xiao Ming thought he might have imagined it, but just as he was about to give up, the screen lit up again. This time, the flickering was more intense, the light on the screen shifting from dark green to bright blue-white, as if something was trying to break free from within.
就在这时,一个声音从屏幕里传了出来——清脆而带着一点电子音质的音色:
Just then, a voice emerged from the screen—clear with a slight electronic quality:
“终于等到你了。”
"I've been waiting for you."
小明吓得往后跳了一步,差点被身后的旧箱子绊倒。他瞪大眼睛盯着屏幕,心脏砰砰直跳。
Xiao Ming leaped backward in fright, nearly tripping over an old crate behind him. He stared at the screen with wide eyes, his heart pounding.
“谁……谁在那里?”小明颤抖着问道。
"Who... who's there?" Xiao Ming asked, his voice trembling.
屏幕上的光芒再次变换,一道道细小的光点开始汇聚、旋转,逐渐形成了一个小小的身影。那是一个看起来像是由像素组成的小精灵——浑身闪烁着蓝绿色的光芒,身体是半透明的,像是由无数微小的方块拼凑而成。它有着圆圆的大眼睛,看起来既可爱又神秘。
The light on the screen shifted again, and tiny points of light began to gather and swirl, gradually forming a small figure. It was a little sprite made of pixels—glowing with blue-green light, its body semi-transparent, as if constructed from countless tiny squares. It had large round eyes that looked both adorable and mysterious.
“我叫Byte,”那个小精灵眨了眨眼睛,用清脆的声音说道,“我是这台电脑里的数字精灵。我已经在这里等待了很久很久,就是为了等到一个愿意探索编程世界的人。”
"My name is Byte," the little sprite blinked its eyes and said in a clear voice, "I'm a digital sprite inside this computer. I've been waiting here for a very, very long time, just to find someone willing to explore the world of programming."
“Byte?编程?”小明努力让自己冷静下来,“编程是什么意思?”
"Byte? Programming?" Xiao Ming tried to calm himself down. "What does programming mean?"
Byte从屏幕里飘了出来——准确地说,它似乎可以自由地进出屏幕这个“窗口”。它在空中飘浮着,转了几个圈,然后用一种老师教学生的语气开始解释:
Byte floated out from the screen—more precisely, it seemed able to move in and out of the screen as if it were a "window." Floating in the air and spinning in circles, it began explaining in a teaching tone:
---
🌟 什么是编程?
🌟 What is Programming?
“编程啊,简单来说,就是告诉计算机该做什么的一种方式。”Byte伸出一根小小的像素手指,在空中比划着,“你知道吗,计算机其实很笨的——它自己什么都不会做。它只能听懂一种特殊的语言,然后严格按照这种语言的指令去执行。”
"Programming, simply put, is a way of telling computers what to do," Byte extended a tiny pixel finger and gestured in the air. "You know what? Computers are actually quite stupid—they can't do anything on their own. They can only understand a special language and then strictly follow the instructions in that language to execute tasks."
小明歪着头想了想,问道:“可是我看到你们(指着电脑)能做很多事情啊——打字、画画、玩游戏,甚至还能上网查找信息。如果计算机什么都不会做,那这些是怎么来的呢?”
Xiao Ming tilted his head and thought for a moment, then asked: "But I've seen you guys do many things—typing, drawing, playing games, even searching for information online. If computers can't do anything by themselves, where do all these capabilities come from?"
Byte露出了赞许的表情,眼睛变成了两个小小的弯月形:“问得好!这些能力,都是人类通过编程赋予计算机的。”
Byte showed an approving expression, its eyes becoming two tiny crescent moons: "Good question! All these capabilities were given to computers by humans through programming."
Byte在空中画了一个圈,继续说道:“想象一下,如果计算机是一个超级听话的机器人,但它完全听不懂你说的话。你对它说'帮我查一下明天的天气',它会一脸茫然——因为它只懂0和1。”
Byte drew a circle in the air and continued: "Imagine if the computer was a super-obedient robot, but couldn't understand a single word you said. If you told it 'help me check tomorrow's weather,' it would look completely confused—because it only understands 0 and 1."
“零……和一?”小明疑惑地问。
"Zero... and one?" Xiao Ming asked, confused.
---
💻 计算机的语言:0和1的世界
💻 The Language of Computers: The World of 0 and 1
“对,就是0和1!”Byte兴奋地跳了起来,“你知道吗,在计算机的内部世界里,所有的信息都是用0和1来表示的。比如数字、文字、图片、声音,甚至你正在看的这个动画,都是由一串串的0和1组成的。”
"Yes, exactly 0 and 1!" Byte jumped up excitedly. "Did you know that inside computers, all information is represented using 0 and 1? Like numbers, text, images, sounds—everything you're looking at right now, including this animation—is made up of strings of 0s and 1s."
Byte挥了挥手,空中出现了一串数字:“比如数字5,在计算机里就是101。数字2就是10。而你名字里的每一个汉字,其实都有一个对应的二进制代码——想象一下,一万多个0和1的组合,才能表示一个汉字呢!”
Byte waved its hand, and a string of numbers appeared in the air: "For example, the number 5 is represented as 101 in a computer. The number 2 is 10. And every Chinese character in your name actually has a corresponding binary code—imagine, over ten thousand combinations of 0s and 1s are needed just to represent a single Chinese character!"
小明瞪大了眼睛:“这听起来太不可思议了!那么多0和1,怎么记得住啊?”
Xiao Ming's eyes widened: "That sounds incredible! With so many 0s and 1s, how does anyone keep track?"
Byte调皮地眨眨眼:“所以啊,人类发明了编程语言——这是一种介于人类语言和机器语言之间的'中间语言'。人类可以用相对简单易懂的代码来编写程序,然后通过专门的翻译工具,把这些代码转换成计算机能理解的0和1。”
Byte blinked mischievously: "That's exactly why humans invented programming languages—these are 'intermediate languages' between human language and machine language. Humans can write programs using relatively simple and understandable code, and then use special translation tools to convert this code into 0s and 1s that computers can understand."
小明若有所思地点了点头:“我好像有点明白了。编程就像是——给不会说话但很听话的机器人写说明书?”
Xiao Ming nodded thoughtfully: "I think I'm starting to understand. Programming is like writing an instruction manual for a robot that can't speak but is very obedient?"
Byte高兴地鼓起掌来——虽然它的手碰撞在一起并没有发出声音,但小明能看到那些像素点开心地跳动着:“完全正确!你的理解能力比我预想的要强多了。这就是编程的本质:用人类能理解的方式,编写精确的指令,让计算机去执行特定的任务。”
Byte happily clapped its hands—though no sound came from the collision, Xiao Ming could see those pixels bouncing with joy: "Exactly right! Your understanding is much stronger than I expected. This is the essence of programming: writing precise instructions in a way humans can understand, so computers can execute specific tasks."
---
🧠 计算思维:程序员的思考方式
🧠 Computational Thinking: How Programmers Think
Byte飘到小明面前,认认真真地说: