PDA

View Full Version : learning C++




thekev
Mar 19, 2012, 04:11 PM
Okay sort of similar to my last thread, but can anyone suggest a good method for learning such a language? All I ever read is that it's annoying to learn. Would books be the way to go? Night/online courses? I really have no idea as my background isn't in programming.



robvas
Mar 19, 2012, 04:13 PM
A book is a lot faster than a Class.

Start out with "Learn C on the Mac". You can use all your C knowledge when you learn C++ or Objective-C, and this book will show you ho wto use Xcode which is important since you're on a Mac.

http://www.barnesandnoble.com/w/learn-c-on-the-mac-dave-mark/1100351405?r=1&ean=9781430218098&cm_mmc=Google+Product+Search-_-Q000000630-_-Learn+C+on+the+Mac-_-9781430218098

firewood
Mar 19, 2012, 04:44 PM
Okay sort of similar to my last thread, but can anyone suggest a good method for learning such a language? All I ever read is that it's annoying to learn. Would books be the way to go? Night/online courses? I really have no idea as my background isn't in programming.

Different people learn differently. Figure out what's the best learning setup for you. Personally. Not what worked for some other random person.

Angelo95210
Mar 19, 2012, 04:49 PM
To learn a new language, I love the O'Reilly books which are available on Amazon. (Learning C++)

thekev
Mar 19, 2012, 05:41 PM
Different people learn differently. Figure out what's the best learning setup for you. Personally. Not what worked for some other random person.

With software I haven't taken a course since college (quite some time ago) so that's generally been a matter of reading books. I asked with this one because it's supposedly an annoying topic to learn. I don't expect to be writing programs or anything major. It's used in writing shaders quite a lot, and many stock ones are written in C or C++, so I wanted to be able to read this stuff properly. The post was just looking for leads or suggestions. It's not intended as a replacement for doing my own research. Anyway I just wanted to respond to that so that you don't think I'm simply lazy.

A book is a lot faster than a Class.

Start out with "Learn C on the Mac". You can use all your C knowledge when you learn C++ or Objective-C, and this book will show you ho wto use Xcode which is important since you're on a Mac.

http://www.barnesandnoble.com/w/learn-c-on-the-mac-dave-mark/1100351405?r=1&ean=9781430218098&cm_mmc=Google+Product+Search-_-Q000000630-_-Learn+C+on+the+Mac-_-9781430218098

Checking that one. Amazon seems to have more reviews. I may order that.

To learn a new language, I love the O'Reilly books which are available on Amazon. (Learning C++)

That name sounds familiar. I'll look them up.

WebMongol
Mar 20, 2012, 01:17 AM
Okay sort of similar to my last thread, but can anyone suggest a good method for learning such a language? All I ever read is that it's annoying to learn. Would books be the way to go? Night/online courses? I really have no idea as my background isn't in programming.

If you are new to programming - start with this solid book:
http://www.amazon.com/Primer-Plus-Edition-Developers-Library/dp/0321776402/ref=sr_1_1?ie=UTF8&qid=1332223370&sr=8-1
or this one:
http://www.amazon.com/gp/product/0201721481/ref=cm_cr_asin_lnk

Each book is around 1000 pages. C++ is heavy duty language for professional programming with 25+ year of history. Learning C++ would require substantial commitment and time investment.

If you are fluent in other programming language I would start with shorter book:

http://www.amazon.com/Accelerated-C-Practical-Programming-Example/dp/020170353X/ref=pd_sim_b_1

Good luck.

robvas
Mar 20, 2012, 07:09 AM
You might also want to play around with a language such as Python or Ruby to get the basics of programming before you have to deal with the very strict requirements of C++

chrono1081
Mar 20, 2012, 09:09 AM
Books are the best way to go in my opinion. C++ can be boring to learn, and it does take much more effort than C or something like Objective-C so be prepared for that. In my opinion though its not near as hard as people make it out to be, its just harder to get very good at.

Since you've never programmed before, maybe start with an easier language just to pick the basic ideas up (C is a great start). You don't have to be an expert at the easier language by any means but as long as you grasp these concepts:

-variables
-loops
-functions
-structs
-conditional statements
-maybe classes (depending on the language, although this can wait)

You should be good to go for C++.

thekev
Mar 20, 2012, 09:48 AM
You might also want to play around with a language such as Python or Ruby to get the basics of programming before you have to deal with the very strict requirements of C++

Python is the other thing I'm studying at the moment, so that is covered. I have never actually come across Ruby.

Books are the best way to go in my opinion. C++ can be boring to learn, and it does take much more effort than C or something like Objective-C so be prepared for that. In my opinion though its not near as hard as people make it out to be, its just harder to get very good at.

