I am the host of a weekly Internet audio talk show for .NET developers called .NET Rocks!

Each week my co-host, Rory Blyth, and I interview the movers and shakers in the .NET community. It's a free download, and there are about 80 shows in the archives as of this writing. We've interviewed the likes of Alan Cooper, Scott Guthrie, Don Box, Kimberly Tripp, Chris Sells, and many other well-known persons in the community. Our show is not boring! We have fun! We give away prizes, look at strange Web sites, talk about what went on in .NET land during the week, and otherwise have a good time. Heard on .NET Rocks! is a regular feature of CoDe Magazine in which I highlight some of the conversations we've had recently.

This excerpt is from a recent interview with the one and only Charles Petzold, author of many books including Programming Windows with C#, Programming in the Key of C# (for beginners) and our favorite, CODE. The Hidden Language of Computer Hardware and Software. He was one of the first authors for Windows with his landmark book, Programming Windows, which taught the world how to write Windows applications. This book is now in its fifth edition.

Rory: Charles, I've been dying to ask you this ever since I read your book, CODE. The question is, "Now that you've given us CODE, do you have any plans to come back and give us another book that's going to take us through another similar knowledge domain in such a fascinating and well-written way?"

Petzold: I have been tossing around a few ideas, more centered on the very early history, or even pre-history, of computers, which brings us back to the 19th century. For a little while I was interested in the differential analyzer, which is an analog computer. A lot of people don't know there were analog computers before there were digital computers. What it did was solve differential equations.

Carl: And what year was this?

Petzold: It was 1925. Vannevar Bush. Bush was in charge of coordinating all the science activities during World War II including the Manhattan Project. In the 50s he wrote a famous article that seemed to preface hotlinks, or linked information. But in 1925 he was a professor of engineering at MIT and they needed to solve a bunch of differential equations and they decided to build a machine to do it. Differential equations involve derivatives, and integrals and calculus stuff. Now, if you do differential equations on a digital computer you know how you do it? You buy Mathematica for thousands of dollars and you use analytical methods to solve these equations. But he constructed hardware to do integrations and hook them together to solve differential equations. There is actually a short film clip of this machine in operation in the movie When Worlds Collide, [in which] they see some kind of comet heading towards earth and they want to find out if it's going to hit the earth. So they put it into the differential analyzer.

Carl: And they actually used it in the movie...

Petzold: Yeah, they show a small clip of it. It's the most insane thing you've ever seen. It's on a tabletop and there's all these discs and stuff that are rotating and making a big racket. And the output, because it's an analog computer, the output is a graph. It draws a graph on a paper.

Carl: How does it work? What is it made out of?

Petzold: It's made out wheels and axels and stuff. If you have a wheel like a turntable that's spinning around and another wheel that's sitting on top of that upright, and depending upon how far from the center of the horizontal wheel the upright wheel will revolve at a different rate.

Carl: Hey Geoff Maciolek, our sound guy, just gave me a link to a Web site (www.shrinkster.com/jc) that shows Tim Robinson's Differential Analyzer, which he made out of Meccano (like a European Erector set). Wow!

Petzold: But the thing is that all these analog computers were special purpose. You know, it's considered a special-purpose computer if all you can do is solve differential equations. But for a physicist or an engineer, solving differential equations is really important. So, it was an important machine. They used other analog computers to solve bomb trajectories and stuff during World War II.

Carl: When Rory asked you that question about doing a sequel [to CODE]... I sort of like the last chapter of CODE where you give these one-paragraph and two-paragraph descriptions of all these digital technologies that you're interested in including MIDI and HTML and other things. So, I didn't know that you were into electronic music, and you know I learned a lot about computer science by programming MIDI at a kind of a low-level too.

Petzold: I got into electronic music way before MIDI. I can trace my interest in computers to the release of Switched-On Bach in 1968. I was 15 years old.

Carl: Charles?

Petzold: Yes?

Carl: I was one.

Petzold:<laughs>.

Rory: I was a naughty feeling in my father's loins at the time

Petzold: So, because of this album, well, I got interested in classical music first of all, and I still am. But I [also] got interested in electronic music. When I was in college, I came into a little bit of money, about $3000. I went out and bought a small synthesizer and a TEAC 4-channel tape deck that could do the synchronized recording.

