Questions about C++ and programming in general from a newbie
My English isn't so great, so I beg your patience if/when I mess up.
I'm going to preamble a bit (which makes this a preamble to a preamble...), but that's just there so you have something to work off of should you want to tailor your answer(s).
So, I'm 17 and haven't been programming for very long. I took up Computer Science as a subject at my school last year (The earliest you can take it in our school system), before which I haven't really had any contact with programming. Last year, our teacher (Who doesn't know a whole lot about programming, he confessed) had us do Java. This year, he switched us over to C++.
I want to create a database program for a family friend, but figure I need to ask these questions (especially number 2) before asking more specific things.
Now, the questions:
1) Important Background: In an interview somewhere, I heard the person make an analogy somewhere along the lines of "if you want to produce musical geniuses, you have to start them off at an early age". I believe it was an interview with the person behind the Raspberry Pi and the analogy was to getting kids programming with it from an early age, just like they used to with the BBC microcomputer, etc. Lots of well-known/public figures in the field of programming have stated that they started at an early age (6-9).
Now, the question - and this is going to be really abstract:
Do you think, in your opinion as an accomplished programmer, that someone that does not have that background (like me) is at a fundamental disadvantage? And I don't mean in terms of just a head-start (Which can be caught up to with hard work). I mean that experience of tinkering at such a crucial period of development having such a profound affect on the way you think and perceive things that to not have it would be a clear disadvantage? Basically, I'm asking whether I will always be a "second class" programmer if I'm only starting this "late".
2) Not so important background: As I mentioned before, my teacher doesn't know all that much about programming. He's learning along with us as we go through a book he has. He's let me have a look at the book, and I've now read most of it.
Last year, when we were still doing Java, I had a question about an error I was getting on a side project I was working on. The teacher couldn't help and I was forced to look on the internet. Google'ing it didn't help and I eventually made up my mind to make a forum post about it. Basically everyone there screamed at me for not using the API - something I didn't even know existed. I mean, the teacher didn't know about it and it wasn't in any of his books. I gave up on that idea and eventually we tracked down a developer from a local company willing to help - but that's besides the point. Some time after that I made it a point to try and find out what an API is and how to use it. I've had success on the first, but practically none on the second.
So, my question is: How exactly do you use APIs? I've Google'd it many times, but never found anything that seems to help. Is there some sort of trick to reading/understanding them, or am I for a lack of a better word just dumb? Do I need to stare at it for long periods of time for it to make sense? If this question is a little too vague, I can probably provide an example of the difficulties I've been having.
3) Something code specific! Do function calls eat a lot of processing power? I'm trying to write the most efficient code I possibly can (I've read/heard most professionals say that in most cases doing that on the job is just unrealistic, because of time/budget constraints). My hope is that if I write it efficiently from the get-go, it won't need so many 'revisions' (don't know if that's the right word) to get it to the best it can be.
For example, in terms of execution speed, which is better:
Code:
int aValue = aFunctionCall();
if (aValue == 1) {
// Something happens
}
// Some other code
if (aValue == 1) {
// Something happens again
}
or
Code:
if (aFunctionCall() == 1) {
// Something happens
}
// Some other code
if (aFunctionCall() == 1) {
// Something happens again
}
Also, does the first one use more memory (Because it stores an extra variable)? I realize in these example the differences would be so miniscule as to be almost irrelevant, but I think you get the idea.
If you read everything; thank you for taking the time. And a preemptive thank you to anyone who replies. I'm sorry if this post is somehow inappropriate (insomuch that it doesn't strictly focus on code).
Fizzgig
Edit: Changed the code snippets to better reflect what I was asking.