h2g2
10th February 2012
Accessibility help
Text only

Guide ID: A32016692 (Edited)

Edited Guide Entry


SEARCH h2g2
Edited Entries only
Search h2g2Advanced Search


or register to join or start a new conversation.

Homepage
The Guide to Life, The Universe and Everything.

3. Everything / Maths, Science & Technology / Computers

Created: 22nd April 2008
'Hello World!' - Programming Tradition
Contact Us



 
A 1983 Atari 800 home computer PC.

Since the 1970s, it has become customary when learning a new programming language or testing 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's generally regarded as the simplest type of program that can be executed in a given language.

History

The first recorded 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've just as easily used 'look, a bus!'2 to illustrate his point and no-one would have noticed. However, 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. Many imitated Kernighan and Ritchie's use of 'Hello world!' as an initial sample program. It's become a handy tool. 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, website or 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 every reason to believe 'Hello world!' will be around for years to come.

Examples

What follows are some examples of 'Hello world!' in a few common programming languages. This is 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>

1 Opinion is divided on whether there should be an exclamation mark at the end of the phrase, a comma after 'hello', and if either or both of the words should be capitalised, lower case or mixed case. This entry will stick to the convention of 'Hello world!'
2 For the purpose of a random example.


Clip/Bookmark this page
This article has not been bookmarked.
ENTRY DATA
Written and Researched by:

echomikeromeo

Edited by:

Icy North (GE)

Referenced Entries:

Computers
Java - the Programming Language
Unix
C - the Programming Language
Seven Secrets of Successful Programmers
BASIC - the Programming Language
Python - the Programming Language
HTML Tags
Dorks
An Introduction to the Unix Command Line
Travelling by Bus in London

Referenced Sites:

'Hello world!' examples
BBC Learning: Information...

Please note that Not Panicking Ltd is not responsible for the content of any external sites listed.


CONVERSATION TOPICS FOR THIS ENTRY:

Start a new conversation

People have been talking about this Guide Entry. Here are the most recent Conversations:

TITLE
LATEST POST
What? No ForTran, RPG, or COBOL?Apr 24, 2008




Disclaimer

Please note that Not Panicking Ltd is not responsible for the content of any external sites listed. The content on h2g2 is created by h2g2's Researchers, who are members of the public. Unlike Edited Guide Entries, the content on this page has not necessarily been checked by a h2g2 editor. In the event that you consider anything on this page to be in breach of the site's House Rules, please click here .




About | Help | Terms of Use