Hello world program

From Free net encyclopedia

(Redirected from Hello world)

Template:Cleanup-date

A "hello world" program is a software program that prints out "Hello, world!" on a display device. It is used in many introductory tutorials for teaching a programming language and many students use it as their first programming experience in a language.

Introduction

Such a program is typically one of the simplest programs possible in a computer language. Some, however, are surprisingly complex, especially in some graphical user interface (GUI) contexts; but most are very simple, especially those which rely heavily on a particular command line interpreter ("shell") to perform the actual output. In many embedded systems, the text may be sent to a one or two-line liquid crystal display (LCD) (and in yet other systems, a simple LED being turned on may substitute for "Hello world!").

A "hello world" program can be a useful sanity test to make sure that a language's compiler, development environment, and run-time environment are correctly installed. Configuring a complete programming toolchain from scratch to the point where even trivial programs can be compiled and run may involve substantial amounts of work. For this reason, a simple program is used first when testing a new tool chain.

While small test programs existed since the development of programmable computers, the tradition of using the phrase "Hello world!" as the test message was influenced by an example program in the book The C Programming Language, by Brian Kernighan and Dennis Ritchie, published in 1978. The example program from that book prints "hello, world" (i.e., no capital letters, no exclamation sign; those entered the tradition later). The book had inherited the program from a 1974 Bell Laboratories internal memorandum by Kernighan —Programming in C: A Tutorial— which shows the first known version of the program:

 main( ) {
  printf("Hello, world!");
 }

However, the first known instance of the usage of the words "hello" and "world" together in computer literature occurred in A Tutorial Introduction to the Language B, by Brian Kernighan, 1973 [1], with the following code:

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

There are many variations on the punctuation and casing of the phrase, and the examples on this page print out several of these variations. Variations include the presence or lack of the comma and exclamation mark, and the capitalisation of the 'H', both 'H' and 'W', or neither. The most commonly accepted variation, despite not being the original text, is "Hello, world!" Some languages are forced to implement different forms, such as "HELLO WORLD!," on systems that only support capital letters, while many "hello world" programs in esoteric languages print out a slightly modified string. For example, the Malbolge program prints "HEllO WORld", this having been determined to be "good enough." "Hello world" programs also normally print a newline (ASCII character 10, character 13, or both).

Another known satirical variation is "Goodbye, cruel world", which has a slightly suicidal tone.

See also

External links

bg:Hello, world ca:Hola món cs:Hello world da:Hello world-program de:Hallo-Welt-Programm et:Hello world es:Hola mundo eu:Kaixo mundua fr:Hello world ko:Hello world 프로그램 id:Hello world ia:Hello World it:Hello world he:תוכנית Hello world hu:Helló, Világ!-program nl:Hello world ja:Hello world no:Hello, world nn:Hello World pl:Hello world pt:Programa Olá Mundo ro:Program Hello, world! ru:Программа Hello world simple:Hello world program sk:Hello world sl:PozdravljenSvet sv:Hello, World! th:Hello world vi:Chào thế giới! zh:Hello World程序