TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

The Infamous Windows “Hello World” Program

134 pointsby johndcookover 10 years ago

19 comments

rozzieover 10 years ago
I&#x27;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:&#x2F;&#x2F;ozz.ie&#x2F;h31100</a>
评论 #8724316 未加载
评论 #8728409 未加载
评论 #8727211 未加载
wolfgkeover 10 years ago
The same program for GNU&#x2F;Linux&#x2F;XLib is not much less complicated: <a href="http://www.paulgriffiths.net/program/c/srcs/helloxsrc.html" rel="nofollow">http:&#x2F;&#x2F;www.paulgriffiths.net&#x2F;program&#x2F;c&#x2F;srcs&#x2F;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&#x27;s fair to compare it with a similar program on GNU&#x2F;Linux&#x2F;Xlib.<p>EDIT: Yes, it is much easier to use something as Qt on GNU&#x2F;Linux, but there are also abstractions around the WinAPI available, so using Qt on GNU&#x2F;Linux for a helloworld example yields no fair comparison.
评论 #8728527 未加载
评论 #8727931 未加载
评论 #8725857 未加载
ChuckMcMover 10 years ago
A story. As Petzold writes, the Windows version of &quot;hello world&quot; 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&#x2F;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 &quot;tools&quot; 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&#x27;t get the &#x27;wonder&#x27; 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 &quot;possible&quot; but not probable in future execution of the program.<p>That has helped me see when I&#x27;m building something that is letting to much generality leak out to the surface.
评论 #8724132 未加载
breadboxover 10 years ago
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 &quot;his&quot; 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&#x27;t in Kansas anymore (and you can&#x27;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&#x27;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.
ryandrakeover 10 years ago
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?
评论 #8723993 未加载
评论 #8724970 未加载
评论 #8723844 未加载
评论 #8725343 未加载
评论 #8724755 未加载
评论 #8724566 未加载
turnip1979over 10 years ago
Brings back memories. I recall learning to write from memory the 40+ line win32 hello world from the Petzold bible. That&#x27;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&#x2F;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.
评论 #8725151 未加载
fit2ruleover 10 years ago
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 &#x27;the thing&#x27; 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.
评论 #8724207 未加载
评论 #8724210 未加载
评论 #8723977 未加载
评论 #8726940 未加载
jmountover 10 years ago
Wow. Interpreting this under the &quot;hello world is often a demonstration of a particular point&quot; rubric ( <a href="http://www.win-vector.com/blog/2008/02/hello-world-an-instance-rhetoric-in-computer-science/" rel="nofollow">http:&#x2F;&#x2F;www.win-vector.com&#x2F;blog&#x2F;2008&#x2F;02&#x2F;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.
forcaover 10 years ago
I really miss the &quot;old days&quot; 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.
评论 #8725820 未加载
raverbashingover 10 years ago
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 &quot;adventure&quot; 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)
评论 #8723656 未加载
评论 #8724148 未加载
CurtHagenlocherover 10 years ago
From what I remember, the equivalent code in something like Toolbox or Xt wasn&#x27;t better or easier -- just different.
评论 #8728044 未加载
评论 #8724082 未加载
bluedinoover 10 years ago
I couldn&#x27;t even imagine the breath of fresh air it must have been to have worked with Windows programming in the 80&#x27;s and then discovered something like NeXTSTEP.
评论 #8724589 未加载
评论 #8724413 未加载
评论 #8723858 未加载
atburrowover 10 years ago
Does anyone have a mirror? The link appears to be dead.
评论 #8724038 未加载
评论 #8723808 未加载
megablastover 10 years ago
&gt; That version probably has as much relevance to real-life Windows programming as printf(&quot;hello world&quot;) 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.
billforsternzover 10 years ago
I remember back in the day being annoyed and frustrated that the two functions in the canonical Petzold &quot;Hello World&quot; were WinMain() and WndProc(). &quot;Why not WinMain() and WinProc() ?&quot; 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.
aurora72over 10 years ago
With the Win32 API, we saw some innovative use of C in action, such as the function pointers and the callback functions.
评论 #8727472 未加载
评论 #8728659 未加载
评论 #8726756 未加载
bkeroackover 10 years ago
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&#x27;d lock up the whole OS.<p>Fun times.
nevsterover 10 years ago
As a unix&#x2F;c coder in the early to mid 90&#x27;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.
评论 #8727458 未加载
weddprosover 10 years ago
It says &quot;Service Unavailable&quot;... Fun!