Rethinking Hello World

Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

Rethinking Hello World

  • Comments 8

Is it time to rethink and replace “Hello world?” Honestly I think so. The purpose of “Hello Word” is to walk a beginner through the process of creating a minimal computer program and getting it to run. It probably made sense when one had to use a text editor to  create a file and then manually run it through a compiler and a linker to get to the run part. For modern integrated development environments (IDEs) I’m not so sure it makes since though. It is fairly easy to enter some simple code and hit the F5 button and get a running “Hello World” to run. So what is the problem? What is the harm? Well two things.

One is that the process doesn’t feel like it makes sense. It is just too trivial and too boring. As I  said before using an IDE is easy for students who have grown up with word processing and similar programs from early childhood. Why waste time with something that means nothing? Plus it violates Astrachan’s law - “Do not give an assignment that computes something that is more easily figured out without a computer, such as the old Fahrenheit/Celsius conversion problem.” OK “Hello world” is not exactly an assignment but more like a demo/exercise. And I am going to suggest a more powerful and interesting version of Fahrenheit/Celsius conversion but bare with me.

The second problem is that “Hello World” does not lend itself to enough experimentation. I think that students get more out of a project, even a simple demo exercise, if they can play with it and stretch their creative muscles a little before moving on. What can you do with “Hello world?” You can change the message. If you want to introduce an input statement and a concatenation operator you can try some personalized messages. None of this makes for any thing but a slightly different trivial exercise.

With text based console applications there isn’t much you can do though. It’s a lot of work to add loops so early for example. On the other hand with Visual Basic and C# from Visual Studio beginners can get graphic easily without writing any code. For years I have been using a version of the Fahrenheit/Celsius conversion that doesn’t require more than two lines of code with both of them being assignment statements. I use a form with two labeled label boxes and a slider bar.

clip_image002

The two lines of code can be as simple as

Label1.Text = VScrollBar1.Value
Label2.Text = ((Val(Label1.Text) - 32.0) * (5.0 / 9.0))
In this case I am taking advantage of some explicit type conversions of course and a little “hand waving” and “we’ll explain more of this later” but most students with some understanding of algebra should be able to handle it. You also have to spend a few minutes explaining setting some object parameters but that is a basic thing that will pay off later. It’s useful I think to get it in early as well. The result is an interactive routine that students can play around with.  

The next benefit is that you can turn students loose and ask them to modify it to do other conversions. Currency, weights (Imperial to metric), volume or any of many that students may find interesting. This lets students take a little ownership and experiment a little in a safe simple project.

So what do you think? Is this too much for a “Hello world” replacement or does a little additional complexity pay off in building early interest? Have you tried something to replace “Hello world” and if so what works for you?



  • I usually test any new GUI library with simple two  textedit and one button.

    when button is clicked text from textedit 1 is copied to textedit 2.

    this could be harder that your hello world , but it shows a lot about GUI library and how it is working.

  • I've done something like that a few times. It is even more interesting if you set the fonts of the two boxes differently. Students seeem to like Wingdings. :-)

  • GUI Hello World shouldn't be about specialized UI widgets, because those change depending on the purpose of UI libraries.

    In my opinion, good "Hello world" should form a good base for experimentation. Ideally, in 2010, the boilerplate that you need to write should be minimal. I think following two aspects give a solid base to start writing any kind of toy programs:

    1) show something on the screen

    2) and react to a user input

    The original "Hello world" program is missing the second part, but even in the command-line environment, if you can immediately learn how to receive some kind of input, you already have necessary building blocks for interesting programs.

    In game UI framework that my company is building, we always start with a following simple "hello world", that introduces these necessary concepts. It shows a logo and when the logo is tapped, it rotates its. The image could be easily replaced by text, thus reducing a need to have an image resource as a part of your project.  

    #include "app.h"

    class MyGame {

    MyGame(const Screen& screen) : App(screen) {

       Layer logo = root.image("logo.png");

       when(logo.tap(), logo.rotate(By(360));

    }

    };

  • My first experience with programming was on a small keyboard device with a single line monochrome display. I was introduced to BASIC at the age of nine. My first program was effectively 'Hello World.'

    I am a recent college graduate from a school in the Northeast, working as a senior developer at a Fortune 500 company, and I do not like the concept of teaching new programming students how to use an IDE (from the start). An IDE should be a tool, an instrument, and not a learning crutch.

    When I first learned assembler in my community college I learned how a processor worked. When I learned about a compiler, command line tools, etc I realized how an operating system is built (and works). I feel that students nowadays are graduating from college with only the knowledge to decipher the output that the IDE gives them, not think for themselves and definitely not use programming as a creative outlet.

    But I do agree with your example: teaching assignments need to allow the student to visualize the purpose of the problem. Your assignment above does this well.

  • I would disagree.

    "Hello World" has one aim in life for a person learning programming from scratch, and that is as a confidence builder.

    To give you are example from Microsoft Visual C# 2008 - Step by Step, the Hello World example introducts the student to:

    a. Creating a Project.

    b. The Solution Explorer.

    c. Intellisense.

    Which is enough to take on board, without making the first program more complicated than "Hello World".

  • It's a tradition in the computing world that we learn a new programming language by writing a program that prints the phrase "hello, world" and I believe that this tradition should be passed along to students. I like your program as a second example.

    Note: I believe student exposure to programming should be via the command-line and not graphical. They learn to use a Unix system using BASH and then the first program becomes:  echo hello, world

  • I have to ask, with my tongue half way in my cheek, if command line is good wouldn't punch cards be better?

  • "if command line is good wouldn't punch cards be better?"

    Now, now, we'd be showing our age if we did that :-)

Page 1 of 1 (8 items)