The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

A language rant that turns into a book question

I feel as if I should qualify this with some background. I work in a completely unrelated industry; I work for General Motors Advanced Design Center, building concept cars. From everything I read about the programming industry, I’d never want to do it professionally, unless it was in a “MicroISV” – one man shop – type of situation. If I had aspiration of programming professionally, this rant would apply doubly. None-the-less, I’m fascinated with programming. I guess my rant, as small as it is, is about the different types of languages. I know choice is good, and some languages are best suited for different problems, but it’s frustrating for the “newcomer” wanting to learn. I’ve found myself jumping from language to language trying to grasp it all, while feeling like I’m never getting anywhere. I know a lot of them share language similarities but it’s still frustrating. In my learning infancy, my focus was on web scripting languages, but I was never really satisfied. I’m drawn toward desktop applications, even though many claim it to be a dying industry. I happen to believe it’ll never fully move away from desktop. Anyway, to speed this up, I jumped from VB to C/C++ then quickly moving to C# and back to C++, but with MFC. How utterly frustrating it is. I know a lot of the frustration can be attributed to my inability to stick with one language but, as a layman, who can really lock onto one, when you have many sources telling you, “Language X is the one you want” or “Language X is what the industry is moving to”. It’s just frustrating. That’ll be all for my rant, sorry for the length

I’ve finally found a language to stick to, a choice made after tasting many languages and having the unique situation of not needing to learn anything specific, because of the industry. I actually like C++. I like object oriented programming. Now my new issue comes in that I’m on Windows and I hate MFC and all of these attempts to abstract me away from the Win32 API, that’s why I’ve read several books on Win32, including Charles Petzold’s “Programming Windows”. I like having the freedom to easily pass a different function pointer to a WNDCLASSEX structure and handle the messages myself. I absolutely need, on a personal level, to know what is happening. I can’t handle passing stuff to a wrapper class, knowing full well that it’s just calling a Win32 API call. I like the control of doing it myself. I’ve just figured out how to have a window procedure as a class member and still get a pointer to the instance of the calling class.

 Now I know there’s not a lot of difference between doing Win32 in C and doing it in C++ but, as in my “window procedure as a member function” above, there are some differences that need to be worked around. I would like more information on doing Win32 in a C++ environment. The more technically in-depth the information is the better. I’d like to extend this question to you professionals. Can you point me to some good references – in-depth technical books, preferably – on doing Win32 in C++?

I apologies for being wordy.
AverageMidget Send private email
Tuesday, October 30, 2007
 
 
C++ is a good language, you just need to read up on it and learn to avoid its many pitfalls.

IRT MFC, Kick Borland in the nuts for killing OWL.
Nate Send private email
Wednesday, October 31, 2007
 
 
Very good question. I have been looking for such a book for a long time too. Perhaps others might correct me but I dont know of any such books out there. What I know I have learned by looking at the implementation of ATL, WTL and MFC. They all come with source (well, you have to buy VC for ATl and MFC).
-S
Wednesday, October 31, 2007
 
 
The Win32 API is mostly C, not C++, so there's really no point in writing a book that covers Win32 programming in C++ specifically.  The API must be used on the C language level, and you are free to create whatever C++ program structure you want on top of that.  The big exception is COM which is basically impossible to use in C.  So you're going to need Petzold and some COM literature to do Windows programming in C++.

But it's really an enormous amount of effort, and C# is just so much easier to use...
Chris Nahr
Wednesday, October 31, 2007
 
 
I programmed in C directly with the Win32 API for many years and am far happier the further I can move away from working at such a low level. It might be interesting to learn and certainly gives you a good grounding, but if you actually want to produce a nice looking modern app you will be there forever.

There are some good libraries that work with MFC that provide a wide array of great looking controls and framework enhancements. Have a look at Prof-UIS http://www.profuis.com as one example. I use this in Surfulater.

WTL was a popular step away from MFC, but I don't think too many folks are using it now.

A great site you can while away may hours is http://www.codeproject.com You'll find a treasure chest of code there.

Finally I suggest you decide on an app you'd like to write, assuming you haven't already, and focus on developing that, taking the shortest possible route.

