Programming preferences, detailed opinions requested

Hello all. For about two years now I’ve been slowly trying to teach myself programming. I started out in Java to get a hang of OOP and quickly switched to C++ (via MS’s Visual C++ 6.0 package).

I’m really enjoying it so far, and though I’ve taken a few months off here and there, each time I return to it, learning more about Windows programming comes easier and easier. I’m now getting to the point where I want to start designing graphics inside windows and I’ve hit another hurdle.

The first hurdle I hit was whether to learn C++ first or C first, and I chose C++. Now I think I am still going to have to go back and learn C eventually. To this end I’ve been recommended “C Primer Plus” as well as the classic work of Ritchie. Will it be easier to “get” C after knowing C++ or should I really have gone about it the other way? Should I even bother with C at all?

The newest hurdle involves graphics programming. OpenGL and Direct3D are both available and have public SDKs and lots of information about them (though I’ve found better OpenGL tutorials). Is there a sort of idea I can have about which to go for? I’ve tried looking for some decent opinions but most of what I’ve found from googling isn’t terribly insightful.

From what I gather, OpenGL’s strength is platform independence, but Direct3D’s strength is, well, that it is better (we’re on DX9.0 right now) and more widely used and supported. I also seem to hear it whispered that OpenGL is easier to learn, though. Others have suggested that one tackle OpenGL with GLUT then move on to OpenGL inside the Win32 without GLUT and then moving to Direct3D will be a piece of cake.

Any dopers have any ideas to add to this? Recommended books would even be welcome if you have personal experience with them.

It might help to know that I fully intend to move to Linux over XP, so platform independence might be a bonus. On the other hand, I might not like Linux.

If you know C++, you already know C; the only learning curve you might have would be the RTL (i.e. standard functions like printf, strcpy, etc.), which you probably already know from C++.

Can’t help you on the OpenGL/DirectX issue – I’m not much of a graphics expert.

I disagree with you here. . .usage of pointers, memory allocation, etc. etc. is completely different in C, as are most of the functions needed for basic input/output which you certainly wouldn’t “already know from C++.” If someone learned strictly C++ using cout << "Hello World. I am " << variable << “years old” etc., what would they think about printf(“Hello World. I am %d years old”, variable); ? Maybe they’d get it, maybe they wouldn’t. I’ve seen lots of people not get it. Don’t even get me started on pointers, passing addresses into and out of functions, and so on.

I learned C first, and was glad I did. After that, C++ was easy. Simplified input/output, passing by reference, it was all simpler than C–the only new idea was the OO nature (which to me wasn’t all that hard to grasp.

So, for Windows Programming I decided to go about it the same way. . .I first wrote some things using the Win32 API and C. Then once I had a grasp of how everything worked that way, I moved to the MFC and C++. The MFC encapsulates a lot of stuff, and knowing the full API beforehand helped me understand what’s really going on in there.

The only graphics programming I’ve done is with OpenGL, C, and GLUT. If you understand the event-driven nature of Windows Programming, then that’s the major hurdle most people have with interactive graphics programming (setting up functions to respond to arbitrary events in a loop, instead of either waiting for specific input and/or proceeding sequentially through the program code). I have looked at the DirectX API, and the concepts are remarkably similar to OpenGL, so it wouldn’t seem like that big of a deal to use either one of them (if you learn one, you can learn the other, I would think).

Well, troub I would agree with memory allocation. I have never had to use malloc or anything of the sort. Vectors and the “new” and “delete” operators take care of memory handling quite easily. But “printf” is easy to adopt afer having used the CString’s “Format” method which would run
sMyString.Format(“The number of dollars is %f”, fDollars).

Also, the TRACE macro I use in debugging has the same syntax as “printf”, though I don’t know any programmers so I don’t know how often TRACE is used.

I can say that I have a friend who has of and on tried to teach themselves C and made some fantastically buggy code that I genuinely couldn’t work through. To produce a workable program I’ve always resorted to rewriting in C++ knowing what the program was supposed to accomplish. So perhaps knwoing C isn’t really inherent in C++ programming, but it is mostly readable and I think it would be easy to pick up without much practice. Most of the syntax, AFAIK, is quite the same. But what do I know, I haven’t tried it yet! :stuck_out_tongue:

I note you said you used GLUT. From what I understand GLUT is only used to abstract the window greation inside of an OpenGL sort of framework, but that if you had a grasp of window creation and message handling then GLUT wasn’t necessary and even had some overhead. Is this correct or am I misunderstanding something?

I’ve programmed in both C++ and C. there isn’t that much of a difference, except that C++ is object oriented. I didn’t think that C even used pointers.

Learn C. Once you can whip up a linked-list implementation on the fly in C, you’ll probably be able to learn anything else fairly easily down the line.

The classic tome of C knowledge is “The C Programming Language” by Kernigan and Ritchie.

I’ve run into far too many programmers nowadays who can’t do things like this, and it really hurts them if we run into anything tough.

Nowadays, it seems like nobody even remembers what the heck a linked list or a pointer is, but it’s good foundation knowledge to have, and will help you in the future.

About OpenGL/DirectX - OpenGL is probably a little more intuitive and easy to learn, and might be a better starting point. But as long as you’ve got a good foundation of skills to draw upon, neither one should be too much of a hurdle for you.

Learn Perl (pick up any of the O’Reilly books). I used to be a C/C++ programmer. Never again, if I can help it.

How could someone familiar with C++ not know what a linked list or pointer is?? How on earth could you possibly get by without ever having to encounter these?

…is there something in C++ that I don’t know about that indeed can “replace” these functions?

I would learn DirectX over OpenGL due to the fact that DirectX is a full suite that covers not just graphics, but audio, internet connectivity and controllers. You don’t need to know C to use it, it works with C++, C#, VB and pretty much any other programming language out there.

There’s also quite a few decent books on programming in Direct X. I’ll have to check my library for which ones are the best, but if you’re looking to add sound and videogame like control (even with a keyboard) you’ll probably be going to Direct X anyways.

kputt wrote

Umm, I hate to be harsh, but if you’ve programmed in C and weren’t aware of pointers, then you weren’t programming in C.

To the OP, I’m glad I learned C first, as C++ is really like the name implies, like C but better. Going backwards means having to learn things you didn’t have to worry about, like (as mentioned) memory allocation, pointers, function names and usages.

Most of my work has been in driver type things, where C seems to be better suited.

Definitely learn C/C++; you can then use that as a foundation to build your other skills off of.