Knowing Programming Fundomentals and jumping to C++

Started by
10 comments, last by ZwodahS 10 years, 8 months ago

Hello guys, I am new to this forum and this is my first post.

So let me get straight to the meat.

I know the Programming Fundomentals like selections,loops,arrays, data types, functions ect.

Some basic algorithmic like fusing arrays, sorting arrays, searching ect.

All this using the Pascal language!

I have solved many "complex" problems with Pascal (as complex as they can be with this language).

So I understand the concept of thinking like a programmer a little bit.

If I jump to C++ will I have any problems? I am not familiar with Object Orientated languages and haven't used anything like it.

I have read the sticky threads of this forum. But they actually talk more about complete beginner.

I am a beginner but I think not a complete beginner.

So will it be a bad choice to jump straight to C++ ?

I am planning to buy a book. So any recommendations acording to that are welcomed!

Thank you. smile.png

Advertisement

Jumping to C++ is not a bad or horrible thing to do but, you need to keep your expectations realistic. Going from Pascal to C++ without increasing your knowledge of programming is completely valid, just don't expect (and don't try immediately) to use templates, classes etc, treat C++ as C to start with. Think of the initial transition as just a change in dialect where you do pretty much everything exactly the same, just getting used to the various dialect changes. Don't go jumping into classes, templates and all the big fluff items until you are solid with the foundations.

Unfortunately I've not read a beginner book in a very long time so I can't make and suggestions there. But, I do suggest looking at the Meyer's books about how to write better/cleaner code. A fair number of the suggestions apply to your everyday core language features which can give you a better foundation of solid coding practices before advancing. Key items like using typedefs for complicated types, const's instead of magic numbers and other items will help you both when using the language in a C manner and later when you jump into OO.

Anyway, just to reiterate it, don't use new features of the language to start with, just port your Pascal to C++ to learn the new language first and you should be OK.

I got your point. That is what I was thinking on doing first. Relearn the fundomentals again but this time in C++ and aply them. Then moving on the object orientation and more advanced things.

For the books there are tons of them for me to choose.

But what I hear is that many books try to learn you C++ the C way which is bad... Is that true?

Also that the book should be updated in C++11. Those are my only two concerns. And I cant recognise if a book has them easily. :/

The books I found so far:

Jumping into C++ - this books looks fully updated to C++11 (it came out 2013 it has to be tongue.png )

C++ Primer Plus (6th edition)

C++ Without Fear

C++ Programming in Easy Steps

If anyone has any suggestions please post them. biggrin.png

I switched from java to C++ with the help of http://www.cplusplus.com/doc/tutorial/ .

Why not take a look there first ? Personally I feel that you should approach C++ without any prior knowledge and learn it like how you learnt your first language. I had a lot of confusion initially when i coded in C++ and use Java mindset to approach the language.

Check out my blog at zwodahs.github.io and zwodahs.itch.io/


just don't expect (and don't try immediately) to use templates, classes etc, treat C++ as C to start with

I'd rephrase that first part as "don't expect to immediately write templates, classes, etc".

Someone new to C++ should not treat it as C. They should not use pointers, they should not use new or delete, they should use std::vector rather than arrays, and they should use std::string rather than arrays of chars. This is both easier and represents better C++ style. The best C++ beginners' books like the old "Accelerated C++" and the not-quite-as-old "Programming: Principles and Practice" do not even mention that the C-style options exist until halfway into the book, at which point they also discuss the circumstances under which you might have a reason to use those things.

(I'm not familiar with newer books, and the two I mention aren't updated for C++11. Then again, 100% of what you might find in a beginners' C++98 book is also valid C++11, and it's easy to just read up on the key C++11 features separately and start using them.)

I'd definitely go with a book that covers modern C++11 -- it's easier to pick up and you're going to become more productive in a shorter amount of time.

Let's think of a simple task -- storing a collection of names and printing them out.

Compare C++11


std::vector<std::string> names {"John", "Alice", "Bob"};
for (const auto & name : names) std::cout << name << '\n';

with C++98/03


std::vector<std::string> names(3);
names[0] = "John";
names[1] = "Alice";
names[2] = "Bob";
for (std::size_t i = 0; i != names.size(); ++i) std::cout << names[i] << '\n';

and with C


// and you'd better understand why these are (and have to be) immutable!
const char * names[3]; // note: fixed size
names[0] = "John";
names[1] = "Alice";
names[2] = "Bob";
for (size_t i = 0; i != sizeof(names)/sizeof(names[0]); ++i) printf ("%s\n", names[i]);

