'Hello World!' - Programming Tradition

1 Conversation

Since the 1970s, it has become customary, when learning a new programming language or testing out an unfamiliar programming environment, to write a 'Hello world!' program with which to do so. This is a program that, quite simply, displays the words 'Hello world!' as output on the computer screen1. Although, due to the syntax of some languages, a 'Hello world!' program can sometimes appear quite complex, it is generally regarded as the simplest type of program that can be executed in a given language.

History

The first appearance of 'Hello world!' in a programming example was in 1972, in A Tutorial Introduction to the Language B by BW Kernighan. B was a precursor to the longer-lasting and better-known language C. Kernighan used the following example to illustrate a point about 'external variables':

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

a 'hell';
b 'o, w';
c 'orld';

This was just an isolated example — Kernighan could as easily have used 'look, a bus!'2 to illustrate his point, and no one would have noticed. But in 1978, Kernighan and co-author Dennis Ritchie wrote a book called The C Programming Language, still considered to be the authoritative reference on the language behind the UNIX operating system, among other things. In the very first section of the book, Kernighan and Ritchie used 'Hello world!' to explain how to write, compile and run a C program:

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

The C Programming Language was considered such a good example of technical writing that its style was emulated by successive authors of programming manuals, and many imitated Kernighan and Ritchie's use of 'Hello world!' as an initial sample program. It has become a handy tool because, as The C Programming Language demonstrated, a program that's very straightforward logically and does only one basic thing can then be used to teach someone how to use the language's syntax and other components such as its compiler.

Today, variants of 'Hello world!' are in use in just about every introduction to programming, whether in a book or on a website or in a classroom. 'Hello world!' is often the source of computer-geek jokes and cultural references. Unless the computing world suddenly decides to convert to 'look, a bus!' there's no reason to think that 'Hello world!' won't be around for years to come.

Examples

What follows are some examples of 'Hello world!' in a few common, popular programming languages. These are only a minuscule sampling of the range of 'Hello world!'.

BASIC

10 PRINT "Hello world!"

C (as mentioned above)

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

C++

main()
{
cout << "Hello world!" << endl;
return 0;
}

HTML

<HTML>
<BODY>
Hello world!
</BODY>
</HTML>

Java

class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello world!");
}
}

Javascript

<html>
<body>
<script language="JavaScript" type="text/javascript">
document.write('Hello world!');
</script>
</body>
</html>

PHP

<?php
echo 'Hello world!';
?>

Python

print "Hello world!"

UNIX Shell

echo 'Hello world!'

And, of course...

GuideML

<GUIDE>
<BODY>
<P>Hello world!</P>
</BODY>
</GUIDE>
1Though opinion is divided as to whether there should be an exclamation point at the end of the phrase, whether there should be a comma after 'hello', whether either or both of the words should be capitalised, and whether the whole phrase should appear in all caps, all lowercase or mixed case, this Entry will stick to the convention of 'Hello world!'2For purposes of random example.

Bookmark on your Personal Space


Entry

A30572859

Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry


Written and Edited by

Disclaimer

h2g2 is created by h2g2's users, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the Not Panicking Ltd. Unlike Edited Entries, Entries have not been checked by an Editor. If you consider any Entry to be in breach of the site's House Rules, please register a complaint. For any other comments, please visit the Feedback page.

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more