• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Learning C/C++

Status
Not open for further replies.

SD-Ness

Member
I know Visual Basic and Java pretty well, but I think it's time I learn C/C++.

Do I need to learn just C++ or is C worthwhile too? [yes, I know they are similiar...]

1) Books/Tutorials?

2) Is there a discount [student...] for acquiring the software with?

If you're familiar with both Java and C++, how similiar are they to each other?
 

neptunes

Member
If you have visual basic then get MS visual C++.

Find a book and learn from it eveyday I guess, but my best bet is to get training or education.
 

Dyne

Member
http://www.bloodshed.net

Download Dev C++; it's the best free compiler program. And buy a nice book on learning C++. Forget C. It was upgraded for a reason. :)

I myself learned in two high school courses with a textbook, and I figured I could do without the teacher. He was only really there to keep me working in class. Haha.
 

Lazy

Member
I strongly recommend "C Programming: A Modern Approach" by K. N. King. Great way to learn C (and a bit of C++), and it also works as a great reference book once you understand the material.
 

maharg

idspispopd
rkxhASDV3hbPgDM3vSji48amkjK


This is the book to learn by if you're going to learn C++. It's about the only one I've encountered that isn't more of a tutorial in bad C++ coding practices mixed with a bad introduction to OO methodology.

Note that this book will teach you very little about actual high level OO coding practices. What it will do is give you an excellent foundation in modern C++ coding practices. Once you know the language, then get a book on OO if that's the way you want to go.

If you know Java, you may not need that anyways. Whatever you do, though, don't treat C++ as something to shoehorn into the way you do things in Java. There is a much stronger emphasis on compile-time structures in C++, as well as on value semantics which barely exist in Java (in fact, contrary to popular belief, coming from Java the hardest thing to learn won't be pointers -- it'll be values).
 

Pochacco

asking dangerous questions
C is a subset of C++ btw...

...C++ isn't too bad if you know Java. When I learnt C++, I was already familiar with Java. The syntax is somewhat similar. You're gonna have to focus on the differences between the two: like memory management, types of constructors, overriding operators, etc. (I honestly can't remember much...). You'll probably find that while C++ is a lot more error-prone, inconsistent, and messy; it's also a lot more powerful and 'customizable' than Java (e.g. you have to manage memory - which is sometimes a pain, but is very important when performance is an issue).
...pure C is another beast imo. I'm not even close to mastering it, so I'll refrain from saying anything...

...but I will say that it's often hard to get out of that object oriented mindset that comes with Java and C++ (if you're using OOP that is).
 

maharg

idspispopd
" You'll probably find that while C++ is a lot more error-prone, inconsistent, and messy;"

A better, more reasonable, way to put it is that C++ allows for a broader range of coding styles, and some of them are bad. If you try to mix and match those styles, or otherwise don't code consistently, the above will be true. It is, however, not so much the language's fault as yours (or possibly whoever/whatever taught you -- very often the case).

I might add that I find it incredibly annoying when people say things like this. C++ and Java, while syntactically similar, are very different languages with entirely different design goals and premises. To compare them, especially when one or the other is one of your first 'real' languages, is not only unfair, but also misleading.

You'll note that in the above retort, I didn't talk at all about the comparison with Java. All I've said wrt to Java in this thread is a couple of technical, objective differences between the two. My opinion of the two languages is pretty much 180 degrees from yours, but I try to avoid openly using any such comparisons because when the languages are as different as Java and C++, it becomes entirely subjective.
 

NotMSRP

Member
If you're dealing with hardware related-issues then learn C. Stay with C++/JAVA if you want to stay on the software side.
 

NotMSRP

Member
C++ was made to dealt with issues that arose from C, and JAVA was made to dealt with issues that arose from C++.
 

maharg

