"Hello, World!" program: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>ClueBot NG
m Reverting possible vandalism by ~2025-32808-18 to version by Explicit. Report False Positive? Thanks, ClueBot NG. (4446937) (Bot)
imported>Augmented Seventh
Reverted 1 edit by ~2025-41466-39 (talk) to last revision by Kevin.Soople
Line 61: Line 61:
Variations of the "Hello, World!" program that produce a [[Computer graphics|graphical output]] (as opposed to text output) have also been shown. [[Sun Microsystems|Sun]] demonstrated a "Hello, World!" program in [[Java (programming language)|Java]] based on [[scalable vector graphics]],<ref>{{cite news|last=Jolif|first=Christophe|title=Bringing SVG Power to Java Applications|newspaper=Sun Developer Network|date=January 2003}}</ref> and the [[XL (programming language)|XL]] programming language features a spinning Earth "Hello, World!" using [[3D computer graphics]].<ref>{{cite web|last=de Dinechin|first=Christophe|title=Hello world!|url=http://grenouillebouillie.wordpress.com/2010/07/24/hello-world/|publisher=Grenouille Bouillie|date=24 July 2010}}</ref> Mark Guzdial and [[Elliot Soloway]] have suggested that the "hello, world" test message may be outdated now that graphics and sound can be manipulated as easily as text.<ref>{{cite web|url=http://www.bfoit.org/itp/Soloway/CACM_Nintendo_Generation.pdf|title=Teaching the Nintendo Generation to Program|website=bfoit.org|access-date=27 December 2015|archive-url=https://web.archive.org/web/20160505190520/http://www.bfoit.org/itp/Soloway/CACM_Nintendo_Generation.pdf|archive-date=5 May 2016|url-status=dead}}</ref>
Variations of the "Hello, World!" program that produce a [[Computer graphics|graphical output]] (as opposed to text output) have also been shown. [[Sun Microsystems|Sun]] demonstrated a "Hello, World!" program in [[Java (programming language)|Java]] based on [[scalable vector graphics]],<ref>{{cite news|last=Jolif|first=Christophe|title=Bringing SVG Power to Java Applications|newspaper=Sun Developer Network|date=January 2003}}</ref> and the [[XL (programming language)|XL]] programming language features a spinning Earth "Hello, World!" using [[3D computer graphics]].<ref>{{cite web|last=de Dinechin|first=Christophe|title=Hello world!|url=http://grenouillebouillie.wordpress.com/2010/07/24/hello-world/|publisher=Grenouille Bouillie|date=24 July 2010}}</ref> Mark Guzdial and [[Elliot Soloway]] have suggested that the "hello, world" test message may be outdated now that graphics and sound can be manipulated as easily as text.<ref>{{cite web|url=http://www.bfoit.org/itp/Soloway/CACM_Nintendo_Generation.pdf|title=Teaching the Nintendo Generation to Program|website=bfoit.org|access-date=27 December 2015|archive-url=https://web.archive.org/web/20160505190520/http://www.bfoit.org/itp/Soloway/CACM_Nintendo_Generation.pdf|archive-date=5 May 2016|url-status=dead}}</ref>


In [[computer graphics]], rendering a triangle{{snd}}called "Hello Triangle"{{snd}}is sometimes used as an introductory example for [[Graphics library|graphics libraries]].<ref>{{Cite book |last=Vries |first=Joey de |title=Learn OpenGL - Graphics Programming |date= |publisher=Kendall & Welling |year=2020 |isbn=978-90-90-33256-7 |pages=26}}</ref><ref>{{cite magazine|magazine=[[The MagPi]]|issue=65|date=Jan 2018|title=Coding games on the Raspberry Pi in C/C++ Part 01|page=57|quote=next time we will expand our code to start working with graphics and the famous 'hello triangle' code that absolutely no one uses except game coders|first1=Brian|last1=Beuken}}</ref>
In [[computer graphics]], rendering a triangle{{Mdash}}the "Hello Triangle"{{Mdash}}is sometimes used as an introductory example for [[Graphics library|graphics libraries]].<ref>{{Cite book |last=Vries |first=Joey de |title=Learn OpenGL - Graphics Programming |date= |publisher=Kendall & Welling |year=2020 |isbn=978-90-90-33256-7 |pages=26}}</ref><ref>{{cite magazine|magazine=[[The MagPi]]|issue=65|date=Jan 2018|title=Coding games on the Raspberry Pi in C/C++ Part 01|page=57|quote=next time we will expand our code to start working with graphics and the famous 'hello triangle' code that absolutely no one uses except game coders|first1=Brian|last1=Beuken}}</ref>


==Time to Hello World==
==Time to Hello World==
"Time to hello world" (TTHW) is the time it takes to author a "Hello, World!" program in a given programming language. This is one measure of a programming language's ease of use. Since the program is meant as an introduction for people unfamiliar with the language, a more complex "Hello, World!" program may indicate that the programming language is less approachable.<ref name="ODwyer">{{cite book |last1=O'Dwyer |first1=Arthur |title=Mastering the C++17 STL: Make full use of the standard library components in C++17 |date=September 2017 |publisher=[[Packt Publishing Ltd]] |isbn=978-1-78728-823-2 |page=251 |url=https://books.google.com/books?id=zJlGDwAAQBAJ&q=%22TTHW%22&pg=PA251 |access-date=4 December 2019 |language=en}}</ref> For instance, the first publicly known "Hello, World!" program in [[Malbolge]] (which actually output "HEllO WORld") took two years to be announced, and it was produced not by a human but by a code generator written in [[Common Lisp]] {{see above|{{slink||Variations}}, above}}.
"Time to hello world" (TTHW) is the time it takes to author a "Hello, World!" program in a given programming language. This is one measure of a programming language's ease of use. Since the program is meant as an introduction for people unfamiliar with the language, a more complex "Hello, World!" program may indicate that the programming language is less approachable.<ref name="ODwyer">{{cite book |last1=O'Dwyer |first1=Arthur |title=Mastering the C++17 STL: Make full use of the standard library components in C++17 |date=September 2017 |publisher=[[Packt Publishing Ltd]] |isbn=978-1-78728-823-2 |page=251 |url=https://books.google.com/books?id=zJlGDwAAQBAJ&q=%22TTHW%22&pg=PA251 |access-date=4 December 2019 |language=en}}</ref> For instance, the first publicly known "Hello, World!" program in [[Malbolge]] (which actually output "HEllO WORld") took two years to be announced, and it was produced not by a human but by a code generator written in [[Common Lisp]] {{see above|{{slink||Variations}}, above}}.


Line 159: Line 158:
*[[KERNAL#Example|KERNAL]]
*[[KERNAL#Example|KERNAL]]
*[[Kivy (framework)#Code example|Kivy]]
*[[Kivy (framework)#Code example|Kivy]]
*[[Kotlin #Main entry point|Kotlin]]
*[[K-Meleon#Customization|K-Meleon]]
*[[K-Meleon#Customization|K-Meleon]]
*[[LibreLogo#Hello world example|LibreLogo]]
*[[LibreLogo#Hello world example|LibreLogo]]
Line 266: Line 266:


==See also==
==See also==
{{Portal|Computer programming}}
{{Portal|Computer programming}}
*[[99 Bottles of Beer#References in computer science|"99 Bottles of Beer" as used in computer science]]
*[[99 Bottles of Beer#References in computer science|"99 Bottles of Beer" as used in computer science]]

Revision as of 19:38, 17 December 2025

Template:Short description Template:Redirect-multi Script error: No such module "Unsubst". A "Hello, World!" program is usually a simple computer program that emits (or displays) to the screen (often the console) a message similar to "Hello, World!". A small piece of code in most general-purpose programming languages, this program is used to illustrate a language's basic syntax. Such a program is often the first written by a student of a new programming language,[1] but it can also be used as a sanity check to ensure that the computer software intended to compile or run source code is correctly installed, and that its operator understands how to use it.

History

File:Hello World Brian Kernighan 1974.jpg
"Hello, World!" program handwritten in the C language and signed by Brian Kernighan (1978)

While several small test programs have existed since the development of programmable computers, the tradition of using the phrase "Hello, World!" as a test message was influenced by an example program in the 1978 book The C Programming Language,[2] with likely earlier use in BCPL. The example program from the book prints Template:Samp, and was inherited from a 1974 Bell Laboratories internal memorandum by Brian Kernighan, Programming in C: A Tutorial:[3]


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

In the above example, the Template:Samp function defines where the program should start executing. The function body consists of a single statement, a call to the Template:Samp function, which stands for "print formatted"; it outputs to the console whatever is passed to it as the parameter, in this case the string Template:Samp.

The C-language version was preceded by Kernighan's own 1972 A Tutorial Introduction to the Language B,[4] where the first known version of the program is found in an example used to illustrate external variables:

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

The program above prints Template:Samp on the terminal, including a newline character. The phrase is divided into multiple variables because in B, a character constant is limited to four ASCII characters. The previous example in the tutorial printed Template:Samp on the terminal, and the phrase Template:Samp was introduced as a slightly longer greeting that required several character constants for its expression.

The Jargon File reports that "hello, world" instead originated in 1967 with the language BCPL.[5] Outside computing, use of the exact phrase began over a decade prior; it was the catchphrase of New York radio disc jockey William B. Williams beginning in the 1950s.[6]

Variations

File:PSP-Homebrew.jpeg
A "Hello, World!" program running on Sony's PlayStation Portable as a proof of concept

"Hello, World!" programs vary in complexity between different languages. In some languages, particularly scripting languages, the "Hello, World!" program can be written as one statement, while in others (more so many low-level languages) many more statements can be required. For example, in Python, to print the string Template:Samp followed by a newline, one only needs to write print("Hello, World!"). In contrast, the equivalent code in C++[7] requires the import of the C++ standard library, the declaration of an entry point (main function), and a call to print a line of text to the standard output stream.

File:CNC Hello World.jpg
Computer numerical control (CNC) machining test in poly(methyl methacrylate) (Perspex)

The phrase "Hello, World!" has seen various deviations in casing and punctuation, such as "hello world" which lacks the capitalization of the leading H and W, and the presence of the comma or exclamation mark. Some devices limit the format to specific variations, such as all-capitalized versions on systems that support only capital letters, while some esoteric programming languages may have to print a slightly modified string. Other human languages have been used as the output; for example, a tutorial for the Go language emitted both English and Chinese or Japanese characters, demonstrating the language's built-in Unicode support.[8] Another notable example is the Rust language, whose management system automatically inserts a "Hello, World" program when creating new projects.

File:HelloWorld Maktivism ComputerProgramming LEDs.jpg
A "Hello, World!" message being displayed through long-exposure light painting with a moving strip of light-emitting diodes (LEDs)

Some languages change the function of the "Hello, World!" program while maintaining the spirit of demonstrating a simple example. Functional programming languages, such as Lisp, ML, and Haskell, tend to substitute a factorial program for "Hello, World!", as functional programming emphasizes recursive techniques, whereas the original examples emphasize I/O, which violates the spirit of pure functional programming by producing side effects. Languages otherwise able to print "Hello, World!" (assembly language, C, VHDL) may also be used in embedded systems, where text output is either difficult (requiring added components or communication with another computer) or nonexistent. For devices such as microcontrollers, field-programmable gate arrays, and complex programmable logic devices (CPLDs), "Hello, World!" may thus be substituted with a blinking light-emitting diode (LED), which demonstrates timing and interaction between components.[9][10][11][12][13]

The Debian and Ubuntu Linux distributions provide the "Hello, World!" program through their software package manager systems, which can be invoked with the command Template:Samp. It serves as a sanity check and a simple example of installing a software package. For developers, it provides an example of creating a .deb package, either traditionally or using debhelper, and the version of Template:Samp used, GNU Hello, serves as an example of writing a GNU program.[14]

Variations of the "Hello, World!" program that produce a graphical output (as opposed to text output) have also been shown. Sun demonstrated a "Hello, World!" program in Java based on scalable vector graphics,[15] and the XL programming language features a spinning Earth "Hello, World!" using 3D computer graphics.[16] Mark Guzdial and Elliot Soloway have suggested that the "hello, world" test message may be outdated now that graphics and sound can be manipulated as easily as text.[17]

In computer graphics, rendering a triangleTemplate:Mdashthe "Hello Triangle"Template:Mdashis sometimes used as an introductory example for graphics libraries.[18][19]

Time to Hello World

"Time to hello world" (TTHW) is the time it takes to author a "Hello, World!" program in a given programming language. This is one measure of a programming language's ease of use. Since the program is meant as an introduction for people unfamiliar with the language, a more complex "Hello, World!" program may indicate that the programming language is less approachable.[20] For instance, the first publicly known "Hello, World!" program in Malbolge (which actually output "HEllO WORld") took two years to be announced, and it was produced not by a human but by a code generator written in Common Lisp Template:See above.

The concept has been extended beyond programming languages to APIs, as a measure of how simple it is for a new developer to get a basic example working; a shorter time indicates an easier API for developers to adopt.[21][22]

Wikipedia articles containing "Hello, World!" programs

Template:Flatlist

See also

Script error: No such module "Portal".

References

<templatestyles src="Reflist/styles.css" />

  1. Script error: No such module "citation/CS1".
  2. Script error: No such module "citation/CS1".
  3. Script error: No such module "citation/CS1".
  4. Script error: No such module "citation/CS1".
  5. Script error: No such module "citation/CS1".
  6. Script error: No such module "citation/CS1".
  7. Script error: No such module "citation/CS1".
  8. A Tutorial for the Go Programming Language. Template:Webarchive The Go Programming Language. Retrieved 26 July 2011.
  9. Script error: No such module "citation/CS1".
  10. Script error: No such module "citation/CS1".
  11. Script error: No such module "citation/CS1".
  12. Script error: No such module "citation/CS1".
  13. Script error: No such module "citation/CS1".
  14. Script error: No such module "citation/CS1".
  15. Script error: No such module "citation/CS1".
  16. Script error: No such module "citation/CS1".
  17. Script error: No such module "citation/CS1".
  18. Script error: No such module "citation/CS1".
  19. Script error: No such module "Citation/CS1".
  20. Script error: No such module "citation/CS1".
  21. Script error: No such module "citation/CS1".
  22. Script error: No such module "citation/CS1".

Script error: No such module "Check for unknown parameters".

External links

Script error: No such module "Side box". Script error: No such module "Side box". Script error: No such module "Side box".

  • The Hello World Collection
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".
  • Script error: No such module "citation/CS1".

Template:Standard test item