Have fun.
Neville Franks Send private email
Wednesday, October 31, 2007
 
 
Neville Franks Send private email
Wednesday, October 31, 2007
 
 
There's a million different languages because there's a million different ways of thinking or expressing.  When you think about it, the process of codifying pure thought in a fashion suitable for machine execution is kind of an awe-inspiring thing, a beautiful thing.  Each different language encodes within it some aspect of its creator and its creator's world-view, evolves over time to reflect its environment, and so forth.  I'm forever tinkering with different languages for the joy of discovery therein, just like I love screwing around with graphics code because there's something about writing code that makes a beautiful picture appear... Certainly these pursuits are rarely applicable to the practical (I pay the bills by writing Java for the finance industry), but that doesn't stop them from being fun. ;)

(Sorry, a tangent inspired by your rant.)
son of anon
Wednesday, October 31, 2007
 
 
"...The API must be used on the C language level..."

Not sure what is a meaning of this. Certainly, you can design a C++ class, which is a base for all other windows in the program. Using polymorphism to give every window its own procedure (e.g. behaviour).
asmguru62 Send private email
Wednesday, October 31, 2007
 
 
As others have said, Win32 is a C API, so nothing really changes when you call it from C++. This is why you don't see many books targeting Win32 and C++ specifically.

There is, as far as I understand it, only one really good book on Win32 programming (fortunately, it is a VERY good book): "Programming Windows" by Charles Petzold.

There is also a book on Windows system programming (non-GUI stuff) that is very well thought of: "Windows System Programming" by Johnson M. Hart.

I have both these books and recomend them, but there are other options that can be found by a simple Amazon search (I just searched for "Win32" and these two books came up as the first and third hits). Some other books that come up on Amazon for Win32 programming, that look good, are:

"Win32 Programming" by Brent E. Rector and Joseph M. Newcomer, a 2 volume set, which just sounds nice an authorotative.

"Nitty Gritty Windows Programming with C++" by Henning Hansen, which, incidentally, seems to fit your exact request.

As for the meta-problem in your rant, you do need to concentrate on a single language: either go with C#, since it's the "wave of the future!" or buckle down and learn both C and C++.

For C# you have all the advantages of Java with some of the advantages of regular compiled languages. It will be easier to do than C/C++ and you'll get nice desktop programs for your effort. You will also be able to transer the language to web programming with ASP.NET, if you are so inclined. There are also lots of good books available for C#, at the moment.

For C/C++ you really need to learn both langauges if you plan to do C++ (since C++ is an extension of C). You also need to learn all the pitfalls of C++. For this I recommend the following books:

"C, A Reference Manual" by Harbison and Steele

"Effective C++" by Scott Meyers

Then, once you have digested those two, you can follow up with two more books by Scott Meyers:

"More Effective C++" by Scott Meyers

"Effective STL" by Scott Meyers

Finally, you probably want the following books for reference:

"The C Programming Language" by Kernighan and Ritchie

"The C++ Standard Library: A Tutorial and Reference" by Nicolai M. Josuttis

"The C++ Programming Language" by Bjarne Stroustrup

That may sound like a lot of reading, but you should be up and running after just the first two, and you'll be a much better programming after the second two (the references are VERY nice to have on a continuing basis).
Jeffrey Dutky Send private email
Wednesday, October 31, 2007
 
 
Nate: "IRT MFC, Kick Borland in the nuts for killing OWL."

Ah, but they replaced it with Delphi's Visual Component Library (VCL), which is much better (and yes, I've used both). CodeGear C++ Builder uses the VCL, and there are thousands of third-party components available, many that are free with source code.
Ken White Send private email
Wednesday, October 31, 2007
 
 
Forgot to mention to the OP: Raymond Chen from Microsoft publishes a blog at http://blogs.msdn.com/oldnewthing - if you look through that site, Raymond has provided a really good C++ skeleton for Win32 apps, as well as posting some interesting uses for that skeleton.
Ken White Send private email
Wednesday, October 31, 2007
 
 
Out of curiosity: what exactly do you do in concept car building process? Is it computer related or do you get to use REALLY cool stuff like TIG welders and whatnot?
Jeffrey Dutky Send private email
Wednesday, October 31, 2007
 
 
I know that the Win32 API is C, and I'm able to do that just fine, but there are issues when done it in a C++ environment. As I said in my original post, when you have a custom Window callback procedure, and you want to have it as part of a class, you need to define it as static. In doing that, you need to have a "router" procedure that gets the instance of the class and forwards it to the static member function. For all I know, that's the only pitfall to doing Win32 in a C++ environment. My not knowing is why I asked.