Carl: Wow! That must have been pretty expensive at that time.

Petzold: The synthesizer was 1500 and the tape deck was 1200. This was in 1974. It was a lot of money back then, but I really wanted to do my own Switched-On Bach. So, I did that for a while and then a few years later I had an electronic piano made by Univox, I think. It was only like 500 dollars. But, the little keys were like little contact switches and each key had a little spring on it. And after banging on this piano for a while the contacts started eroding. So you'd press a key and it wouldn't work anymore. You know, you go inside with a little file and file it off and it would work for a while and then it would stop working. And I thought, you know, what I really need is a sequencer!

Carl: This must have been way before sequencers.

Petzold: Well, not WAY before sequencers. This was approaching the late seventies.

Carl: So they were using Voltage Control to do MIDI-style stuff back then right?

Petzold: Yeah the synthesizer was all Voltage Control. But with this electronic piano I had, each key had a separate circuit which just independently turned off and on when you pressed the switch. But what I conceived [of] was putting together a big array of little slide switches. Horizontally they would stand the five octaves of the keyboard. Vertically there would be 16 of them. So I found a place where I could buy slide switches in bulk for 10 cents a piece. I don't know how much that would be, 61 times 16 times 10...whatever that works out to be.

Carl: Yeah, math isn't your strong suit ;-)

Rory and Charles:<laughing>

Petzold: So, I could program up a sequence just by throwing these switches and loop around 16 notes. And there would be a switch on for each of the notes, and that's how the sequencer would work with this big array of switches. But I didn't know how to do that. I didn't know how to sweep through these 16 rows electronically. So I started researching this, and research was hard because, you know, we didn't have the Internet at that time. You actually had to go to book stores and go through all the books. But I found a book by Don Lancaster called the CMOS Cookbook which told you how to use CMOS chips to do exactly what I needed to do. And that began me learning about chips.

Carl: So if it wasn't for music, you wouldn't have been inspired to be the Charles Petzold we know and love.

Petzold: This is absolutely true.

Carl: That's awesome. I also read in that same last chapter that Sony and Phillips developed the compact disc to hold 74 minutes of music so that Beethoven's 9th Symphony would fit on it.

Petzold: Yeah, this may be an apocryphal story, but yeah it was some executive. Originally they came up with a CD spec of 60 minutes, which seems like, you know, a nice round number. And an executive at Sony said no, we must fit Von Karajan's performance of Beethoven's 9th symphony on one CD.

Carl: Wow. That's great.

Petzold: And that story could be total bullshit. I don't know.

Carl: Tell me what it was like back in the early days. You were there at Windows 1.0. What was the atmosphere like for you as a writer? Was anybody thinking about writing about this stuff?

Petzold: Not really. I first started seeing Windows about a year before it was released. Version 1.0 was released at Fall Comdex in 1985. I was spending a lot of time at PC Magazine doing writing and reviewing of hardware and stuff like that. And, periodically Steve Ballmer would come by the magazine with the latest beta version of Windows. And there was only one guy in the office who had EGA so we'd go run it on his machine, you know? <laughter> and we'd play with it until it crashed too much, and we'd get bored. And people who remember that era will recall that Windows was announced several years before and it just took so long for them to get it working right. And I had no idea how to begin to write programs for this thing. I asked one of the editors, "How do you code for this?" and he opened up his drawer and pulled out a big pile of paper and five diskettes and said, "Take this home." It was the Beta SDK on diskettes.

Carl: Oh man.

Petzold: And, I barely knew C at the time. So, I went home and installed this whole thing, and six months later I could write my first Windows program.

Carl and Rory: Six months?

Petzold:<laughing> Yeah. There was a tutorial. They had five programs. The first one was basically hello world. It had a menu, and an about box, and it was pages and pages long. So after I got it to work I said to myself, "Does the program really need a dialog box?" and I took that code out and the program still worked. Does the program need a menu? I took that out and the program still worked. <all laughing> Then I got it down to, you know, two pages. And I thought, you know, this stuff could be taught a lot better.