“Hello World,” C++ style

I cracked open Beginning C++ Through Game Programming (for the third or fourth time since I’ve owned it), and was immediately directed to Appendix A, “Your First C++ Program.”

I was instructed to install Dev-C++, a freeware IDE (Integrated Development Environment). Apparently Dev-C++ hasn’t been actively developed for years, but someone else picked it up and has been updating it under the name of wxDev-C++.  So I am planning on using it rather than Dev-C++.  If I run into any issues, I can always switch back.

So I fire up wxDev-C++, and am greeted with this:


Not intimidating at all, nosiree…

So I go to File -> New -> Source File (Or simply hit CTRL+N) to start a new file.

The first program the book provides is a variation on the “Hello World” program.  The example given in Wikipedia’s entry for C++ is as follows:

#include <iostream>

int main()
   std::cout << "Hello, world!n";

Looks simple enough.  Not quite sure what all of the alphabet soup means yet, but at least it’s short.

I paste it into the source code window, save the project as “hello_world”, then go to Execute -> Compile (or hit CTRL+F9).  A “Compile Progress” window is displayed, which doesn’t tell me a whole lot, other than the status is “Done.”  Allrighty then.

So I go to the the folder where I saved the project file, open the command prompt, and type “dir” (ah, DOS, how I don’t really miss you).

I see the .cpp project file at a svelte 96 bytes, as well as the hello_world.exe file, coming in at a whopping 464 KB.  I suppose that contains all of the libraries and other infrastructure necessary to actually run the program.

I type in “hello_world”, hit Enter, and bingo-bango:

Sweet.  Google, you got a job for me yet?

Now what?

As I mentioned in the introductory post for this blog, I’m really not sure what direction I should go.  There seem to be several options:

  • I’ve had Python suggested as a good beginner’s language.
  • Visual Basic seems logical given my past history with BASIC (though it is apparently quite different from the 8-bit 80’s era language I grew up with).
  • JavaScript would be good as it’s something I could put into immediate use at my full-time job.  Though it’s more of a scripting language, as the name would suggest.
  • Objective-C might make sense, as I’m interested in developing mobile apps, and I currently own an iPhone.  Most iPhone apps make heavy use of Objective C.

I’ve decided (at least for the moment) to start with C++, for a number of reasons:

  • It is one of the most popular programming languages created.  I’d wager that the majority of commercial applications created over the past 10-20 years have been done in C++
  • From what I have gathered, it is not tolerant of sloppy coding techniques.
  • It is hard to learn.  I realize this sounds backwards for a beginner’s blog, but I figure if you can get a handle on one of the harder languages, the easier ones will be that much simpler.

I will probably jump around between different languages as my whims dictate, but for the moment I’m going with C++.

Beginning C++ Through Game Programming

So now that a language has been determined, the next step is to determine how to actually learn the language.

Late last year, I purchased Beginning C++ Through Game Programming, Second Edition* by Mike Dawson. He teaches at UCLA, and was the co-designer of Dark Seed, an early 90s horror/adventure game.

I’ve always been interested in writing my own games, and learning programming via writing simple games seems like a logical way to go about it.  From a cursory scanning of the book, it seems that the example games are all text-based – which is fine with me.

I will attempt to work through the book and update the blog on my progress, without simply duplicating the content of the book.  Not sure how I will accomplish that yet, but I suppose we shall see!

(*Apparently there is a revised edition coming soon, Beginning C++ Through Game Programming, Third Edition.)