What is the best way to learn more C++ programming?

Red Squirrel

[H]F Junkie
Joined
Nov 29, 2009
Messages
9,211
I pretty much self thought myself programming, I would not call myself an expert, I basically try to find out something as I need to use it. There's lot of big projects I want to start on, and I realized I need to step back and maybe learn more so I can start off well, and ensure I'm following standard conventions, standard ways of doing things, not using bad habits etc...

So I've been thinking of picking up a couple C++ books and reading from start to end. I'm specifically programming under Linux, but depending on what I'm programming, I usually try to compile/test in Windows too.

I've also been thinking I should take a program like Apache or even the Linux kernel itself, and look at the source code, try to modify it etc and learn that way. I learned lot of C# that way as a game server I run is all coded in C# and I've rebuilt a lot of it from ground up.

Any other ideas of ways to brush up on C++ or am I on the right path? The first book I'm thinking of going with is "Effective C++".
 
Thinking in C++ by Bruce Eckel
Part 1 and 2

I have read part one and it was great. I imagine part two would be the same. It's not "dry" like a whole lot of programming books out there. I would really recommend it.

However, I could give you a lot of reasons to learn another language though... :p
 
My personal opinion: Just write some more C++ code. For me, it's fair to say that the Effective C++ books are quite good, but I treat them as morality guides. They help me along and I can avoid some subtle C++ language traps, but reading about them vs writing code and finding out for yourself can be a big difference.

However, I'm not sure you'll find much C++ in apache or Linux. I think they're both primarily C? Linux is definitely all C. Linus isn't exactly a fan of C++.
 
My personal opinion: Just write some more C++ code.
For just about any other language, I'd agree with you. But C++, being far too big for its own good, is pretty difficult to get a thorough overview of with this kind of self-directed experimentation. You can comfortably accomplish just about anything you need to with a relatively small subset of the language, and once you've got that far, there's not much pushing you to look further.

Unfortunately, that's about where I lost interest, so I can't offer any advice on where to go from here...
 
Ok, poor advice. It really depends on what you want to learn about C++. For example, I consider myself to be pretty fluent in C++, but definitely not a master. I wanted to elevate my understanding of language design issues and understand some of the "Why?"s of C++ and other programming languages which facilitate an object oriented style of programming. To that end, I took a compiler construction class and learned a lot about language implementation and some issues of different languages. That knowledge has helped me to understand why some of C++ is the way it is and has affected my programming style in slight ways (for better or for worse is another question...).

Wanting to learn how to best use C++ probably requires extensive experience not only in C++ but in other languages as well. You need to know what C++ is good at and what it is bad at to be a great C++ programmer.

If you're looking to go the route of understanding the implementation details of C++, I would highly recommend learning about compilers and implementing object oriented languages. Trying to implement C++ itself would be a colossal effort, but learning about the issues for simpler languages will give you some insight into its language design. The standard is a thorough (if not terse) resource, which may be useful in this regard, but it's a huge document that specifies the language. It doesn't really explain why things are the way they are.

If you want some more practical and hands on approaches, a solid book isn't a bad start. Effective C++ pretty awesome, but again, I consider it a morality guide. Some of the books by Strustroup aren't bad either. At the end of the day though, you need to supplement reading with doing. Maybe you should take some of your projects you've done in other languages and reimplement them in C++. First try to recreate it to get the exact same functionality. Then try to do something in C++ that you found difficult to do in the other language (or maybe you found it the other way around, you did something in the other language that was far easier than in C++).

But, you should figure out what you even mean by learning more C++ programming. Doesn't even sound like you know what you're looking for.
 
Thanks for the tips so far, I'll keep those in mind. By learning more I mostly mean just that, I just want to gain a better set of knowledge for knowing how to do things property etc like I mentioned, and also know more specifics like sockets, graphics, etc...

So yeah think I'll start with reading Effective C++, and take it from there. I will probably want to at least know C concepts well enough as well, since lot of 3rd party libraries are C so I will want to be able to understand them better. Like for example I see really weird stuff that I can never understand, such as passing structs as a void, and weird stuff like that. So I'll want to learn those concepts.

I also have a lot of smaller projects I can take on as practice. I tend to only use C++ for small things here and there so I can't say I have that much experience, but I will be diving more into it.
 
As an experiment I rolled my own c compiler in the 90s. Unfortunately did not take it far enough and had to stop. Something like that would be very useful. But todays languages are just too complex unless you have a specific target in mind. In other words, if you want to learn how to program, there are general techniques involved for creating legible code that others can edit in the future. these apply to all languages. I think Mike Blas has a post with recommended programming links. For C++ only the topic is too broad. Unix programming, Object programming, windows programming, gui programming, api programming, etc. There are multiple books available for each topic. Settle on something, get a programming cookbook and work through the examples. I tend to like the cookbooks myself.
 
Have you considered joining some sort of open source project? Stuff like Wine still needs alot of work and would require you to pickup alot of new knowledge.
 
I've thought of that too actually. At least I could contribute to something and actually see it find itself packaged in a distro or what not, would be a pretty rewarding feeling.

For learning purposes I could try to make my own port, just for fun, then contribute the code. Think I'll look into that. One project I would really like to see take off better is Gimp. It currently sucks, so maybe I could make it my goal to learn enough to make it better.
 
One of the best things you can do is try and get some peer review on code you write. A seasoned set of eyes can point out where you might improve things.
 
Mozilla maintains a pretty extensive C++ codebase for their work on Thunderbird and Firefox.

https://developer.mozilla.org/en/Introduction

I'd recommend getting on their IRC and talking with other developers if you're having trouble. I think #introduction at irc.mozilla.org is their new developer help channel, but most devs (for firefox) live in #firefox I think. You'll probably get help there more easily.
 
Back
Top