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?