Day 10, Programming

April 15, 2007

Let’s get this out in the open first and foremost; coding in Windows Vista is like eating glass. There are no other words to describe it.

Some of you may have tried coding in Windows before, I hadn’t. I wish I never did. First off, I made the mistake of downloading an IDE. For those of you who do not know what this is, it is an all-in-one application for writing, and compiling code. I never, ever use one for coding in anything except Cocoa (Xcode) in OS X. Emacs is more than enough for any coder with little or a lot of experience. But, I only installed the appropriate Cygwin (UNIX shell emulator) for using irssi. So I downloaded and installed Bloodshed’s Dev-C++ IDE. Looked up some Windows GUI API cheat sheets, and I was on my way.

The syntax for coding a GUI in Windows is truly revolting. But, alas I continued to write Hello World! I couldn’t believe I just typed ‘#include <windows.h>’. I feel so unclean…

After typing out loads of frankly unnecessary code, I tapped F9 (compile) and was greeted by a lovely error message. Path trouble. Dev-C++ couldn’t find gcc. I was on the brink of giving up when I decided to install all of Cygwin’s packages. Which, thankfully, included gcc. After the lengthy download process (roughly an hour on a very slow broadband connection) I successfully compiled my first Windows program:

Click for bigger image

As you can see, there is rather a lot of unnecessary code there. Here is an easily copiable version:

#include

int WINAPI WinMain(HINSTANCE hInst,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow){
MessageBox (NULL, "Hello World!",
"Hello World!", MB_OK);

return 0;
}

Another thing that deserves critique, is the obscene amount of capital letters in the functions and global variables. It all seems very .NET

Leave a Reply