For faster navigation, this Iframe is preloading the Wikiwand page for Hello World.

Hello World

Hello World 于Windows Vista中的执行结果

“Hello, World!”程序通常指一类输出或显示“Hello, World!”(你好,世界!)字符串的计算机程序。在大多数通用编程语言中,这样的程序只有一小段代码,因此可以用来展示该编程语言的基本语法英语Syntax (programming languages)[1]。“Hello, World!”往往是初学者学习某种编程语言所接触的第一个程序内容[2][3][4],同时它也是用来确认原始码编译器、程序开发或运行环境是否已经安装妥当并被操作者理解的常用手段。

历史

布莱恩·柯林汉 撰写的“Hello, world”程序 (1978年)

1972年,在贝尔实验室成员布莱恩·柯林汉撰写的内部技术文件《A Tutorial Introduction to the Language B》中首次提到了Hello World这一字符串。当时,他使用B语言撰写了一个用于演示外部变量的示例程序:

main( ) {
    extern a, b, c;
    putchar(a); putchar(b); putchar(c); putchar('!*n');
}
 
a 'hell';
b 'o, w';
c 'orld';

这个程序将在终端打印出“hello, world”,然后附上一个换行符。之所以这一短语被拆分成多个变量记录,是因为B语言中的每个字符常量只能容纳四个ASCII字符[5]

1974年,时值C语言取代B语言,在贝尔实验室的又一内部备忘录《Programming in C: A Tutorial》中,柯林汉用C语言再次编写了一个Hello World程序作为教学示例。这一程序在他和丹尼斯·里奇于1978年出版的《C程式设计语言》中得到继承:

main( ) {
        printf("hello, world\n");
}

在上例中,main( )函数定义了程序开始执行的位置。其主体由一条语句组成,即对printf函数的调用,意思是“打印格式化”(print formatted)。这个函数将使程序输出以参数传递给它的任何内容,在本例中是字符串hello, world

自此,Hello World成为了电脑程序员学习新的编程语言的传统[6]。但是,也有些人认为 hello, world 的字符串早于1966年的BCPL语言出现的时候已经出现[7]。虽然相关的字词确实在发明者记录的文件出现,但是可以肯定的是,Hello World在当时确实没有流行。因此,人们公认为布莱恩·柯林汉是令该字符串走进公众目光的人。

派生影响

Sony 的 PSP 掌机执行 Hello World 代码。

对电脑文化的影响

Debian以及系统的高级包装工具当中包含了“hello, world”安装工具。用户只需要于终端(Linux 系统的Terminal)输入“apt-get install hello”便能够安装此工具及其相关部件。虽然看似没用,但却可作为测试工具使用。同时,这亦能够向新用户展示安装工具的方法。对开发者来说,这个工具展现了建立.deb安装工具的方法。这个工具,连同GNU Hello便成为了撰写GNU程序的教学软件。[2]

对其他电子产品的影响

虽然Hello World在单片机微电脑、现场可编程逻辑门阵列复杂可编程逻辑器件中不能展现出来,一盏细小的微型LED灯会代替Hello World的作用,以表示安装成功、相关程序功能已实现[8][9][10][11][12]

以“Hello, World!”测试LED光影系统是否正常运作。

对流行文化的影响

Hello World已经成为流行文化的一部分,例如以Hello World命名首个运用纯人工智慧完成的专辑。[13] 虚拟YouTuber公司hololive production在Hololive Alternative企划预告PV末使用"//Hello,Δlternative World"来致敬此文化。[14]同时,亦有若干公司以Hello World命名,例如位于澳洲的Helloworld旅游公司[15]、Hello World Consulting[16]等。

到Hello World的时间

“到Hello World的时间”(英语:Time to hello world,TTHW)是指用给定的编程语言编写一个“Hello, World!”程序所需的时间,这是衡量一个编程语言易用性的标准之一。由于“Hello, World!”程序主要的介绍对象是不熟悉该语言的人,“Hello, World!”程序越复杂可能越表明该编程语言不太容易接近。这个概念现已不限于编程语言,在API层面同样适用,成为衡量一个新开发者使一个基本示例运作的难易程度。时间越短,说明开发者越容易采用该API。

参见

参考来源

  1. ^ James A Langbridge. Professional Embedded ARM Development. [2018-04-30]. (原始内容存档于2017-02-05). 
  2. ^ 2.0 2.1 Hello - GNU Project - Free Software Foundation. gnu.org. GNU Project. [2017-07-07]. (原始内容存档于2014-05-29). 
  3. ^ W3schools. Tryit Editor about Hello World. [2018-04-30]. (原始内容存档于2018-05-08). 
  4. ^ Hello World. 普林斯顿大学. [2018-04-30]. (原始内容存档于2017-10-12). 
  5. ^ The Programming Language B. [2018-04-30]. (原始内容存档于2015-06-11). 
  6. ^ Kernighan, Brian W.; Ritchie, Dennis M. The C Programming Language 1st. Englewood Cliffs, NJ: Prentice Hall. 1978. ISBN 0-13-110163-3. 
  7. ^ BCPL页面存档备份,存于互联网档案馆), Jargon File
  8. ^ Silva, Mike. Introduction to Microcontrollers - Hello World. EmbeddedRelated.com. 2013-09-11 [2015-05-19]. (原始内容存档于2015-05-22). 
  9. ^ George, Ligo. Blinking LED using Atmega32 Microcontroller and Atmel Studio. electroSome. [2015-05-19]. (原始内容存档于2014-11-05). 
  10. ^ PT, Ranjeeth. 2. AVR Microcontrollers in Linux HOWTO. The Linux Documentation Project. [2015-05-19]. (原始内容存档于2015-05-02). 
  11. ^ Andersson, Sven-Åke. 3.2 The first Altera FPGA design. RTE. Realtime Embedded AB. 2012-04-02 [2015-05-19]. (原始内容存档于2015-05-21). 
  12. ^ Fabio, Adam. CPLD Tutorial: Learn programmable logic the easy way. Hackaday. 2014-04-06 [2015-05-19]. (原始内容存档于2015-05-20). 
  13. ^ BBC. Is this the World's first good robot alblum. (原始内容存档于2018-05-13). 
  14. ^ Hololive Alternative官方PV. (原始内容存档于2021-05-10).  已忽略未知参数|archive-ur1= (帮助)
  15. ^ Helloworld 旅遊公司的網站. (原始内容存档于2018-05-13). 
  16. ^ Hello World Consulting公司的網站. (原始内容存档于2018-04-30). 

外部链接

{{bottomLinkPreText}} {{bottomLinkText}}
Hello World
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?