back to article Influential scribe Charles Petzold: How I figured out the Windows API

Charles Petzold’s book Programming Windows (in various editions) was how a generation of developers learned to code for Windows – 25 years ago when Microsoft’s operating system was the hot new thing. Charles Petzold Petzold now works for Xamarin, and I caught up with him at the company's Evolve conference in Atlanta last …

  1. Admiral Grace Hopper
    Thumb Up

    Thank you Mr. Petzold

    You made writing code for Windows much less painful than it could have been.

    1. Evil Auditor Silver badge
      Thumb Up

      Re: Thank you Mr. Petzold

      I totally agree with you! Problem is, I don't remember which of his books I used. But it's funny, after all those years in which I haven't touched any Windows programming, to finally see a person behind this then omnipresent name Petzold.

  2. CadentOrange

    I cut my teeth on programming in Win32 by reading Charles Petzold's book about 15 years ago. He made the Win32 API make sense to me, though I'm worried about Xamarin forms given that he's working at Xamarin and probably has some input on its design.

    Do I really want someone who has spent the last 25 years on the Win32 API anywhere near the design of a new API? Even if he is Charles Petzold?

    1. dogged

      His rates do go some way toward explaining their insane prices.

  3. Julian Bond

    The only guy I ever met with the Windows Logo tattooed on his shoulder.

  4. Anonymous Coward
    Anonymous Coward

    Borland's OWL was a much sensible approach than MFC

    Problem was that people took the examples from Petzold's book and extended them, which led to the 14-page switch statement programs that everyone has seen once and run away from them as fast as he/she could.

    OWL was a bit worse than Delphi's framework (don't remember the name right now) but both made C++/Pascal programmers way, way more productive than raw Win32 or MFC programmers. But the MS borg crushed Borland (with a little help from Borland itself) so what remained was the VHS of Windows frameworks.

    Now that Windows is the niche and the number of developers on Objective-C or Android is vastly superior to the number of Windows developers perhaps Microsoft feels some incentive to make Windows development a bit better. Such as, oh god, making it cross platform?

    1. sawatts
      Thumb Up

      Re: Borland's OWL was a much sensible approach than MFC

      Thumbs up for remembering OWL!

      I evaluated both OWL and MFC at the time, and OWL was clearly designed by someone who understood OOD, while MFC didn't seem to grasp the concept.

      1. AndyDent

        Re: Borland's OWL was a much sensible approach than MFC

        The funny thing is that most of the non-OO stuff in MFC was layered on by macros. Under the hood was a reasonably clean OO design. I took advantage of that with my PP2MFC product which mapped the lovely PowerPlant framework from Metrowerks to MFC, so you could cross-compile Mac GUI code.

        The history of MFC is that it was supposed to be a much more OO design, informed by Apple's MacApp, but the "Advanced Framework" was deemed too hard for Win32 C programmers so was dumbed down. Hence the "AFX" prefix on many identifiers which lingers on like the NS prefix in Apple lingers as a reminder of NextStep.

      2. dajames

        Re: Borland's OWL was a much sensible approach than MFC

        I evaluated both OWL and MFC at the time, and OWL was clearly designed by someone who understood OOD, while MFC didn't seem to grasp the concept.

        What you're missing is that MFC wasn't trying to grasp that concept.

        MFC was not so much an attempt to build a good OO framework for C++ as a pragmatic approach to providing a framework that could straddle the gap between 16-bit Windows (and Microsoft's 16-bit C++ compiler that no support for exceptions or templates) and Win 32 (and their new 32-bit compilers that at least paid lip-service to some newer language features).

        It wasn't lovely, but it was effective.

    2. g00se
      Joke

      Re: Borland's OWL was a much sensible approach than MFC

      OWL was a bit worse than Delphi's framework (don't remember the name right now)

      That would be the Visual Component Library (VCL) perhaps?

      It it just me or is the general tone of this article (despite details stated to the contrary) along the lines of "Meet Charles Petzold - the man who reverse-engineered the Windows API"?

      Or even ...

      Windows 1.0 had tiled windows and I had a paragraph in my first chapter explaining why tiled windows were better than overlapping windows.

      "Charles Petzold vindicates Windows 8"

    3. JDX Gold badge
      Flame

      Re: Now that Windows is the niche

      Nice try.

      1. Anonymous Coward
        Anonymous Coward

        Re: Now that Windows is the niche

        Face it, Windows is no longer the dominant OS on machines connected to the Internet. Explorer is no longer the browser leader outside desktops and laptops, and even there is leading by a tiny margin.

        The previous mindset that made developers stick with Windows technologies assuming that they could spend their professional lifetime with them no longer holds true. You have to look outside if you want to remain relevant.

        1. RyokuMas
          Trollface

          Re: Now that Windows is the niche

          "The previous mindset that made developers stick with Windows technologies assuming that they could spend their professional lifetime with them no longer holds true. You have to look outside if you want to remain relevant."

          Yeah, you can now spend an entire career trying to get a single Android app working on every combination of device hardware and OS variants... and still not get done before it's time to retire!

        2. JDX Gold badge

          Re: Face it, Windows is no longer the dominant OS on machines connected to the Internet

          Of course it is.

          Change "machines" for "devices" and you might be right although it would be interesting to see stats for total number of pages loaded across desktop & mobile OS, not number of unique devices, to measure where the bulk of usage is coming from.

          1. Anonymous Coward
            Anonymous Coward

            Re: Face it, Windows is no longer the dominant OS on machines connected to the Internet

            "Of course it is.

            Change "machines" for "devices"

            If "machines" means desktops and laptops to you, then you're likely right. However my point was about what you call "devices" (perhaps I'm not up to industry standards, for me a "machine" and a "device" are the same)

            As for number of pages, I'd say that metric is becoming irrelevant. Mobile apps don't "load pages" from a browser in the conventional sense, they may have a browser component embedded that does so, but the most popular apps (FB, YouTube, etc) have their native front end communicating over http, but no notion of "browser" is in the middle. And they are usually generating way more traffic than desktop/laptop browsers.

    4. 9Rune5

      Re: Borland's OWL was a much sensible approach than MFC

      I used to be an avid Delphi user (and quite proficient with the VCL).

      Today I'm mainly using C# and this morning I again found myself shaking my head in dismay as I tried sorting out taborder on a winforms form. In Delphi, setting the TabOrder property would automatically renumber TabOrder on other controls. Which makes sense, because what good would it do anyone to have two (or more...) controls on the same form with the same TabOrder? In Delphi it is simple to go back to a five year old form, insert an edit field in the middle of the form and get the TabOrder in order (pardon the pun). Using Visual Studio's Winforms editor OTOH is a chore. Even Delphi 1.0 (from 1995) beats VS hands down in this regard.

      We are making the move to WPF. It has become my favorite way of making GUIs, but its steep learning curve is naturally easily beat by Delphi. However, the possibilities that WPF offer makes it worth it. At least I hope that will be the case. I18n is one of the trickier aspects of WPF in my opinion. I feel somebody dropped the ball there.

      But Winforms? It should have been put out of its misery a long time ago.

    5. jpb421

      Re: Borland's OWL was a much sensible approach than MFC

      The one thing I remember about OWL is Borland changed everything between a particular pair of versions (was it 1.0 to 2.0?) They basically told developers to rewrite all their code and provided tools that did a rather bad job of automatically converting it.

      In my book, if you're providing API you should keep the interface to it backwardly compatible - we felt betrayed by Borland and our small company shifted to plain Windows with MFC after that since we were going to have to rewrite our code anyway. Prior to that we'd used Borland from the days of Turbo C.

  5. dogged

    "Windows Programming Foundation"

    wat

    1. Anonymous Coward
      Coffee/keyboard

      Re: "Windows Programming Foundation"

      Whatever. I call it quicksand.

  6. hammarbtyp

    Good for windows, bad for programming

    I remember learning to program windows using Petzold book as a young programmer just cutting their teeth on coding.

    Looking back now, I do think that Petzold taught a lot of early windows programmers some really bad habits such as the use of naked global variables to store things like handles and we ended up with a lot of really bad, unstructured, difficult to maintain code.

    Unfortunately at the time I didn't know any better

    1. dogged

      Re: Good for windows, bad for programming

      Those guys all write JavaScript now, to judge from the code I keep seeing.

  7. amanfromarse

    Hungarian notation

    No mention of the monster that would not die?

    1. Tim Anderson

      Re: Hungarian notation

      There was, but couldn't fit it in. Just for you though: "there was a style of identifying variables known as Hungarian notation that I imitated and perhaps propagated more than was desirable (laughs)." Almost a confession :-)

      1. PleebSmash

        Re: Hungarian notation

        Shouldn't you be sporting a shiny vulture badge?

  8. Mint Sauce
    Windows

    I still have...

    ...my copy of Programming Windows 3.1. The knowledge of how the internals of windows worked came in useful for many years afterwards even as things moved on to proper multi tasking, and wrappers, APIs and frameworks came to hide some of the more laborious parts of the code we had to write.

    The Hungarian Notation comment above made me szChuckle too :-)

    I still slip in to using it sometimes and people wonder why the variable names have all 'that crap' in front of them [myself included] ;-)

    1. captain veg Silver badge

      Re: I still have...

      That book was single handedly responsible for my switching from C to VB in my day job!

      -A.

  9. Tom 7

    If Oracle get their way over copyrighting API's and backdated it

    MS would have died long ago.

    The only people who would be able to program the API would have been malware writers.

    1. Mage Silver badge

      Re: If Oracle get their way over copyrighting API's and backdated it

      Yes, the MS ones for DOS pinched from CP/M Digital Research!

  10. Ian 55

    "I will need more than the $15,000 advance that you normally get for a book"

    I need to speak to my agent.

    US royalty rates are appallingly low, and he gets this as an advance?

  11. Ian 55

    "a paragraph in my first chapter explaining why tiled windows were better"

    Apart from 'Microsoft don't know how to do the overlapping ones they promised two years earlier when Windows was announced", I wonder what those reasons were.

    1. Lee Mulcahy

      Re: "a paragraph in my first chapter explaining why tiled windows were better"

      Windows 1 was non-tiled because of worry about infringing the Macintosh's overlapping Windows. I think there was a legal agreement there somewhere. Don't know how they got out of it for Windows 2

    2. captain veg Silver badge

      Re: "a paragraph in my first chapter explaining why tiled windows were better"

      > Apart from 'Microsoft don't know how to do the overlapping ones they promised two years earlier

      They could and did do overlapping windows in Windows 1. That's what a drop-down menu is. What they chose not to do was overlapping top-level app windows, partly for fear of litigation from Cupertino and partly because they genuinely thought, backed by observation of novice user behaviour, that it was less confusing.

      This belief later gave us the Metro UI. Someone hammer a stake through it, please.

      -A.

  12. Notas Badoff

    Was it him?

    Long ago in another age, MS stabbed IBM in the back and dropped OS2. A very prominent author got so irate at MS deep-sixing a finally rational API set, he swore he'd **never** write another book for Microsoft's APIs. Was that Petzold? Because strangely I have not in the last several years been able to track down exactly who that was... I sure though it was him, but can't find *any* mention. Very strange, as it was a big deal at the time.

    1. Stevie

      Re: Was it him?

      And here I thought OS/2 died because it was tied into the proprietary microchannel architecture that IBM refused to license and ultimately dropped as a Waste Of Time.

      IBM are good at Aiming At The Wrong Target. From the Wikipedia page on OS/2

      "At the launch of OS/2 Warp in 1994, Patrick Stewart was to be the Master of Ceremonies; however Kate Mulgrew of the then-upcoming series Star Trek: Voyager was substituted at the last minute"

      So instead of the "captain" who rebooted the Star Trek franchise with nitromethane, they picked the one to whose show's theme you could sing:

      "Boring song, it's a boring song,

      A boring song,

      A boring song,

      What a boring song

      Boring song, it's a boring song,

      A boring song,

      And *what* a boring show."

      Consider:

      ST:TNG - people exploring out beyond the limits, ever outward and upward.

      ST:V - people running for home and the familiar as fast as possible.

      Which metaphor do you want nailed to your product?

      I had a colleague who lost a hard-won and prestigious CIO position when his support of OS/2 outpaced IBM's.

  13. Kev99 Silver badge

    I'd love to have someone come up with a Windows add-on or install helper that would watch which of the hundreds of thousands of files are actually needed for an install and keep the rest out.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

Other stories you might like