Monday, November 14, 2005

The Canonical Program

Perhaps the single most influential book on programming is The C Programming Language, by Brian Kernighan and Dennis Ritchie.

It begins like this:
1.1 Getting Started

The only way to learn a new programming language is by writing programs in it.The first program to write is the same for all languages: Print the words hello, world

This is the basic 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. With these, mechanical details mastered, everything else is comparatively easy.


Since K&R, everyone's begun this way. No sense going against the crowd if you don't have to. Let's begin.

# The canonical program

echo hello, world # note that '#' starts a comment

You can type these lines into a file, make the file executable, and run it as a command. You can also just type the lines at the command prompt. The result is the same. It's a programming language. It's a command-line language. It's new Shimmer.

(You can omit the comments, but it's more fun to type them in.)

Give it a try.

0 Comments:

Post a Comment

<< Home