Since you've never programmed before, maybe start with an easier language just to pick the basic ideas up (C is a great start). You don't have to be an expert at the easier language by any means but as long as you grasp these concepts:

-variables
-loops
-functions
-structs
-conditional statements
-maybe classes (depending on the language, although this can wait)

You should be good to go for C++.

I might try C if it helps understand the other. Also I started on Python. If I recall correctly, you use many of the same programs in your work. I could always see how far I get with books before getting stuck, but I hate developing bad habits early on. That's usually a concern with any new software or workflow. Initially the purpose of this is just writing custom shaders, but I do want to take the time to learn the language effectively.

danwilliams
Mar 20, 2012, 12:41 PM
I might try C if it helps understand the other. Also I started on Python. If I recall correctly, you use many of the same programs in your work. I could always see how far I get with books before getting stuck, but I hate developing bad habits early on. That's usually a concern with any new software or workflow. Initially the purpose of this is just writing custom shaders, but I do want to take the time to learn the language effectively.

I am twenty years in with software development and I am still finding better ways to use the language effectively. It's a never ending process. Jump on in and along your journey you will come across code/books/forums/people that will help in that goal. Just be relentless in that pursuit every single day and you will be way ahead of the curve.

May the force be with you...

sero
Mar 20, 2012, 04:26 PM
This is pretty decent (and free):
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-096-introduction-to-c-january-iap-2011/

thekev
Mar 20, 2012, 05:48 PM
This is pretty decent (and free):
http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-096-introduction-to-c-january-iap-2011/

I read through the intro and a little of the second part. I'm going to look at the first couple lectures and exercises this evening.

I am twenty years in with software development and I am still finding better ways to use the language effectively. It's a never ending process. Jump on in and along your journey you will come across code/books/forums/people that will help in that goal. Just be relentless in that pursuit every single day and you will be way ahead of the curve.

May the force be with you...

+1 for the Star Wars reference:D. I'm not trying to become a programmer or anything of that sort. I keep bumping into stuff that's written via C++ or Python and I wanted to better understand how the languages work rather than just memorizing details relative to a given application without that level of comprehension. I feel like that kind of learning path leads to bad working habits that become more difficult to correct later. As I noted my research isn't limited to starting a thread here (as that would be silly). It's just helpful getting a range of suggestions and sometimes warnings on common pitfalls.

Cactus Dan
Mar 20, 2012, 07:01 PM
Howdy,

Here is a good dvd video tutorial series called "C++ Complete" on C++ and OpenGL:
http://www.3dbuzz.com/xcart/product.php?productid=30&cat=12&page=1

Even though it's mainly using MS Visual Studio on Windows, they use cross platform frameworks, GLUT, wxWidgets and SDL, so following along the lessons on Mac is fairly easy. It's well worth the price.

Adios,
Cactus Dan

macrumorsuser10
Mar 20, 2012, 08:30 PM
Okay sort of similar to my last thread, but can anyone suggest a good method for learning such a language? All I ever read is that it's annoying to learn. Would books be the way to go? Night/online courses? I really have no idea as my background isn't in programming.

C++ is one of the most powerful and difficult programming languages; I know this because I'm a professional software engineer, and I write C++ code. I learned this language in undergrad, used it in grad school, and then spent many years as a professional learning best practices and idioms from my own mistakes and by reviewing other professionals' coding. This is a programming language that not too many engineers can truly master.

From what you wrote, you want a "casual" programming language to start learning programming in general. Try JavaScript or Python to learn about functions, loops, and other programming language constructs that are applicable to almost all other languages.

If you are serious about C++, then the best bet is to start off with a class at a local junior college where the instructor can help you learn from your mistakes and teach you best programming practices.

thekev
Mar 20, 2012, 08:55 PM
From what you wrote, you want a "casual" programming language to start learning programming in general. Try JavaScript or Python to learn about functions, loops, and other programming language constructs that are applicable to almost all other languages.



I mainly wanted the ability to write my own shaders. I am not going into what would be considered software development. I'm working on learning python simultaneously, which is something I should have done long ago, but at least I'm doing it now. It's quite popular as a scripting language.


If you are serious about C++, then the best bet is to start off with a class at a local junior college where the instructor can help you learn from your mistakes and teach you best programming practices.

It would end up being a night course if I did that. Given that the summer term for such a thing would still be at least a couple months away, I do have time to review some books before then. A course does sound appealing. I'm kind of paranoid about developing bad working habits.


Howdy,

Here is a good dvd video tutorial series called "C++ Complete" on C++ and OpenGL:
http://www.3dbuzz.com/xcart/product.php?productid=30&cat=12&page=1

Even though it's mainly using MS Visual Studio on Windows, they use cross platform frameworks, GLUT, wxWidgets and SDL, so following along the lessons on Mac is fairly easy. It's well worth the price.

