Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
"Hello, World!" program
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=="History"== [[File:Hello World Brian Kernighan 1974.jpg|thumb|"Hello, World!" program handwritten in the [[C (programming language)|C language]] and signed by [[Brian Kernighan]] (1978)]] While several small test programs have existed since the development of programmable [[computer]]s, 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]]'',<ref>{{cite book |last1=Kernighan |first1=Brian W. |author1-link=Brian Kernighan |last2=Ritchie |first2=Dennis M. |author2-link=Dennis Ritchie |date=1978 |title=The C Programming Language |edition=1st |publisher=[[Prentice Hall]] |location=[[Englewood Cliffs, New Jersey]] |isbn=0-13-110163-3 |url-access=registration |url=https://archive.org/details/cprogramminglang00kern}}</ref> with likely earlier use in [[BCPL]]. The example program from the book prints {{samp|"hello, world"}}, and was inherited from a 1974 [[Bell Labs|Bell Laboratories]] internal memorandum by [[Brian Kernighan]], ''Programming in C: A Tutorial'':<ref name="ctut">{{cite web |url=https://www.bell-labs.com/usr/dmr/www/ctut.pdf |title=Programming in C: A Tutorial |last1=Kernighan |first1=Brian |author1-link=Brian Kernighan |year=1974 |publisher=Bell Labs |url-status=live |archive-url=https://web.archive.org/web/20220322215231/https://www.bell-labs.com/usr/dmr/www/ctut.pdf |archive-date=22 March 2022 |access-date=9 January 2019}}</ref> <!-- ********** Editor's Note: We do not need to have an example for every programming language ever created. Wikipedia is an encyclopedia. Please refrain from adding examples just because we can. If you think a particular example adds something unique and valuable to the article, petition on the talk page, first. Thanks. (User: DragonHawk) Addendum: there are large repositories of Hello, World! programs all over the net, in every conceivable language. No need exists to list them all here. In fact, there is now a very comprehensive Wikibooks link: if you want to add a version for your language, do so there (you'll likely find it already exists). HERE IS NOT THE PLACE. The C version (which is not even correct in modern C) is here because it is the first in a non-obscure language, and the B example because it is the first known. There is no reason to have many others here. ADD NO MORE! ********** --> <!-- ADD NO NEWLINE, HEADER FILE, ADJUST WHITESPACE, OR INT DATA TYPE TO THIS CODE. THE ORIGINAL IN 1974 DIDN'T HAVE THEM, THANKS --> <!-- See https://www.bell-labs.com/usr/dmr/www/ctut.pdf for original. --> <syntaxhighlight lang="c"> main( ) { printf("hello, world"); } </syntaxhighlight> In the above example, the {{samp|main( )}} [[subroutine|function]] defines where the program [[Entry point|should start executing]]. The function body consists of a single [[Statement (computer science)|statement]], a call to the {{samp|printf()}} function, which stands for "''print f''ormatted"; it outputs to the [[Console application|console]] whatever is passed to it as the [[Parameter (computer programming)|parameter]], in this case the [[String (computer science)|string]] {{samp|"hello, world"}}. The C-language version was preceded by Kernighan's own 1972 ''A Tutorial Introduction to the Language [[B (programming language)|B]]'',<ref name="langb">{{cite book |last1=Johnson |first1=S. C. |last2=Kernighan |first2=B. W. |author2-link=Brian Kernighan |url=https://www.bell-labs.com/usr/dmr/www/bintro.html |title=The Programming Language B |publisher=Bell Labs |url-status=live |archive-url=https://web.archive.org/web/20150611114355/https://www.bell-labs.com/usr/dmr/www/bintro.html |archive-date=11 June 2015 |access-date=8 August 2024}}</ref> where the first known version of the program is found in an example used to illustrate external variables: <!-- Do not adjust the whitespace or otherwise change this example below as it is meant to match the original in the source. --> <syntaxhighlight lang="text"> main( ) { extrn a, b, c; putchar(a); putchar(b); putchar(c); putchar('!*n'); } a 'hell'; b 'o, w'; c 'orld'; </syntaxhighlight> The program above prints ''{{samp|hello, world!}}'' 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 ''{{samp|hi!}}'' on the terminal, and the phrase ''{{samp|hello, world!}}'' 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]].<ref>{{cite web |url=http://www.catb.org/jargon/html/B/BCPL.html |title=BCPL |work=[[Jargon File]] |access-date=21 April 2013 |archive-date=3 April 2018 |archive-url=https://web.archive.org/web/20180403000549/http://www.catb.org/jargon/html/B/BCPL.html |url-status=live}}</ref> 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 (DJ)|William B. Williams]] beginning in the 1950s.<ref name=nytobit>{{cite web |url=https://select.nytimes.com/search/restricted/article?res=F50714FF3E5B0C778CDDA10894DE484D81| title=William B. Williams, Radio Personality, Dies |work=The New York Times |date=4 August 1986}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)