> Just out of curiosity -- once these examples are both compiled, will they > take up an equivalent amount of space and/or take an equivalent amount of > time to run?
The Fool replied:
They will create the _same_ machine code.
Thanks. I kind of thought so, but I figured with so much expertise on the list, why not ask? :-)
Me again:
> Or more generally, when programming languages include shorter ways of doing > things that previous languages, how much of that comes from the writers of > the newer languages having a better understanding of how to do things, and > how much comes from shortcuts written into the newer language that make
> coding easier, but make no actual difference after compilation?
The Fool again:
You mean something like this:
#define MB(x,y,z,w,q) MB+((z*(q+1)*(w+1))+(y*(w+1))+x)
#define XXX(x,y,z) ((*(m.MB((x),(y),(z),(h->X),(h->Y)))))
and later in the code just say
a.
XXX(3,14,15);
which is just the same as putting
b.
((*(m.MB+(((z)*((h->Y)+1)*((h->X)+1))+((y)*((h->X)+1))+(x))))))
Which is essentially a calculation for a pointer to specific integer of data in a 3 dimensional array [i.e. Matrix], (they compile to the same code);
Which one do you want to work with hundreds of times in a program, a. or b.?
Actually, I was more looking for the info you gave in your first answer above. I certainly understand and agree that the less you have to type within a given language, the better, and with what little coding I do, I definitely use macros and functions as much as possible. I was just checking to make certain that the same kind of thing done in different languages will generally compile to the same machine code, as you say above, or if any recent compilers had found any shortcuts within machine code itself. You answered that question nicely above.
I haven't done much coding in... I guess it's been at least ten years. I'm just getting back into it now, and have another question for you or anyone else. Assuming that I am going to learn both C++ and Java, which would you recommend learning first? I have previous experience with BASIC, FORTRAN, COBOL, and Pascal, but as I said, it's been a while. I've been toying a little lately with both Java and C++, trying to teach myself, but if I dive full bore gung ho into one first, then the other, what order would you recommend? I have no problems with object-oriented programming and have done some pseudo-code with a friend of mine who is just about to graduate from DeVry, so learning either will really just be about learning the syntax of the language, not about programming concepts in general.
Reggie Bautista
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE* http://join.msn.com/?page=features/junkmail
_______________________________________________ http://www.mccmedia.com/mailman/listinfo/brin-l