Adios,
Cactus Dan

Thanks but that seems like they're covering a lot of topics in a limited amount of time. For $100, I feel like I'd be better off with $100 worth of books (assuming quality books).

chrono1081
Mar 21, 2012, 01:24 AM
Howdy,

Here is a good dvd video tutorial series called "C++ Complete" on C++ and OpenGL:
http://www.3dbuzz.com/xcart/product.php?productid=30&cat=12&page=1

Even though it's mainly using MS Visual Studio on Windows, they use cross platform frameworks, GLUT, wxWidgets and SDL, so following along the lessons on Mac is fairly easy. It's well worth the price.

Adios,
Cactus Dan

Hm....I may get that just for the OpenGL tutorials. OpenGL tutorials that are good are hard to come buy.

The Blue Book doesn't really teach OpenGL anymore, it only teaches their wrapper and the Red Book is full of deprecated API's. NeHe is severely outdated so maybe I'll give these a shot.

If anyone used these, please let me know what you thought about them, especially the OpenGL sections. I'm familiar with OpenGL but I just don't feel like I know enough of it and its hard to find good resources on.

Cactus Dan
Apr 1, 2012, 03:10 PM
Howdy,
...If anyone used these, please let me know what you thought about them, especially the OpenGL sections. I'm familiar with OpenGL but I just don't feel like I know enough of it and its hard to find good resources on.
The videos go from the basics (drawing a 3D cube) to creating a scene graph and working with shaders. I've gone through all of the lessons, following along using Xcode.

Adios,
Cactus Dan

chrono1081
Apr 1, 2012, 03:23 PM
Howdy,

The videos go from the basics (drawing a 3D cube) to creating a scene graph and working with shaders. I've gone through all of the lessons, following along using Xcode.

Adios,
Cactus Dan

So definitely worth the money? If so I'll be buying these very soon.

Cactus Dan
Apr 1, 2012, 03:34 PM
Howdy,

Yes, I think it was well worth the money. You'll get C++ Volumes 1 through 5 plus the OpenGL In-Depth. The OpenGL In-Depth is 73 lessons. Of course I had to figure out how to set up the projects in Xcode, compared to them using MSVC++, but there was plenty of information on the internet to get it figured out, even for an old guy like me. :D

Adios,
Cactus Dan

chrono1081
Apr 1, 2012, 03:55 PM
Howdy,

Yes, I think it was well worth the money. You'll get C++ Volumes 1 through 5 plus the OpenGL In-Depth. The OpenGL In-Depth is 73 lessons. Of course I had to figure out how to set up the projects in Xcode, compared to them using MSVC++, but there was plenty of information on the internet to get it figured out, even for an old guy like me. :D

Adios,
Cactus Dan

Thanks! I ordered them :)

softwareguy256
Apr 14, 2012, 11:58 PM
Read every page of Bjarne's book, then read every page of scott meyer's books. If you are a beginner it may take several years of experience to be able to put everything together. Where's that 10,000 hours statistic I keep hearing about?

When you are done with that, thoroughly understand boost. then you too will be a C++ guru. The reward at the end is well worth the hardships.

Do not take shortcuts, you will write very bad code and your potential will be stunted, e.g. you will never get hired at the most prestigious firms out there.

Mac_Max
Apr 17, 2012, 11:34 AM
I didn't find C++ to be particularly difficult to learn. I actually had a harder time with Objective C than C++. There are a few things that will really make life easier for you:

Don't be lazy and skip creating copy constructors, destructors & assignment/equality operators for classes that need them (those that contain pointers you need to deep copy). Being lazy is a good way to introduce subtle bugs.

