I've uploaded three versions of the missing source code from floppies, along with windows.h for each.<p><a href="http://ozz.ie/h31100" rel="nofollow">http://ozz.ie/h31100</a>
The same program for GNU/Linux/XLib is not much less complicated: <a href="http://www.paulgriffiths.net/program/c/srcs/helloxsrc.html" rel="nofollow">http://www.paulgriffiths.net/program/c/srcs/helloxsrc.html</a><p>Under Windows it is easy to create a console application, which is similar to the usual C helloworld. But the application here creates a windows to show hello world - so it's fair to compare it with a similar program on GNU/Linux/Xlib.<p>EDIT: Yes, it is much easier to use something as Qt on GNU/Linux, but there are also abstractions around the WinAPI available, so using Qt on GNU/Linux for a helloworld example yields no fair comparison.
A story. As Petzold writes, the Windows version of "hello world" was amazingly baroque. It bothered me, a lot. I had come up in the four line hello.c world of UNIX, and later the make/test world of UNIX, and when I had left Sun the idea of writing code like the Hello World example was something I could not bring myself to do. I rebelled in a bunch of different ways, but the worst part was it started a period for me where I programmed a lot less, I was getting curmudgeonly because programming had become so screwed up.<p>The thing that changed for me was getting a chance to help a young man with his programming who had come up through Windows rather than something easier, and he was full of all the wonder and excitement I had had at his age for programming, and had no idea that he was running with a large handicap to his productivity. And partly because many of the "tools" you had to have like Visual Studio worked their butt off to make that gap small, from self writing code to documentation at your fingertips. I realized that if I didn't get the 'wonder' back of writing code I was going to become one of those guys who sits around grumbling about how in my day things were so much better and FORTRAN just worked dammit :-).<p>What I tried to learn from it was that systems with great generality suffered from usability efficiency. The reason UNIX hello.c was so simple is that UNIX programs, by and large, did simple things, algorithmic computation driven by interaction over a character based interface. One way to drive effecive use of a system was to either eliminate or otherwise hide the modalities that were "possible" but not probable in future execution of the program.<p>That has helped me see when I'm building something that is letting to much generality leak out to the surface.
Certainly there is advantage in having a simple hello-world program. The original purpose of hello-world, naturally, is just to have something to verify that your environment and tools are properly installed and configured before you go off and do anything serious.<p>But because Petzold used "his" hello-world program to introduce you to a bunch of critical, foundational concepts -- to show you everything you needed in order to get a functioning top-level application window open on the desktop -- I myself found it a great place to start. By forcing you to confront the message loop from square one, it really reinforced the idea that you aren't in Kansas anymore (and you can't do things like the Kansans do).<p>As Petzold hints in his article, the original version of the book (for Windows 2.x) didn't even start with that program, but worked its way up to hello-world through a sequence of 5-10 iterations that got you to that point over the course of an entire chapter. (Thus for example one iteration actually opened a top-level window but lacked a message loop, so the program exited and the window immediately disappeared after it was created.) It makes sense that he had to edit out such a lackadaisical introductory chapter as the subject of Windows programming got bigger and bigger, but I for one always liked that chapter.
Brings back horrid memories of learning Windows programming back in the mid nineties. From the very first line of code, Microsoft had you doing it their (nonstandard) way, making you use WinMain() instead of main(). That style, too... Yuck! Even today, I can somewhat reliably identify folks who were raised on the Windows SDK by looking for lpszHungarianNotation and UNREADABLEALLCAPSTYPEDEFS.<p>Does anyone remember why the original samples allocated structures on the heap, did stuff with them, then immediately freed them, rather than just using them on the stack directly? Was that a thing? Were early Windows systems stack constrained or something?
Brings back memories. I recall learning to write from memory the 40+ line win32 hello world from the Petzold bible. That's the way it was back then ... but you got super speed from it. Event loop was blazing fast. I discovered MFC a bit later and worked as a professional dev at an ISV that made use of it. I have fond memories of reading the v1 MFC manual - it was small enough at that time so that a person could understand the whole thing with relative ease.<p>Some interesting notes on what happened in a few years .. when I first saw .net Compact Framework, it blew my mind how easy it was to write .net code/WinForms stuff. Even though I was relatively poor, I bought an MSDN subscription on the spot and started to write mobile apps. This was early 2000s. If MSFT had paid proper attention to mobile devices, they could have rocked it.<p>I faced weird challenges. Companies would ask me for 20K to certify my free apps on their phones. It was disgusting. I sold a few apps on the hangango app store, and then got out of mobile dev (missed the whole iPhone revolution). Talk about bad timing.
For those of us watching from the Unix world while Microsoft fumbled its way towards world domination, it was an incredibly frustrating time to see the banality of their technology become 'the thing' in light of so many, many, forgotten and ignored mysteries. It was something like what it might be like to see a new religion form for your children while watching that of your parents die.<p>Thank Linus we still have an alternative to Microsoft, here and now! It is absolutely a huge gain for us that Unix was not eradicated by the feral, vermin new thing.
Wow. Interpreting this under the "hello world is often a demonstration of a particular point" rubric ( <a href="http://www.win-vector.com/blog/2008/02/hello-world-an-instance-rhetoric-in-computer-science/" rel="nofollow">http://www.win-vector.com/blog/2008/02/hello-world-an-instan...</a> ) it looks like Petzoid was trying to demonstrate that a mere finite amount of code could launch a Window API client. Large was, of course, undesirable- but he was trying to see if the API costs were even bounded.
I really miss the "old days" of programming. Things were simpler then. I fondly remember the early 80s programming on a Commodore 64, then moving to the early IBM machines and DOS.<p>Even though I favour a <i>nix environment, there is more sanity in Windows programming circles methinks. I have been thinking about getting into some .NET development these days and moving away from doing </i>nix stuff, altho I really love the BSDs.
And then MS came up with MFC which was slightly better. But only slightly.<p>Borland had a better solution if I remember, in their C++ Builder thing.<p>Another "adventure" I had in Win32, trying to make a dynamic dialog box (basically, selecting something in a list opened up a list of properties - like the Preferences dialog box in most browsers). It was some time before I figured out how to do it (there was a coordinate conversion needed)
I couldn't even imagine the breath of fresh air it must have been to have worked with Windows programming in the 80's and then discovered something like NeXTSTEP.
> That version probably has as much relevance to real-life Windows programming as printf("hello world") has to real-life character-mode C programming.<p>A simple program has a lot of advantages, it shows you can actually compile and run a program. When you have never done so before, there are 100s of hurdles that regular developers would not even consider when starting out.
I remember back in the day being annoyed and frustrated that the two functions in the canonical Petzold "Hello World" were WinMain() and WndProc(). "Why not WinMain() and WinProc() ?" I used to silently scream. I must be getting more mature because I am not quite so pedantic about these sorts of things these days.
I had that book (<i>Programming Windows</i>) as a preteen. This is actually Win16 API programming--the event loop gives it away. This was before Windows had preemptive multitasking (which came with Win95, IIRC). If you forgot to yield at the bottom of the loop you'd lock up the whole OS.<p>Fun times.
As a unix/c coder in the early to mid 90's, the future seemed to be Windows and I dreaded having to learn that gobbledegook. Then Java came along and I never had to. Thank goodness.