aliens

Author Topic: Any pointers for learning C++?  (Read 6618 times)

Offline MKSheppard

  • Colonel
  • ****
  • Posts: 249
    • View Profile
Any pointers for learning C++?
« on: August 29, 2013, 07:33:46 am »
Currently, I'm playing around in Microsoft Visual Studio 2012 Express; and I've got a ton of C++ books, some on loan from the library, some bought from used book stores; and there's always the INTERTUBEZ to help me.

Right now, I've managed to make a simple Win32 Console CLI application that does simple area calculations (hey a start is a start), but I was wondering if you guys had any specific recommendations regarding books for learning or any rules of thumb that you've painfully learned.

PS - Yes, I admit the big reason I picked C++ to learn was because OpenXCOM is programmed in it  ;D

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: Any pointers for learning C++?
« Reply #1 on: September 08, 2013, 08:24:56 am »
my advice: dive in. i knew nothing about C++ when i started modding OpenXCom, but had a decent core knowledge of the basics of coding. OpenXCom is designed in such a way that it is actually intuitive, and to some extent instructional in it's design (certain sections aside, don't play with research unless you're feeling brave) and has a lot of handy tips and tricks to discover the more you dig around.

These days i feel confident calling myself a qualified C++ coder, and it's completely due to OpenXCom.

Offline djemon_lda

  • Captain
  • ***
  • Posts: 52
    • View Profile
Re: Any pointers for learning C++?
« Reply #2 on: September 25, 2013, 06:27:12 pm »
@MKSheppard:

take Stroustroup books thinking in c++ volume 1 and 2, read them and tweak the code around them. when you aren't sure about something ASK questions. when you are through with the books, understand mechanisms like dynamic and static polymorphism, templates, STL, are keen to pointers, references, understand the difference between them, understand static, const, be aware when you can and when you can't throw exceptions, when to use which cast operator, what is an interface, what is an abstract class, what is the difference between a struct and a class, when you should overload operators and when you shouldn't, what is the 'this' pointer for, and so on...

the next step is to understand the difference between object oriented programming and object based programming - here all the code I have seen so far is object based.

once you know all this, you know the "language" - meaning the important keywords and some simple features, and have a real chance to ask real questions. this is the right moment to start to dig into the code, make some changes and make a code review with someone really competent.

you will also need to lear a lot about the environment around the language, and know something on a little lower level than what the code gives you.

I highly discourage learning c++ based on the code of openXcom.

another thing is do not learn c++ using CLI, as long as the project doesn't contain interops between the two.

Quote from: Warboy1982
OpenXCom is designed in such a way that it is actually intuitive
nope - as a nice example I can give that reaction and psi attack logic is in the TileEngine class, where it should have never landed, as well as the issue with many places in the code that need to be modiffied in order to introduce a new psi attack type.

Quote from: Warboy1982
These days i feel confident calling myself a qualified C++ coder, and it's completely due to OpenXCom.
utterly brave. far too brave in my opinion.

one of the professors on my university told us very wise words on his lecture once "a coder isn't a person who gets the thing done. its the person, that gets the thing done in the RIGHT way".
« Last Edit: September 25, 2013, 06:41:22 pm by djemon_lda »

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: Any pointers for learning C++?
« Reply #3 on: September 25, 2013, 08:11:04 pm »
@djemon_lda: I don't claim to understand anything about coding, but it appears to me that you are trying to radically change the style of programming in openXcom. I don't know if you are ultimately right, and a more-or-less complete re-design would actually help this project. But I do know that what you are doing right now is claiming that the code is all wrong, that the coding style is inferior to what you do and that the main coders of openXcom are not coders at all. Also, seriously? You are necroing threads just to press your points.

What you are doing isn't helping the code, it isn't helping the others and it certainly isn't helping you. I don't speak for anyone but myself, but to me you sounded annoying before and are starting to sound insulting now. Please change your attitude! If you have improvements for the project, fine, but don't push it.

Offline djemon_lda

  • Captain
  • ***
  • Posts: 52
    • View Profile
