views:

71

answers:

3

When learning new languages such as C++ from PHP, does reading other language snippets help you understand better by giving one a different prospective, or does doing so confuse a noob like me? Also, any advice on learning C++ would be great.

+2  A: 

I find it helps to

  1. Get a good grasp of the syntax and semantics of the language, by looking at SIMPLE examples and relating it to something you already know
  2. Look at what libraries and design patterns are common. Find out why they are common. Was the language designed to encourage them? Is it convention? Efficient?
  3. have an idea that you want to implement in the language. It will give you a goal, and some perspective.
  4. Look at other's code, once you are comfortable picking apart and reading it, and comfortable with source-layout, conventions, common-naming and so on

I find it best to dive-in heads first. Get feedback from people if possible. Most importantly:

don't be afraid of making mistakes they are a big part of the learning process. And try and relate things to concepts you are already comfortable with.

Aiden Bell
Yup, it was me... you do make some good points :)
Zifre
+2  A: 

I find that reading short snippets helps a lot. A good book is really handy too. Once you understand most of the language itself, reading large, full-size programs helps a lot with learning how common problems are solved in that language. Most languages don't have a term for this, but it is like the "Pythonic" way in Python.

As for learning C++, first get a good understanding of C. C is quite simple, so it shouldn't take that long. Once you know C, start learning about the C++ specific features one at a time. This way, you can still write useful programs (C is mostly a subset of C++), before you learn the real "C++ic" way.

Zifre
Do I mod this up? I agree with the 'learn C first', but do I stump my answer ... decisions decisions :) We can exchange :P
Aiden Bell
Zifre, don't know if you upped, but I will now :P
Aiden Bell
+1  A: 

If you are sufficiently inexperienced to ask this question, I recommend that you read short snippets, but not in another language. A better mental exercise is to say given a short snippet in the new language (C++), how would it compare with what you would write in the old language you already know (PHP)? Similarly, if you read about a new C++ thing, ask what PHP snippets you could express in the new C++ish way.

Regarding C++ itself, there are plenty of other SO questions to trawl. I think it bears repeating that the Design Patterns book with four authors is very helpful to learn the vocabulary and mindset of many longtime C++ programmers.

Norman Ramsey