Programming程式設計
寫程式最難的部分不是打字,是把一件你自己都沒想清楚的事,講到一台完全不會猜的機器聽得懂。
CEFR B1閱讀約 6 分鐘 · 12 個單字 · 測驗卷 100 分
3D Tour3D 導覽影片:先看一遍,再自己點點看
3D 導覽影片 · 約 2 分鐘
The Coding Club程式社團
12 個可以點的單字 · 可以隨時暫停、轉動場景
逐字稿(15 段)
- 1Welcome to the coding club! Let's see how programmers really think.歡迎來到程式社團!來看看寫程式的人到底是怎麼想的。
- 2This robot follows a program to make a sandwich. A program is a list of instructions.這台機器人照著程式做三明治。程式就是一串指令。
- 3A computer does exactly what you wrote, not what you meant. Every step has to be there.電腦執行的是你寫的,不是你想的。每一步都得寫出來。
- 4So break a big problem into small steps, until each step is obvious.所以要把大問題拆成小步驟,拆到每一步都顯而易見。
- 5This box is a variable. It has a name, and it holds a value.這個箱子是一個變數。它有名字,裡面裝著一個值。
- 6Here is a new value, seven. You can look inside the box, or put something new in.這是一個新的值:7。你可以看箱子裡裝什麼,也可以放新的東西進去。
- 7A condition is a yes-or-no test. If it is true, go this way. If not, go that way.條件是一個是非判斷。成立就走這邊,不成立就走那邊。
- 8A loop goes round and round until a condition changes.迴圈一圈又一圈地跑,直到條件改變為止。
- 9A loop can repeat a step a million times, so you never write a million lines.迴圈可以把一個步驟重複一百萬次,你就不必寫一百萬行。
- 10A function is a named block of steps. Put something in, and it gives something back.函式是一段有名字的步驟。放東西進去,它就交回一個結果。
- 11A function is reusable, like this bottle. If you write the same thing twice, you need one.函式是可重用的,就像這支水壺。同樣的東西寫了兩次,就該做成函式。
- 12A bug is a mistake in the instructions. The first computer bug was a real moth, found in 1947.臭蟲是指令裡的錯誤。第一個電腦 bug 是 1947 年發現的一隻真的蛾。
- 13To fix a bug, first reproduce it. Make the same problem happen again on purpose.要修錯誤,先讓它重現:故意讓同樣的問題再發生一次。
- 14Then debug: find where your idea and the machine stopped agreeing. Explaining it to a rubber duck really helps!接著除錯:找出你的想法和機器從哪裡開始不一樣。講給小黃鴨聽真的有用!
- 15Now it's your turn. Click on any block and see what it does.現在換你了。點點看每一塊積木,看看它們在做什麼。
Instructions for Something That Never Guesses寫給一台永遠不會猜的東西
A program is a list of instructions. The hard part is that a computer does exactly what you wrote, not what you meant.程式就是一串指令。困難的地方在於:電腦執行的是你「寫」的,不是你「想」的。
If you tell a person to make a sandwich, they fill in the gaps. A computer does not. Every step has to be there.你叫一個人做三明治,他會自己補上沒說到的部分。電腦不會。每一步都得寫出來。
So most of programming is really thinking: breaking a big problem into steps small enough that each one is obvious.所以寫程式大部分其實是在思考:把一個大問題拆成小到每一步都顯而易見的步驟。
Once you can do that, the language you write it in is the easy part.一旦你做得到這件事,用哪種語言寫反而是簡單的部分。
The Building Blocks基本積木
- Variable變數
- A named box that holds a value. You can look at what is inside, and you can put something new in.一個有名字的盒子,裡面裝著一個值。你可以看裡面是什麼,也可以放新的東西進去。
- Condition條件
- If this is true, do that; otherwise do something else. This is how a program makes a decision.如果這件事成立就做這個,否則做別的。程式就是這樣做決定的。
- Loop迴圈
- Repeat something until a condition changes. Loops are why a computer can check a million records without you writing a million lines.重複做某件事,直到條件改變。因為有迴圈,電腦才能檢查一百萬筆資料,而你不必寫一百萬行。
- Function函式
- A named block of steps you can use again. Writing the same thing twice is the sign that you need one.一段有名字、可以重複使用的步驟。同樣的東西寫了兩次,就是該抽成函式的訊號。
- Bug臭蟲
- A mistake in the instructions. Debugging is not typing faster — it is narrowing down where your idea and the machine's behaviour stopped agreeing.指令裡的錯誤。除錯不是打字打快一點,而是逐步縮小範圍,找出你的想法和機器的行為從哪裡開始分岔。
Words You Will See in Any Language在任何語言裡都會看到的字
| English 英文 | Chinese 中文 | What it means 意思 |
|---|---|---|
| variable | 變數 | A named place to keep a value 存放值的地方 |
| value | 值 | The thing inside 裡面的東西 |
| function | 函式 | A reusable block of steps 可重用的步驟 |
| argument | 引數 | What you hand to a function 傳給函式的東西 |
| return | 回傳 | What a function gives back 函式交回來的東西 |
| loop | 迴圈 | Repeat until something changes 重複到條件改變 |
| condition | 條件 | A yes-or-no test 一個是非判斷 |
| debug | 除錯 | Find and fix a mistake 找出並修正錯誤 |
資料查證至 2025 年底
幾乎所有程式語言的關鍵字都是英文,所以這一批字學起來特別划算——它們在 Python、JavaScript、Java 裡長得幾乎一樣。
Did You Know?你知道嗎?
- Programmers spend far more time reading code than writing it, which is why clear names matter more than clever tricks.工程師讀程式的時間遠多於寫程式,所以取好名字比耍聰明重要得多。
- Rubber duck debugging is a real technique: explain your code out loud, line by line, to anything at all. You usually find the bug while explaining.「小黃鴨除錯法」是真的方法:把你的程式一行一行大聲解釋給任何東西聽。你通常會在解釋的過程中自己找到錯。
- Grace Hopper helped create the idea that programs could be written in words rather than numbers, which led to modern languages.葛麗絲・霍普推動了「程式可以用文字而不是數字來寫」的想法,這催生了現代程式語言。
- The first rule of fixing a program is to make the problem happen again on purpose. A bug you cannot reproduce is a bug you cannot fix.修程式的第一條守則是「先讓錯誤重現」。無法重現的錯誤就無法修好。
Key Words單字表
program/ˈproʊ.ɡræm/n. / v.
程式;寫程式
A program is a list of instructions.程式是一串指令。
variable/ˈver.i.ə.bəl/n.
變數
A variable holds a value.變數存放一個值。
value/ˈvæl.juː/n.
值
You can change the value.你可以改變那個值。
condition/kənˈdɪʃ.ən/n.
條件
The condition decides what happens.條件決定接下來發生什麼。
loop/luːp/n.
迴圈
A loop repeats the steps.迴圈重複那些步驟。
repeat/rɪˈpiːt/v.
重複
It repeats until the list ends.它重複到清單結束為止。
function/ˈfʌŋk.ʃən/n.
函式
Put the steps in a function.把步驟放進一個函式。
reusable/ˌriːˈjuː.zə.bəl/adj.
可重用的
A function is reusable.函式是可重用的。
bug/bʌɡ/n.
程式錯誤
There is a bug in this line.這一行有個錯誤。
debug/ˌdiːˈbʌɡ/v.
除錯
It took an hour to debug it.花了一小時才除完錯。
reproduce/ˌriː.prəˈduːs/v.
重現
First reproduce the problem.先讓問題重現。
obvious/ˈɑːb.vi.əs/adj.
顯而易見的
Break it down until each step is obvious.拆到每一步都顯而易見為止。
讀完了,來考一下
測驗卷共 100 分,有單字配對、選擇、填空與簡答。 按下去會開啟列印版,可以直接印出來,或在列印視窗選「另存為 PDF」。