Learn RAII. Link 1 (http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization), Link 2 (http://www.hackcraft.net/raii/).

Don't use heap semantics (pointers) just because its cool or fun (well except for learning projects and breakable toys) when you're better served by stack semantics; i.e. variables that will never be passed between functional units or passed as arguments to other functions. Any time you use a pointer, you're opening yourself up to the possibility of a memory leak, and when you're not dealing with some massive object larger than your stack or a large object that has to be passed to a function you're not receiving any benefit by using a pointer. Stroustrup has been trying to get this message out for years but its very hard to convince people to not throw pointers at everything (partially because pointers are what make C/C++/Obj C better than those other inferior languages :rolleyes:).

Also related, try to pass objects by reference where possible. There are many fringe benefits besides being able to, in many cases, use simpler syntax. At the very least, remember to pass your objects as pointers so you're not creating copies left and right for no reason. Primitive types (int, bool, float, char, etc) can be passed by value.

Learn how to use Smart Pointers (http://en.wikipedia.org/wiki/Smart_pointer).

Learn Const correctness (http://www.parashift.com/c++-faq-lite/const-correctness.html).

Try to rely on composition rather than inheritance (http://www.ronaldwidha.net/2009/03/22/a-good-example-of-favouring-composition-over-inheritance/). This will be hard initially since deciding which is better is very much a decision influenced by past experience and most of your teaching material will have you creating all sorts of inheritance chains. Just keep an open mind to how you implement things and you'll be fine.

neowin
Apr 17, 2012, 10:52 PM
the best video tutorials for C++ out there -

http://thenewboston.org/list.php?cat=16

mully1121
Apr 18, 2012, 05:36 PM
the best video tutorials for C++ out there -

http://thenewboston.org/list.php?cat=16

I second this recommendation, the guy really breaks it down well and does it in short easy-to-digest blocks.

ChrisA
Apr 18, 2012, 09:12 PM
Okay sort of similar to my last thread, but can anyone suggest a good method for learning such a language? All I ever read is that it's annoying to learn. Would books be the way to go? Night/online courses? I really have no idea as my background isn't in programming.


You say your background is NOT is programming. All those suggestions to buy a book are only good if you DO already have a background in programing.

Learning to program is NOT the same as learning a programming language. It is like writing a novel. You could write a novel in Spanish or English but in order to do so you h=first have to learn how to develop characters and story lines and so on.

Class es at a community collage are the best way. Then you have access to an instructor and may get to work on projects with other students.

If you did have a software background then I'd say to just get a reference book and use C++ on the next project and look up everything as you need it.

thekev
Apr 18, 2012, 11:02 PM
Do not take shortcuts, you will write very bad code and your potential will be stunted, e.g. you will never get hired at the most prestigious firms out there.

Heh.. you misunderstand my goals slightly. I'm not looking to be a programmer. I'm looking to implement very basic functions with clean code rather than making sloppy mistakes because I don't know any better. It's a case of where I want to do very basic work but keep it efficient.



Try to rely on composition rather than inheritance (http://www.ronaldwidha.net/2009/03/22/a-good-example-of-favouring-composition-over-inheritance/). This will be hard initially since deciding which is better is very much a decision influenced by past experience and most of your teaching material will have you creating all sorts of inheritance chains. Just keep an open mind to how you implement things and you'll be fine.

I didn't realize my thread had been resurrected, but this is an amazing response, and yeah while I only quoted part of it, you're correct about not making lazy mistakes. It applies to anything. I'm not looking to write entire programs, but rather customize small functions via API, but yeah I had making mistakes. I've looked at all of the links in the thread, but I haven't really moved forward with this much given that i've been working on other things.


Learning to program is NOT the same as learning a programming language. It is like writing a novel. You could write a novel in Spanish or English but in order to do so you h=first have to learn how to develop characters and story lines and so on.

Class es at a community collage are the best way. Then you have access to an instructor and may get to work on projects with other students.


I'm quite aware of that, and I may sign up for courses. Heavily structured learning has always been problematic for me though. I get bored when they go too slow, and if I find something I wish to investigate, I can't always do it at that moment. The thing about courses in general is that it's easier to discern good ones if you know more about the topic. They're not all equal, even at really good colleges.

chrono1081
Apr 29, 2012, 11:27 AM
Class es at a community collage are the best way. Then you have access to an instructor and may get to work on projects with other students.


This really depends...

I learned programming on my own through books before college, and in college we didn't learn nearly enough to be effective (and I went to three colleges).

The worst out of the three was Penn State, it took us 16 WEEKS just to get to overloaded functions, and we didn't touch classes or inheritance or anything like that.

Although a class would be useful to a beginner, honestly in my personal experience its rare that its worth the money.

Cactus Dan
Apr 29, 2012, 03:43 PM
Howdy,
...If you did have a software background then I'd say to just get a reference book and use C++ on the next project and look up everything as you need it...
For some of us, particularly those of us who are self motivated, this can sometimes be the best method. ;)

Adios,
Cactus Dan

PrismaticRealms
May 2, 2012, 03:33 PM
I can learn from books pretty well, and is usually the way I go. But you need a certain amount of motivation to keep going, and not everyone can do that.

Another option you have is online training. I took a couple of courses at gameinstitute.com (http://www.gameinstitute.com/package.php), including a C++ Programming course. I took it as a refresher, but it starts from square one, so you can use it to learn C++ from scratch. That course includes 2 thick text manuals full of material, examples and exercises, access to an online community of students, access to teachers via email, and presentation videos. There are online exams that you must pass, and you'll receive a certificate from them for completing the course with a passing grade. (I passed with a 94%. ;))

In fact, they have been running a special for a couple of months now where you can buy that course, as well as every other course they carry in their game developer package, all for $99! I actually bought the package a few weeks ago. Great friggin' deal, even though I had already bought a couple of the courses from them before.

(And no, I don't work for them. :))
Good luck!