This is actually even "cheating" to the C's advantage -- i.e., the C version is less featured than the C++ versions -- you can't change the names and you can't change the size of the collection.

Right now IMO "C++ Primer, 5th Edition" by Stanley B. Lippman, Josée LaJoie, Barbara E. Moo is the best C++11 book on the market, so I'd go with that:
http://www.informit.com/store/c-plus-plus-primer-9780321714114

I'd definitely NOT recommend "C++ Primer Plus" by Prata, since it uses the evil (and obsolete) approach of starting with C -- in order words, you'll waste lots of time on useless cruft that won't help you in starting gamedev in C++.
(Sure, you'll need some of the C stuff later, say, if you're going to write your own engine and need interoperability on the C API level -- and that's why it's actually brilliantly covered in the book I recommend -- it's just done in the right order).


just don't expect (and don't try immediately) to use templates, classes etc, treat C++ as C to start with

I'd rephrase that first part as "don't expect to immediately write templates, classes, etc".

Someone new to C++ should not treat it as C. They should not use pointers, they should not use new or delete, they should use std::vector rather than arrays, and they should use std::string rather than arrays of chars. This is both easier and represents better C++ style. The best C++ beginners' books like the old "Accelerated C++" and the not-quite-as-old "Programming: Principles and Practice" do not even mention that the C-style options exist until halfway into the book, at which point they also discuss the circumstances under which you might have a reason to use those things.

(I'm not familiar with newer books, and the two I mention aren't updated for C++11. Then again, 100% of what you might find in a beginners' C++98 book is also valid C++11, and it's easy to just read up on the key C++11 features separately and start using them.)

Ah yes, thanks for the correction, I agree they should use stl aggressively but I disagree on the pointers bit. It is my belief that any C/C++ programmer should learn and understand pointers completely fairly early for a number of reasons. The primary reason is that once you get a crash down in a template, nearly your only hope of figuring out what is going on quite often relies on understanding pointers, how they work and what they "should" have been doing/pointing to when you got the crash. The second reason is that pointers are often the only real solution to certain problems when designing algorithm's, without a sound understanding you limit yourself greatly by expecting to be able to fit everything into some existing concept of stl.

Others may disagree with this thinking, but with few exceptions, I expect anyone doing C++ to understand the basis on which it is built. That most definitely means a solid understanding and ability to use pointers since everything is built on top of them at some point.

Matt-D

From what I have seen in the reviews C++ Primer is for intermidiate to advanced programmers. As I said previously mentioned I know only the fundementals of programming. Will I have a problem understanding this book?

From what I saw it does not have exercises which are very important for me to aply my knownledge.

Yrjö P

This did have exercices which is something that I like laugh.png . I might consider buying it, if I dont find anything newer updated on C++11.

Thank you for your recomendations. If anyone else has anything else to recommend me plz post it. smile.png

I switched from java to C++ with the help of http://www.cplusplus.com/doc/tutorial/ .

Why not take a look there first ? Personally I feel that you should approach C++ without any prior knowledge and learn it like how you learnt your first language. I had a lot of confusion initially when i coded in C++ and use Java mindset to approach the language.

That's because you switched from a managed language to a non managed language with Pascal this issue doesn't exist as Pascal is a non managed language as well.

It's more a syntax change rather then a complete different way of thinking about memory like in your case.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

Matt-D

From what I have seen in the reviews C++ Primer is for intermidiate to advanced programmers. As I said previously mentioned I know only the fundementals of programming. Will I have a problem understanding this book?

From what I saw it does not have exercises which are very important for me to aply my knownledge.

It means it's not for the case when C++ is the first programming language you've ever learned (to the point where you can't distinguish basic terms, like not able to tell the difference between a loop and a variable -- but if it were so, then PPP would be your only choice (DEFINITELY not Prata's book), and that's not updated to C++11, yet).

Since you've already programmed before, I don't think you have anything to fear. To be frank, it all depends on how well & fast you learn, but you can actually check that yourself (which I'd recommend to do for the other books regardless) -- if you can visit a bookstore that has it or (perhaps more realistic in today's day and age) use Amazon's preview feature (just checked on the US and the UK versions, both seem to work), try to skim through Chapter 1 and see if you can solve the exercises after you read each section. If you can, I don't think you'll have any problems.

It definitely has lots of exercises! Already Chapter 1 has 25 of them (although mostly short), so I think you must have seen another book?

This topic is closed to new replies.

Advertisement