This is my blog. I am your host, Karl Meissner. My web site is here .
I am a professional software developer with an interest in good, solid code.
I wanted to blog about some of my areas of interest.
These include programming video games, automation, controllers, compilers, parsers, 3D graphics, Artificial Intelligence, and mobile platforms.
I will review technologies and tools that I use when developing. Good tools make us smarter.
Finally, I wanted to share some reflections on being a software contractor in the post-dotcom world and being successful at it.
For my first topic, I wanted to talk about the computer science classic program “Hello, World.”
In most colleges and universities, fresh young Computer Science majors take some course like Programming 101. It is an informal tradition that the first program taught is called “Hello, World.” It is a short program that prints the text “Hello, World” to the screen.
When I took the course, the programming language was in Modula-2, a derivate of Pascal. These days, it could be in Java. Other courses might teach C++, Simula, ADA, Lisp, COBOL, Perl, Ruby, Python, or Fortran. Here is a list of many “Hello, World” programs in many languages. Look at all the different ways of doing the same thing!
These are all different languages, all with different purposes, strengths, and weaknesses. However, “Hello, World” is usually the first thing taught.
With so many languages that work in so many ways, why do classes start with learning “Hello, World?”
Any general purpose programming language has to be able to generate some output that a person can read. The early computers were text-only, on a single console. We are still rooted in that tradition even after decades of GUI’s and the internet. Just about all programming languages can output the text “Hello, World.”
Programming is largely an exercise of design and craftsmanship. There is an entire publishing industry made up of Manuals, Guides, and “Introduction To’s.” But to really learn a craft, start with a simple example and then try it yourself. You become a better craftsman when you practice your skill. We start with the example, “Hello, World,” then we try to do it.
The program generates some output. If you can generate output, you can see it working. The programmer can test his work. This is one the fundamental principles of good development:
Do some work,
Does the program generate the output at all? Can the student make that happen? Is the text correct? Did it show up in the right place?
Inevitably, our craftsmanship falls short of the task. The world is exceptional, so the code has bugs. For some reason, the output is wrong. The text is wrong, the database entry is not correct, the sum is not correct, the web page does not load. There are multiple reasons that the code can be in error. If we understood our creation perfectly and had the capacity to hold it all in our mind, we could simply analyze the code and solve the mistake that way.
Most programs are many times too big and do too many complicated things. We illuminate the workings of our code with outputs. Output messages are sent to the screen or to a log so we can trace the execution of the code and see what happened. It is one the fundamental tools we can use as programmers.
So all programs courses start with teaching Hello World, not because it is a silly tradition but because sending text to the screen is one of the fundamental debugging tools of any programmer.
So Hello, World!
Monday, May 28, 2007
Computer Science: Hello World
Posted by Karl Meissner at 6:15 AM No comments:
Labels: Hello World, introduction programming, testing
Subscribe to: Posts (Atom)