Lambda the Ultimate

inactiveTopic What does Hello World show?
started 3/28/2004; 12:20:37 PM - last post 3/29/2004; 5:55:28 PM
Albert Y. C. Lai - What does Hello World show?  blueArrow
3/28/2004; 12:20:37 PM (reads: 256, responses: 4)
Since K&R, it has become a cliche for language introductions to open with a hello-world program, and a habit for beginners to ask for one; now there is even a web page full of hello-world programs in different languages. After three decades of language development, it is time to question the usefulness of this mindset and habit.

For languages with a lot of coding overhead and line noise, a hello-world example is effective in getting the beginner up to speed with the ritual junk one must add to an otherwise simple and clear program, such as "public class MyFirstClass { public static void" in Java.

But for streamlined and succint languages --- a holy grail of language design --- a hello-world example is not going to illustrate any language feature (apart from succintness); in fact it is not supposed to be of any interest if the language is properly designed: a boring problem should be solved by a boring program. For example, The Haskell SOE opens with the gist of basic Haskell programming right away: computation by rewriting, types, and functions; there is a hello-world example, but it comes in the I/O chapter as nothing more than an I/O example. Similarly, SICP opens with expressions, procedures, and computation by substitution. (I am aware that both books are more than language introductions.)

I think we should begin educating programmers to develop the new habit of being impatient with hello-world examples (even critical in non-trivial ones) and asking for interesting first examples from language introductions.

sean - Re: What does Hello World show?  blueArrow
3/28/2004; 1:37:05 PM (reads: 246, responses: 0)
On a related note, I think programming language designers would be well-served by moving beyond the classic fact/fib/qsort examples, which give a skewed picture of typical programs. Unfortunately, it's probably too much work to do a real usability study or translate a significant program just for a paper.

Kevin Millikin - Re: What does Hello World show?  blueArrow
3/29/2004; 12:50:38 PM (reads: 186, responses: 0)
I always thought that the purpose of the "Hello, World!" program was to be a simple program with predictable observable output that could be experimented with to learn the platform dependent details of compiling, linking, and executing a program.

That is, I'm not really all that interested in how I would print "Hello, World!" to the terminal in Haskell, as a means of comparing Haskell to C. But it sure was nice to have a Hello World program when I was trying to figure out how to use GHC to build a standalone executable on my favorite OS.

K&R seem to agree:

This is the big hurdle; to leap over it you have to be able to create the program text somewhere, compile it successfully, load it, run it, and find out where your output went.

Adewale Oshineye - Re: What does Hello World show?  blueArrow
3/29/2004; 1:32:24 PM (reads: 173, responses: 0)
The PLEACE project: http://pleac.sourceforge.net/ has a nice approach to this problem. They're re-writing all the examples in the perl cookbook in a variety of other programming languages in a bid to identify idiomatic solutions to various common programming problems.

Admittedly their definition of "common programming problem" could be wider but it's a nice start.

sean - Re: What does Hello World show?  blueArrow
3/29/2004; 5:55:28 PM (reads: 148, responses: 0)
I haven't had a chance to look at it in detail, but PLEAC seems quite impressive as a broad sample of common, small programming problems. I particularly enjoyed the Haskell version's rampant use of composition and pointless style, which made it superficially familar for the Java programmer (e.g. "obj.meth.otherMeth(5)"). And no offense, but at least to me,

dir' = argv >>> ((||| ["/tmp"]) $ head)

can probably give Perl a run for its money in the obfuscation department.