As for the concept car stuff, I do it all, actually. My main responsibility is CAD/CAM; I CNC mill the clay cars and also the parts for the cars...the mirrors, headlights and taillights. I also do tig welding, and all other aspects of fabrication. I've got 20+ years of automotive fabrication, under my belt.
AverageMidget Send private email
Wednesday, October 31, 2007
 
 
To Ken White:

Thanks, I've actually read a few articles at that site, when it showed up in a specific google search but I might have to revisit it for more of a "start at the beginning" approach.
AverageMidget Send private email
Wednesday, October 31, 2007
 
 
There are a couple of solutions to the wndproc problem, if you dig around in the ATL code you will find a small piece of assembler code which dispatches the call to the correct class. This is an efficient solution but platform specific, have a look in atlstdthunk.h
Tony Edgecombe Send private email
Wednesday, October 31, 2007
 
 
Feel free to correct me if I'm wrong, but my opinion is that if you're a novice who deals mostly GUI-related operations then Java is really the thing for you.

Yes Java might not be ideal for every possible type of application out there but for *your* type of applications it sounds like the easiest, most widely used language around.

If you know C++ or C# picking up Java should be extremely easy (and in my opinion the APIs are a lot cleaner!)

Just my 2 cents :)
Gili Send private email
Wednesday, October 31, 2007
 
 
Your staring into your navel too much.

Pick a project and just do it. The journey is the best teacher.
You're not paranoid if ...
Thursday, November 01, 2007
 
 
I whole-heartedly agree that, if I was going to write software as a profession, .Net and Java would probably be the better path. I can definitely appreciate the productivity benefits and ease of coding that C# and other .Net languages offer - I don't know about Java. However, I really don't want that ease. Quite frankly, I have some mental issues and, when left idle, my brain doesn't react well. I like it hard - that sounds really bad. I've conditioned myself to obsess over detail, to preserve my sanity. That's why I fundamentally need to know every last detail of how Windows is working, while my code is executing. To shine a little light on how deep it goes, I'd actually like to learn Assembly, when I grow content with C++; talk about self-torture.

Thanks Tony Edgecombe, I actually never put much thought to pouring through the ATL and MFC code, to see how Microsoft did it. That's a great suggestion.
AverageMidget Send private email
Thursday, November 01, 2007
 
 
There is nothing particularly tortuous about assembly, it's just that there are better tools these days for most uses: you can still have plenty of fun with assembly when a paycheck isn't on the line. If you really want to understand assembly, and if you have a penchant for grittiest of nitty-gritty details, you might want to consider a book on computer architecture (my favorite is "Computer Architecture, A Quantitative Approach" by Hennessey and Paterson, but it's a pretty heavy text. The same authors have a lower level book titled "Computer Organization, the Hardware/Software Interface", either of which should satisfy any reasonable desire for low level details) which will give you a full understanding of what the actual program is doing after being compiled from C, C++ or C# into a specific machine language.

We professionals often, I think, forget that people can be interested in programming and computers as a hobby. If you are a computer hobbyist you're concerns are entirely different than the those of a working professional. As a hobbiest you are free to persue topics purely for your own enjoyment, regardless of applicability or earning potential.
Jeffrey Dutky Send private email
Thursday, November 01, 2007
 
 
My first instinct is to agree with a few peeps in saying starting off, I would suggest a "higher level" language but unfortunately having your requirement of needing to know the low level details makes it difficult.

However the application stack goes even further. Your going to have to dive into the OS level calls, drivers, and network layer.

If you get into Java, C# or any JIT stuff you can get into learning the actual intermediate code :)

Theres other GUI kits available for C++ like
GTK http://www.gtk.org/
WXwindows http://www.wxwindows.org/

Im a C# guy but those are the two free libraries I always here about.
Anon cause I fear the real world
Thursday, November 01, 2007
 
 
For low level stuff, check out books by Randall Hyde.  Hang around http://www.masm32.com/board/index.php if you have time & you will learn a lot.
LGC Send private email
Friday, November 02, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz