views:

275

answers:

11

Hello,

Many programming languages introduce themselves with a simple "Hello World" program.

As a programmer, I must admit that this does not give very good insight into the strenghts and capabilities of the language.

What kind of problem would you suggest to use when providing a demo of a programming language?

+3  A: 

IMHO, the purpose of the hello world program is to show a very simple program in that language, not to show the strengths and capabilities.

It would be hard as each language has its own strengths. Comparing a standard set of functions for each language might be asking for trouble, especially for an intro book.

moogs
+10  A: 

I think the "Hello World" program has its uses. It says a lot if you can run that program:

  • You have your IDE/Tools setup correctly
  • You can write a class and or main method in that language
  • You can call a function in that language to print
  • You can edit a file and format it correctly for that language
  • Your compiler is working and you know how to use it.

So, for those reasons I don't find any better alternative to "Hello World."

However, in terms of a good intro to languages in general, I'm a big fan of coding challenges like Python Challenge. You are given a set of challenges/puzzles you have to complete with the language. They start out extremely basic (the first one is easier than writing a hello world).

They quickly progress into more difficult and advanced tasks, and usually are tasks that are intended to show off a particular aspect of the language.

I only wish every language had such a fun programming challenge. I think a LISP, Haskell, C++, C, Java, etc Challenge would be a fun introduction to the languages for people. They could be tailored to the languages.

The C++ challenge could quickly start having challenges involving pointers and other commonly misunderstood aspects to help drive home those difficult bits while the LISP/Haskell challenges could start to ask some questions that are more tailored to functional languages.

Simucal
You are always free to adapt the challenge to any other language. Just means you will have less hand holding and some of the hints won't work as well :P
X-Istence
@X-Istence, many of the challenges are meant to show off a feature of Python. So yes, you can complete all but challenges 5 and 23 with another language. However, it wouldn't have the same effect.
Simucal
Thanks for that link to the Python Challenge!
onnodb
+1 for the succinct list of what "hello, world" is for. Notably, being a sensible demonstration of a language's strengths and weeknesses is *not* on that list.
RBerteig
A: 

Depends on what core feature of the language sets it apart from other languages out there. The Haskell quicksort comes to mind.

With that said, hello world does show how to immediately produce some sort of output.

Hank
A: 

Personally when I start out in a new programming language I attempt to re-write a piece of code that I have already written in a different language so that I can get a feel for the language and see how it relates back to what I have already learned in my previous programming experiences.

People suggest programming simple stuff like binary search trees, and other data structures along with a simple way to test that it works. The other thing is to not give up on the programming language when things start to get complicated or do not fit in with your previous experience.

As for looking for the strengths in programming languages? Well, start out by writing a small application and then once you have a feel for the language look at open source projects written in this language. See what it does very well, look at mailing lists found out where the difficult parts were for that project, where they had to work around some idiosyncrasy in the language that caused them issues.

Certain languages you know right off the bat that they were meant for a certain task and using them outside of that task is not recommended. For example, PHP is a web programming language, the fact that you can write big programs in it and run them on the command line does not mean it is a language that should be used for those tasks.

X-Istence
+4  A: 

If you are worried about the scope of a "hello world" program, you can always upgrade to "hello universe"

Gamecat
+3  A: 

Larry O'Brian wrote three very good blog posts on exercises to familiarize yourself with a programming language.

Part 1: Basics

Part 2: Data Structures

Part 3: Libraries, Frameworks and Mashups

Einar
Very nice collection, I foretell future sundays spent on hacking ;)
Adrian
A: 

fizz buzz question.

+2  A: 

"99 bottles of beer" is a slightly more involved example than "Hello world", so it can show the things that differentiate one language from the others.

Check out http://99-bottles-of-beer.net/ .

A: 

I was very favorably impressed by Bjarne Stroustrup's choice to make a quite powerful calculator, including parsing. I expected that it would be too difficult as a first project, but he does an excellent job step by step. And the final application is not a toy.

All in his new book, Programming Principles and Practice in C++.

SPWorley
A: 

I some cases "Hello world" may be non-trivial. See for example Struts 2 "Hello world". To have it working you'd need to have server set up, environment set up, your app deployed, etc.

vartec
A: 

Well a "blinky" is a good alternative, but that is more in the embedded world that this is relevant...

For you who have misses out on blinky, it is just to get a LED to blink on/off at steady pace. Kind of shows how to work with gpio.

/Johan

Johan