Re: Any pointers for learning C++?
« Reply #4 on: September 25, 2013, 10:36:35 pm »
@moriarity:
first of all, I'd like to thank you for your response.

what I've written here is related strictly to the post. the proposed way to learn to code in c++ is inferior, and leads nowhere near the basics that are actually required to call an individual a qualified c++ coder.

Quote
...complete re-design would actually help this project...
please take a re-read of my posts, and you will find yourself wrong on that.

Quote
the main coders of openXcom are not coders at all
a coder is not the same thing as a qualified coder. for example a qualified c++ coder easily handles tons of problems that simply couldn't ever occur in this project, thus which can't be learnt here.

Quote
But I do know that what you are doing right now is claiming that the code is all wrong
you "assume", you do not "know", and please quote anything in this post, or any other of my posts, that proves that statement :)
to add even more: I never said anything like this - the code does approximately what the users want, but its quality is really poor. (approximately, because there are still bugs, I've found some really quickly, tough one of them did not reproduce on other machines, but I still have one or two to post with saves)

and yeah, I can lie as well that the code is perfect quality, and its design is really intuitive if you think this will help out anything. I have never believed in the "don't worry timmy, you didn't lose. you're just the last winner" attitude -THIS does nothing but helps bad things corrupt into worse :)

Quote from: djemon_lda
reaction and psi attack logic is in the TileEngine class
and here I don't think you actually understand what stands behind these words. here's an projection of that situation to real life:

imagine you have a vacuum cleaner, and a blender. now imagine, that in order to use the blender you must bring the vacuum cleaner every time, open its dust container and that deep there's the button that turns the blender on.

now please tell me, how intuitive that is, and how a new user would be able to swiftly start using the blender without a manual :P

answering another point from what you've written:
Quote
complete re-design would actually help this project.
of course it wouldn't help this project, because a complete redesign basically means a rewrite, and it is a widely known fact that the deathrate of projects that get rewritten is tremendous.

Quote
You are necroing threads just to press your points.

I'm not. if you read carefully, you'd notice that I start being cynic when something "fuzzy" appears. I am not tolerant to lies, that is all. AND I really respect truth, such as you expressing your thoughts on my posts.

when I see a sentence "well, we didn't use polymorphism, because <something that makes sense as a justification>" then it's a valid decission that was made thoughtfully, but when I see "well, we didn't use polymorphism, because it doesn't line up with game development" then it's inavoidable, to recieve a proper comment to that.
false things are false, and insisting on them being true means either that someone is wrong, or is intentionally lying.

finally, if you think that speaking the truth is ill tempered, bad attitude or insulting, then please consider your honest words, as the same kind of temper, attitude or tone.

last comment:
learning materials need to be as close to being flawless as possible. there are tons of materials posted as "learning resources" that should be destroyed, because of their low quality - even if you take out all the crap that contains errors (in code samples or in the explanations of topics).

I have actually been teaching programming in java and c++ and managed to make people write their final projects on their own despite they were starting from different programming paradigms at best, so I know how this looks like. Still, I wouldn't call any of the people I've been teaching how to program in a certain language a  decent, or qualified person.

Offline evoron

  • Sergeant
  • **
  • Posts: 12
    • View Profile
Re: Any pointers for learning C++?
« Reply #5 on: June 28, 2014, 06:32:31 am »
If you're just a beginner you should consider Timothy Budd book "An Introduction to Object-Oriented  Programming". Abstract enough to give you feel of OOP, 'cause OOP is about thinking in object way, but not coding in C++. And of course you shouldn't skip Bjarne Stroustrup, because he is creator of C++ and knows the language better than anybody. If you really want to be OOP programmer you should take a look in Grady Booch "Object-Oriented analysis and design with applications" book and UML in general. And you shouldn't really start with Windows and it's WinAPI+DirectX. It is real nightmare, thank God we have SDL and friends. If you ask me, i prefer Linux+Geany+gcc. Or Windows+Geany+mingw at least. But YMMV.