Code – Charles Petzold

Anyone interested in learning more about computers might enjoy ‘Code’ by Charles Petzold. I’ve just finished it, and found it very readable.

It sets out to be a beginners guide to how computers work, but without all the cute analogies and pictures of 1’s and 0’s in pidgeon holes that seem to crop up in other texts like this.

It probably helps that I first encountered the author as my introduction to programming Windows. As I type this I’m unsure if I ever read all of his classic ‘Programming Windows’ (I was a student when I needed to, and probably borrowed it), but I certainly read large chunks. It has a clear, no-nonsense, style I enjoyed.

All you really need to understand to follow Code is how a relay works, and he explains that from first principles. He then works up to laying them out by the thousand to produce a computer recognisable today. One interesting observation is that much of the technology needed to create a computer was around a hundred years old before someone assembled one we would recognise. There’s a different path the world might have taken, if that had happened earlier!

1 thought on “Code – Charles Petzold

  1. Ailin Jasel

    Ola! John, This question may be a little off-topic, I am learning winapi programming from Charles Petzold’s Programming Windows fifth edition. I am using this code from his book whilst attempting to build a dll, but the dll header is giving an error.

    By the way, the book was written for C, however I am programming in C++.

    Here is the problematic portion of the code:

    //The callback function type definition uses generic strings typedef (CALLBACK * GETSTRCB)(PCTSTR, PVOID);

    //Each function has Unicode and ANSI versions EXPORT BOOL CALLBACK AddStringA(PCSTR); EXPORT BOOL CALLBACK AddStringW(PCWSTR);

    EXPORT BOOL CALLBACK DeleteStringA(PCSTR); EXPORT BOOL CALLBACK DeleteStringW(PCWSTR);

    EXPORT int CALLBACK GetStringsA(GETSTRCB, PVOID); EXPORT int CALLBACK GetStringsW(GETSTRCB, PVOID);

    And here are the errors: ISO C++ forbids declaration of GETSTRCB' with no type [Warning]stdcall‘ attribute only applies to function types typedef GETSTRCB' is initialized (use __typeof__ instead)PCTSTR’ was not declared in this scope expected primary-expression before ‘)’ token

    Thanks in advance for your help

    BC Thx.

Leave a Reply

Your email address will not be published. Required fields are marked *