The Real Cost of Hello World

The archetypal Hello World program has always had a calming effect on developers. It's been a programming staple for decades:


This is a companion discussion topic for the original blog entry at: http://www.codinghorror.com/blog/2006/02/the-real-cost-of-hello-world.html

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
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 :slight_smile:

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.

http://www.sics.se/~joe/apachevsyaws.html

now what would you rather run?

:open_mouth:

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. :slight_smile:

1 Like

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

“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. :slight_smile:

"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 :slight_smile:

a href="http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=hipelang2=hipe"http://shootout.alioth.debian.org/gp4/benchmark.php?test=alllang=hipelang2=hipe/a

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.