February 15, 2006
The archetypal Hello World program has always had a calming effect on developers. It's been a programming staple for decades:
[Hello World] is typically one of the simplest programs possible in a computer language. Some, however, are surprisingly complex, especially in some 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 LCD. In yet other systems, a single LED may be turned on.
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.
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 the 1978 book The C Programming Language. The example program from that book prints "hello, world" (no capital letters, no exclamation sign; those entered the tradition later). The book 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.
Wikipedia also has a ridiculously comprehensive list of Hello World programs in hundreds of programming languages, some of them extremely esoteric (read: joke) languages.
On the Great Win32 Computer Language Shootout page, amongst all the various benchmark tests, there's even a Hello World performance test :
Of course, it's a completely useless performance test. But that's very much in the spirit of Hello World.
Posted by Jeff Atwood
Next time I see somebody write a Hello World program in Java, I'll tell them it will be more performant in C :))
Two thoughts. One is that I'm slightly disappointed that the list in Wikipedia does not (AFAIK) include the sample "Hello, World" program that Petzold published in his first Windows programming book. That was a real eye-opener for a lot of people who got from that a sense of what programming that new-fangled' GUI was going to be all about.
The other thought is that the page is in some senses a matrix that compares the algorithmic granularity of assembly languages (all those steps!) versus the comparatively minimal effort of a simple C statement versus the scaffolding required in an OOP-based approach. That is, it's a (very) rough gauge of the high-levelness of languages.
Anyway, very interesting. We can be sure that as new programming languages are invented, it will always be "Hello, World" that will be the first program illustrated in the book.
Whoa, I retract my first comment -- just found it under Windows API (shorter version).
I've been working on an artificially intelligent agent based software who's first task will be to write a "Hello World" program.
I wouldn't say completely useless. It gives you an indication of how elegant a language is (Number of lines) and how expensive its environment/framework is (mem and cpu time).
Hello, World! in assembler takes only 27 bytes.
mov ah, 9
mov dx, String
mov ah, 04Ch
db 'Hello, World!', 0Dh, 0Ah, '$'
Cool, I should add Progress ABL (formerly 4GL) when I have a chance.
Jeff, I'd like to know why you think this test is "completely useless". Or did I miss the sarcasm?
Displaying output on a computer screen is a pretty basic function of many programs, and it would seem this test measures the performance of doing that.
I'd also be interested in another benchmark: how long it takes to code "hello world" in each language :)
The point of this particular benchmark is to measure the load/initialization cost. The assumption is that the actual "Hello, World!" cost is negligible, so the test is actually measuring startup costs. I'm not entirely sure, but I think the Shootout folks even subtract this benchmark from their other tests to control for language startup costs.
Startup time can be critical for some applications. In most GUIs, the startup time is a large factor in how fast the user perceives the application to be. In shell scripting, it's usually the dominant cost - one reason why Java is completely unsuitable as a scripting language.
it would seem this test measures the performance of doing that
I'm sure the CEO of Hello, World! Incorporated will be riveted by these benchmark results.
You have to benchmark things that people actually use. This is a common criticism of video card reviews. How many 3D Mark 2006 units a video card scores is irrelevant. It doesn't help me understand whether the card will be fast in the games I actually play. Will it play Battlefield 2 at 1600 x 1200 with 4x antialiasing at a sustained 60fps in my multiplayer games?
Very interesting statistic:)
amusing but useless. people may look at this and say "oh boy, stay away from erlang", except erlang is starting up a runtime that provides for more efficient concurrency than any of the other tools.
now what would you rather run?
Objective Caml: A high-level functional programming language with: (1) a powerful type system, equipped with parametric polymorphism and type inference; (2) user-definable algebraic data types and pattern matching; (3) and automatic memory management.
And it's freakin' *fourth*!
Guess they weren't kidding about (4) efficient native code compilers. :)
Ole: The test is completely useless as benchmark because Hello World is so small that you have the load/initilization cost and the actual "Hello, World!" costs mixed together. Unless you're actually trying to make the fastest Hello World program for some reason, it's useful only for humor's sake. On real tasks this initilization time gets amortized over the life of the program.
The worlds shortest Hello World, must be in monad.
Here is the script
just save that one line to hw.msh and run it.
Also, if you use my code signing scripts at www.reskit.net/monad you can end up with the worlds most secure hello world. :-)
"a completely useless performance test"
Perhaps you don't understand what it's being used for?
The Computer Language Shootout FAQ a href="http://shootout.alioth.debian.org/"http://shootout.alioth.debian.org//a
"Each program was run as a child-process of a Perl script. We take the script child-process usr+sys time, before forking the child-process and after the child-process exits... The Full CPU time includes program startup time."
The hello world programs are included to provide some idea about startup costs.
'people may look at this and say "oh boy, stay away from erlang"'
Would anyone really choose to ignore "the various benchmark tests" and make a decision based on a 3 line program :-)
Jonathon Tang wrote: "one reason why Java is completely unsuitable as a scripting language"
I don't think so.
Even if you take the "hello world" times at face value, it just amounts to a few hundredths of a second. (And that goes away when you use an ahead-of-time compiler a href="http://www.excelsior-usa.com/jetfaq.html#internals)"http://www.excelsior-usa.com/jetfaq.html#internals)/a
People do use Beanshell a href="http://www.beanshell.org/"http://www.beanshell.org//a
Jeff Atwood wrote: "You have to benchmark things that people actually use"
People actually use a mind-boggling variety of things.
You have to benchmark your own application.
There is no longer a list of hello world programs for esoteric languages, as far as I can tell.