Hello World

HelloWorld is a term for any simple program or component that verifies the correct functioning of the environment, usually by outputting the words "Hello World''. HelloWorld holds very little value in the learning or evaluation of a language and its constructs. Its primary purpose is to ensure that compiler is in the path, the libraries are in the right place and the build script is sane.

When configuring a new environment or coming to an unknown environment, verifying that HelloWorld behaves correctly should be the first step. Once you get it running, you can edit this stub to become anything. It may be thought of as a SpikeSolution for your environment configuration.

It can also be a useful step in a debugging a program that is modifiable at runtime to ensure that you're editing the right thing and that it is being reloaded (ie. adding "Hello World" to the top of a JavaServerPage).


Console based HelloWorld is seriously out-dated. In the 80s, HelloWorld programs should have been written using SMTP. In the 90s, they should been written to produce a dialog. In 2000, an HTTP service was the way to go. Nowadays, our HelloWorld programs should use SMS.

How in the world is Console-based HelloWorld outdated?!? As someone who programs in PythonLanguage, and aspires to CommonLisp, HaskellLanguage, and SmalltalkLanguage, I happen to like using the console a lot, thank you very much! The console still has many practical uses (among which, it's a nice place to start programming, because of its simple nature), so to claim that it's "out-dated" is far-fetched, at the very least.


History

The first known use of HelloWorld was by Kernighan in his "A Tutorial Introduction to the Language B" (which predates the CeeLanguage). See http://www.cs.bell-labs.com/~dmr/bintro.html and section 7 of the tutorial linked from that page.

KernighanAndRitchie included a section in their C book that explained how to compile and run a simple program. They offered one that printed Hello World. This popular book is what first made HelloWorld world famous.


Hello World As A Learning Tool

Hello World, while often the first program introduced in an introductory programming text, is actually not aimed at teaching the language at all. It's about teaching the programmer how to configure their environment. Once Hello World has been achieved, actual learning of the language can begin. The following are some suggested starting points:

I think if our culture agreed upon such things, more people would be better inclined to learn more programming languages, as I find I will learn the syntax of a language and not know what to do to try and just get acquainted with it. I mean, HelloWorld teaches me nothing about a language's control structures, data structures, or input. Though, a common one I've heard is, making the "Guess a number from 1 to 100' game. I wonder if HuntTheWumpus might be better... -- NickBensema

"Hello, World" doesn't teach much about the language, but it does teach something very important - the computer is a tool that you control. It was an AhaMoment for me, as I realized that I created an executable program, simplier but fundamentally the same as all those other programs I'd been running for years. I believe the first modification to this program is one of the most important - in my case, changing the message to "Hello, John!". Followed, of course, by an infinite loop saying "John is Great!" It is the moment where I ceased to be a mere computer user, and became a computer programmer. -- John Whitlock

I do agree, it's the way all programming books I've encountered are tending. The base philosophy of
"Tell me and I will forget, Show me and I will learn, Let my try and I will understand"

Whenever I pick up a language, even if I'm just working from a syntax description, the first thing I produce is "Hello World". -- MartinDixon.


Hello World as a Language Comparison Tool

Many implementations of Hello World are available at HelloWorldInManyProgrammingLanguages.

HelloWorld tests if simple things are simple to implement. That doesn't mean that a language which can't do HelloWorld simply is bad in general, just that it's probably the wrong choice for emitting mainly static text. In some cases, the implementation of hello world demonstrates that learning the framework required in a language is more difficult than the incremental learning of its commands or constructs.

One potentially useful use of Hello World as a basis for comparison is to compare the size of the executable that the language generates, and how much supporting infrastructure must exist behind the program for it to execute.

EXE magazine in the UK ran a series at one stage, comparing languages with a somewhat more involved example (it may have been calculating the length of the third side of a triangle from the other two). This was slightly more useful as it told you a little more about the language's libraries and the build framework.

This interested me when I was working in DEC's Trellis/Owl OO environment. Delivering a working copy of a non-graphic "Hello, World!" to another workstation required at least 1.7meg of disk space (after trimming unused classes from the environment). -- RonLusk

Sure, I learned a great deal about WinCE programming when I flicked through the book and saw that the hello world program was six pages long... -- AnonymousDonor


Humor

According to tradition, trying to exec(2) a C program that isn't derived from HelloWorld will fail with errno set to ENONSEQUITUR. However, all C programs known to man are derived from HelloWorld, so it has so far been impossible to corroborate this claim.


Writing hello world has become a bit of a tradition, though some of the implementations may not meet the original goals. I'm reminded of the four pages of gobbldegook that would print hello world on a PenPoint? computer. I once sat in with a group that had just gotten it to work. I suggested an improvement. Make it say, Hello Ward. Debugging this small change took us the rest of the day.

(In case you are curious, the string appeared twice in the PenPoint? program, once relating to font metrics, again where it was actually printed. It took us forever to find that second string among all of the other system calls required to write anything on the screen.)


Hello World in the world beyond programming

When Tiger Woods burst upon the professional golf scene in late 1996, the series of Nike commercials that introduced him were themed "Hello, world". I wonder - did Mr Woods take any programming classes at Stanford?

And of course, where would we be without the lyrics to the song "Hello World!"...

http://server14.hypermart.net/eeyore/helloworld.htm (beware - lots of popups)?


The quintessential "Hello, world!" isn't really this:
 #include<stdio.h>
 int main(){
  printf("Hello, world!");
 }
Rather, it's the above C code and this:
 cc hello.c
 ./a.out
I've begun to think of a HelloWorld as a litmus test for software packages other than languages, now that I'm starting to be asked to evaluate and select software components for use by the company. A "sane environment" combined with a working program is a great test to put against software packages, especially under time constraints; it only takes 5 or 10 minutes to check for it and confirm or deny that it exists.

Specifically, a package can probably be rejected unless the software provider includes a complete, working example that demonstrates the most important features of the system. That includes source code for the example, how to set up the development environment, how to build the program, how to run it, and the expected output. Software that does not come with this is probably undocumented in all other ways, or has some very mysterious problem that prevents a working example from being possible, such as an embarrassing amount of necessary configuration.

My two recent examples are trying to set up an AzMan? store using ADAM (Google it) and attempting to use "ASP.NET Ajax", formerly Atlas. AzMan? and ADAM both lack working "Hello World!" scenarios, and certainly lack one in combination. I gave up on both pieces of software after weeks of fiddling. ASP.NET Ajax is probably close enough, but only includes using special type of web project from scratch - there weren't instructions for adding it to an existing web site.


You can also take a look at the wikipedia link: http://en.wikipedia.org/wiki/Hello_world_program


Contributors: FrankAdrian, WayneCarson, DaveHarris, DavidHarvey, KielHodges, RalphJohnson, PaulChisholm, DanielSheppard, JonathanTang, AnonymousDonors

see also LearningProgrammingLanguages LearningObjectOrientedProgramming

EditText of this page (last edited November 13, 2014) or FindPage with title or text search