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 View blog reactions
« Fear of Writing Colorization Required »
Next time I see somebody write a Hello World program in Java, I'll tell them it will be more performant in C :))
Steven on February 16, 2006 05:37 PMTwo 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.
mike on February 16, 2006 06:12 PMWhoa, I retract my first comment -- just found it under Windows API (shorter version).
mike on February 16, 2006 06:15 PMI've been working on an artificially intelligent agent based software who's first task will be to write a "Hello World" program.
Haacked on February 16, 2006 06:17 PMI 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).
mark on February 16, 2006 06:40 PMHello, World! in assembler takes only 27 bytes.
mov ah, 9
mov dx, String
int 21h
mov ah, 04Ch
int 21h
String:
db 'Hello, World!', 0Dh, 0Ah, '$'
Cool, I should add Progress ABL (formerly 4GL) when I have a chance.
Molly
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 :)
Ole Eichhorn on February 16, 2006 11:50 PM> 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?
Jeff Atwood on February 17, 2006 01:52 AMVery interesting statistic:)
Andrej Gaevskij on February 17, 2006 02:30 AM:O
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. :)
Rahul on February 17, 2006 11:13 AMOle: 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.
JimDesu on February 17, 2006 12:52 PMThe 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.
Jonathan Tang on February 17, 2006 01:20 PMamusing 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.
http://www.sics.se/~joe/apachevsyaws.html
now what would you rather run?
grumpY! on February 17, 2006 05:13 PMThe worlds shortest Hello World, must be in monad.
Here is the script
"Hello World"
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. :-)
tfl on February 19, 2006 09:11 AM"a completely useless performance test"
Perhaps you don't understand what it's being used for?
The Computer Language Shootout FAQ http://shootout.alioth.debian.org/
"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.
Isaac Gouy on February 23, 2006 03:00 PM'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 :-)
http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=hipe&lang2=hipe
Isaac Gouy on February 23, 2006 03:05 PMJonathon 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 http://www.excelsior-usa.com/jetfaq.html#internals)
People do use Beanshell http://www.beanshell.org/
Isaac Gouy on February 23, 2006 03:12 PMJeff 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.
++++++++++[>+++++++>++++++++++>+++>+++.>+.+++++++..+++.>++..+++.------.--------.>+.>.
The most short Hello World is written in HQ9
And is:
H
Here you have more info http://en.wikipedia.org/wiki/HQ9+
There is no longer a list of hello world programs for esoteric languages, as far as I can tell.
Invinciblegod on September 4, 2007 02:02 AM| Content (c) 2008 Jeff Atwood. Logo image used with permission of the author. (c) 1993 Steven C. McConnell. All Rights Reserved. |