Originally Posted by
rags_to_riches
Your English is far better than many native speakers. You have nothing to fear where that is concerned.
But in every other respect I'm screwed, right? Haha, couldn't resist. Thanks SpellCheck helps though.
Originally Posted by
iMalc
That's a lot you've written there, so expect many of us to only respond to part of your post. You'll no doubt get the answers you're looking for, just spread out over everyone's replies
I expected as much. I just tried to preempt questions as best I can, but I know I come off long-winded most of the time.
Originally Posted by
iMalc
The problem with your code example is that its damn near impossible to reason about the performance of hypothetical stuff in programming.
...
Early on, you won't know the kinds of things that actually make a big difference in execution time anyway.
This makes sense.
Originally Posted by
iMalc
...and the compiler will do its job of sorting out the optimisation side of things.
I... didn't know they do that. But surely they have some sort of limit as to how much they can do, right? (Flows into next reply)
Originally Posted by
Elysia
I want to give you the advice to stop thinking about trivial optimizations in the beginning. Today's computers are blazing fast, and the bottleneck often is not CPU power.
I understand what you are saying, but am I wrong in thinking that cannot be such a blanket statement? What if I'm writing code for circuitry (Embedded systems I think is the right name for it? Not sure). There the processing power is severely limited.
I just thought learning to program the "right" way from the start would make me a better programmer later on. But I understand now that it's more of a case by case thing and that it involves learning how the underlying systems work - something I should leave for later.
But if what you and iMalc say is correct and software takes care of the optimizations, why do we have things like Big-O notation? Is that just for the people that write the optimization software?
Speaking of Big-O notation, may I just ask someone to help me understand this one thing:
with Sum = Sum + 1; as the basic operation and n being unknown, I can agree that in
Code:
int Sum = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++)
for (int k = 1; k <= n; k++)
Sum = Sum + 1;
the growth-rate function is O(N^3).
What I can't agree with is that in the following
Code:
int Sum = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= i; j++)
for (int k = 1; k <= j; k++)
Sum = Sum + 1;
the growth-rate is also O(N^3).
I've tested this every which way. On paper, with outputs to the console at every step and it never agrees with this. Most of the time it's pretty close, but never spot on. Is that it? Is it just an approximation in the same sense that you discard constants in Big-O notation? That at higher numbers, the deviations are inconsequential? If so, this book should have really stated so (It did in the other cases). For those wondering what book, the same one we're taught out of at school. Big-O notation is the very first chapter and thus the very first thing I learned in C++ (Even though it's not language specific).
Originally Posted by
Elkvis
which API? there are as many ways to use an API as there are APIs to use. without knowing which API they were telling you to use, it will be hard to give you advice.
Well, at that time it was the Java API if I remember correctly. I had a run in with one recently when working with QtCreator, as I wanted to fiddle with C++ GUIs (I understand that C++ doesn't have anything 'built in', in order to be cross-platform as I understand it) So I have a specific example from that, but if almost every API is used differently, I'm wondering whether I should just wait to ask at a later date (I don't know if I'm going to stick to Qt). Actually, you know what, there's no such thing as useless knowledge, but I'm going to tack on another question before I get to the example: At what point is a programmer expected to be able to use an/any API?
Example: I was trying to get QInputDialog::getInt() to work inside my main function (You are supposed to call it via a class dedicated to GUI or something as far as I understand). It just wasn't working and I couldn't understand why, I mean I looked for examples on the Net, copy-pasted them (after modifying to fit of course) and they just wouldn't work and gave me a very nondescript error message.
This is what I had at first:
Code:
int number;
number = QInputDialog::getInt(0, "Calculate Primes", "Enter a number between 1 and 500:",1, 1, 500,1, 0, 0);
And this is what fixed it:
Code:
int number;
number = QInputDialog::getInt(0, ("Calculate Primes"), "Enter a number between 1 and 500:",1, 1, 500,1, 0, 0);
Can you perhaps show me what in this API (Qt 4.7: QInputDialog Class Reference) explains to me to use those parentheses? In fact, why did I have to use them?
Originally Posted by
rogster001
...though they do say the brain is most receptive when very young...
That's what I was talking about.
Originally Posted by
rogster001
but that is general information-wise - i dont know if that neccesarialy translates to absorbing soemthing specialised like programming more effectively and imbuing some kind of 'talent' for it.
Originally Posted by
Elkvis
programming is really just a form of engineering and problem solving. if you've been developing your engineering and problem solving skills all your life, the people who have been programming for their whole lives aren't really that far ahead of you.
Originally Posted by
Elysia
So long as you give it your all, you should have no problems whatsoever, I think.
It's good to hear your opinions on this, thanks.
Originally Posted by
iMalc
Regularly participating in a forum such as this one is one way to boost your skills very significantly.
Wouldn't folks get very irate if I posted a question every other day, though? (After of course researching the problem to the best of my abilities beforehand and trying to figure it out myself)
Edit: Bah! I only now notice the Multi-Quote button on the bottom.... I hand-typed all those quotes =/ Oh well, another reminder to be observant.
Also fixed double negative.