# Hello, world

**“Hello, World!”** 是一个小型计算机程序，它把“Hello, World!”这句话打印到显示器上，是人们在学习一门新的编程语言或测试一个新环境时所写的传统第一个程序。它通常是最简单的、能产生可见输出的程序，因此可以在动手写任何真正的代码之前，用它来检查这门语言的工具是否已经安装、是否能正常工作。<sup>[1](https://exercism.org/tracks/java/exercises/hello-world)</sup>

| 关键事实 | 详情 |
|---|---|
| 已知最早出现 | 1972年，布莱恩·克尼汉（Brian Kernighan）在贝尔实验室的内部备忘录《B语言教程导论》中<sup>[2](https://www.helloworld.amsterdam/why-the-name)</sup> |
| 原始措辞 | 小写的“hello, world”，带逗号，没有大写字母，也没有感叹号<sup>[3](https://helloworlds.io/origins)</sup><sup> • </sup><sup>[4](https://oiu.edu.sd/frontend/web/uploads/lecturess/ce6187e0df95d8fb3193f865585e6a16.pdf)</sup> |
| 推广文本 | 克尼汉与丹尼斯·里奇（Dennis Ritchie）1978年的《C程序设计语言》，其第一个示例程序打印“hello, world”<sup>[2](https://www.helloworld.amsterdam/why-the-name)</sup><sup> • </sup><sup>[5](https://c-program-example.com/2011/10/kr-c-program-exercise-1-01a.html)</sup> |
| 目的 | 证明这门语言可以工作、能够产生输出、工具链配置正确<sup>[2](https://www.helloworld.amsterdam/why-the-name)</sup><sup> • </sup><sup>[3](https://helloworlds.io/origins)</sup> |
| 现代用途 | 教程、教科书以及Exercism和大学课程等学习平台上的标准第一道练习<sup>[1](https://exercism.org/tracks/java/exercises/hello-world)</sup><sup> • </sup><sup>[6](https://www.cs.princeton.edu/~cos125/summer24/assignments/hello/specification.php)</sup> |

## 贝尔实验室的起源

1972年，[贝尔实验室](https://www.edgepedia.org/zh/bell-labs)的研究员布莱恩·克尼汉在一份题为《B语言教程导论》的内部备忘录中首次印出了这一行文字。他想要一个尽可能简单、又能做出可见成果的程序：打印一句问候，并证明工具链可以工作。<sup>[2](https://www.helloworld.amsterdam/why-the-name)</sup> “hello, world”这一确切措辞——全部小写、带一个逗号——就作为最小可用程序的典范示例出现在这份教程里。<sup>[3](https://helloworlds.io/origins)</sup> 克尼汉说过，他几乎不记得自己当初是怎么选中这个短语的。<sup>[7](https://helloworldthebook.com/story/)</sup>

克尼汉的第二份备忘录《C语言编程：教程》（1974年）也用了这个例子，而这个程序的C语言版本正是由它沿袭而来。<sup>[4](https://oiu.edu.sd/frontend/web/uploads/lecturess/ce6187e0df95d8fb3193f865585e6a16.pdf)</sup>

## 《C程序设计语言》与传播

1978年，克尼汉与C语言的设计者[丹尼斯·里奇](https://www.edgepedia.org/zh/dennis-ritchie)把“hello, world”放在了《C程序设计语言》的第一页。这本书卖出了数百万册，其第一个示例程序打印的字符串就是“hello, world”。<sup>[2](https://www.helloworld.amsterdam/why-the-name)</sup><sup> • </sup><sup>[5](https://c-program-example.com/2011/10/kr-c-program-exercise-1-01a.html)</sup> 此后，编程教程绝大多数都从同一个地方起步。<sup>[2](https://www.helloworld.amsterdam/why-the-name)</sup>

在一种相关的场合里，这个短语的用法比它作为程序输出还要早：20世纪60年代，在[达特茅斯学院](https://www.edgepedia.org/zh/dartmouth-college)（Dartmouth College），BASIC语言的设计者们曾考虑用HELLO和GOODBYE来取代LOGON和LOGOFF，作为一套由常用词构成的语法的一部分。<sup>[8](https://time.com/69316/basic/)</sup>

## 今日教学中的使用

在K&R那本书问世四十多年后，“Hello, World!”仍然是人们用Python、JavaScript、Rust、Go、Swift、Kotlin以及其他自带编译器和可打印字符串的语言写下的第一个程序。<sup>[2](https://www.helloworld.amsterdam/why-the-name)</sup> 代码练习平台Exercism把它设为Java学习路径的第一道练习，称其为“初学者学习一门新语言或新环境时的传统第一个程序”；完成这道练习，才能解锁该路径余下的内容。<sup>[1](https://exercism.org/tracks/java/exercises/hello-world)</sup> 普林斯顿大学（Princeton）的入门课程COS 126也以一份Java作业开篇，学生要编写一个名为`HelloWorld.java`的程序打印这句话，之后才转向接受命令行参数的程序。<sup>[6](https://www.cs.princeton.edu/~cos125/summer24/assignments/hello/specification.php)</sup>

由于这个程序在大多数语言里都极其简单，人们常用它来说明一个可运行程序的基本语法，这也是它往往成为人们一生中写下的第一个程序的原因。<sup>[4](https://oiu.edu.sd/frontend/web/uploads/lecturess/ce6187e0df95d8fb3193f865585e6a16.pdf)</sup> 最早的B语言版本演示的是外部变量；K&R中的C语言版本由一个`main`函数构成，它调用`printf`并传入字符串“hello, world\n”；甚至这个版本的细枝末节，比如POSIX文本输出惯例所要求的结尾换行符，也成了标准的教学要点。<sup>[3](https://helloworlds.io/origins)</sup><sup> • </sup><sup>[5](https://c-program-example.com/2011/10/kr-c-program-exercise-1-01a.html)</sup>

## 文化影响

这两个词已经成为一种人们耳熟能详的简称，既指编程生涯的开端，也指与一个新系统的初次接触。在[计算机历史博物馆](https://www.edgepedia.org/zh/computer-history-museum)（Computer History Museum），那台老式IBM 1401大型机至今仍有一个单张卡片的“HELLO WORLD”程序：装入卡片后，每次按下启动按钮，它就在1403打印机上打印出这一行。<sup>[9](https://ibm1401.computerhistory.org/DemoProgs.html)</sup> 有人汇编了用200多种编程语言写成的该程序合集，这个短语也被用作计算机与算法类书籍的书名。<sup>[10](https://www.cs.princeton.edu/courses/archive/fall05/cos126/checklist/hello.html)</sup><sup> • </sup><sup>[11](https://e-edu.nbu.bg/pluginfile.php/993798/mod_resource/content/1/Hannah_Fry%20-%20HELLO%20WORLD%20-%20How%20algorithms%20will%20decide%20our%20future%202018.pdf)</sup>

## References

1. [Hello World, Exercism Java track](https://exercism.org/tracks/java/exercises/hello-world)
2. [Why the name? The story behind Hello World](https://www.helloworld.amsterdam/why-the-name)
3. [The Origins of "Hello, World!", helloworlds.io](https://helloworlds.io/origins)
4. [Programming Fundamentals (course PDF), Omdurman Islamic University](https://oiu.edu.sd/frontend/web/uploads/lecturess/ce6187e0df95d8fb3193f865585e6a16.pdf)
5. [K&R C Exercise 1-1a: The "hello, world" Program, C Program Examples](https://c-program-example.com/2011/10/kr-c-program-exercise-1-01a.html)
6. [Programming Assignment 1: Hello, World, COS 126, Princeton University](https://www.cs.princeton.edu/~cos125/summer24/assignments/hello/specification.php)
7. [The Story Behind Hello, World!, helloworldthebook.com](https://helloworldthebook.com/story/)
8. [Fifty Years of BASIC, Time](https://time.com/69316/basic/)
9. [Demo Programs, IBM 1401, Computer History Museum](https://ibm1401.computerhistory.org/DemoProgs.html)
10. [Programming Assignment Checklist: Hello World, COS 126 Fall 2005, Princeton University](https://www.cs.princeton.edu/courses/archive/fall05/cos126/checklist/hello.html)
11. [Hannah Fry, *Hello World: How Algorithms Will Decide Our Future* (2018), PDF](https://e-edu.nbu.bg/pluginfile.php/993798/mod_resource/content/1/Hannah_Fry%20-%20HELLO%20WORLD%20-%20How%20algorithms%20will%20decide%20our%20future%202018.pdf)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 19, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Programming languages › Paradigms, classification, and history

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/hello-world

English original: https://www.edgepedia.org/hello-world