idspispopd
fart said:
*may be hyperbole (don't hurt me maharg)

Hey, so long as you keep it confined to one language, with no comparisons, it's cool with me :p

Lathentar said:
Partially corrected.
See now this is supportable (arguable, but supportable).

Lathentar said:
Must is a bit strong, but yes they're both good. Bjarne's is the only other book I've ever seen with a decent tutorial-like style to decent coding practices in C++. The book I pasted above is much like his (and Koenig is a very significant contributor to the C++ language itself, as well) but more focused on teaching and less on rationale. I'd call it (Bjarne's, not Koenig's) a second step book, except that until recently there's been very little in the way of first-step books that don't suck.

I haven't read the library reference book, but I have heard many good things about it.
 

maharg

idspispopd
Lathentar said:
Easily supportable, easily arguable (why I put Partially).

I consider it arguable in the following way: Languages that aim to improve productivity out of the gate often have little to no impact in the long term. Once you get down to it, you tend to be writing the same code no matter what language you work with. For example, if you have a decent set of supporting libraries in C++, your code and your startup difficulty, barring any need to learn the language, will be little different.

However, it's indisputable that that *was* one of the aims of introducing the language. I don't think the other argument (that it fixes 'issues' with C++) is supportable because, in fact, it owes more to the legacy of smalltalk and other 'pure/academic' OO languages than it does to C++, from which it borrows not much more than syntax. Java did not invent garbage collection, and C++ is not incapable of doing garbage collection, and that's often the most specific thing people are talking about when they make that argument.

fart said:
actually maharg, i've still never seen a first step book that wasn't terrible.
Have you checked out Accelerated C++? I took my resident barely-coder through it and found it was quite good at bringing them through the early concepts. It also makes extensive use of the standard library, completely avoids macros (one of the biggest crimes of most beginner C++ material), and doesn't bother to pretend that it teaches templates or object orientation in full.
 

Lathentar

Looking for Pants
maharg said:
I consider it arguable in the following way: Languages that aim to improve productivity out of the gate often have little to no impact in the long term. Once you get down to it, you tend to be writing the same code no matter what language you work with. For example, if you have a decent set of supporting libraries in C++, your code and your startup difficulty, barring any need to learn the language, will be little different.

I disagree there. A large part of the object oriented movement was because the human mind could more easily view systems as groups of objects. Allowing our minds to think of code the same way we think in the real world is a productivity increase.

If I want to code something in a functional language my code is going to be VERY different than it would be in an object oriented language such as Java. Even if they tackle the same task.
 

maharg

idspispopd
Lathentar said:
I disagree there. A large part of the object oriented movement was because the human mind could more easily view systems as groups of objects. Allowing our minds to think of code the same way we think in the real world is a productivity increase.

If I want to code something in a functional language my code is going to be VERY different than it would be in an object oriented language such as Java. Even if they tackle the same task.

Heh well yes, barring paradigm shifts. Actually I personally find functional language to be easier to understand in general, but the particular implementations of it that exist (lisp, haskell) are imo unreadable do to syntax issues.

(unless you mean functional as in purely procedural, in which case the above applies, but without the tangent. If the language does not fascilitate some degree of OO, odds are you'll have to implement parts of it yourself somehow)

Also, on another slight tangent, I would not argue that Java is not a better purely OO language than C++. Actually I think C++ is particularily weak at pure OO. But its mix of OO and static generic programming paradigms is, imo unmatched by any other popular language.
 

maharg

idspispopd
iapetus said:
<sigh>

How many times do I have to say it, people?

Thinking in C++, Volume 1
Thinking in C++, Volume 2

Thinking in Patterns

Bruce Eckel owns you.

[Edit: The Patterns book is actually a Java thing - though many of the principles will apply in C++ as well, albeit with different implementations. Thinking in C++, Volume 2 has a section on patterns, though.]

I can not, in good conscience, second any recommendation for the Thinking in C++ book. It is full of terrible practices (macros macros everywhere) and is terribly outdated (one, very late, chapter on the standard library -- I'm sure you wouldn't recommend a book that excluded the entire java library altogether). His Java books may be good, but his C++ books, you get what you pay for.
 

maharg

idspispopd
fart said:
macros are totally awesome. i love macros with every part of my body.

In C, fine. In C++ keep them away from my code. With inline functions and the fact that const static variables can be inlined, as well as templates for more complex structures/functions, 90% of the usefulness of macros is eliminated -- and the replacements are all namespacable and don't have sometimes surprising behaviour.

The other 10% is hacks, especially assert or debug-type functionality, where the ability to completely remove a piece of code from the output, or to pull context information into a function is needed.
 

maharg

idspispopd
That said, understanding patterns is a great idea. The original Gang of Four book on it is also very good. Just so long as you understand it as a clarifying theory and not something to shoehorn real code into :) Like all theories, it can go too far.

Oh and this is a really good site to get a good idea of the quality of a C++ book before buying it. Big names in the C++ community do the reviews, and there are some where the author defends their book in the comments section heh.
 
Status
Not open for further replies.
Top Bottom