> From: Reggie Bautista <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Re: Computer Languages [was: Your Favorite SciFi/Fantasy Movie
Soundtrack?]
> Date: Wednesday, February 26, 2003 7:09 PM
> 
> I wrote:
> > > 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?  :-)

Technically I borrowed it from the C++ compiler output that it spat out.
 
> 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))))))

or

something similar to this:

  00b49 8b 45 f0         mov     eax, DWORD PTR _this$[ebp]
  00b4c 33 c9            xor     ecx, ecx
  00b4e 66 8b 48 22      mov     cx, WORD PTR [eax+34]
  00b52 8b 55 f0         mov     edx, DWORD PTR _this$[ebp]
  00b55 0f bf 42 4a      movsx   eax, WORD PTR [edx+74]
  00b59 03 45 ec         add     eax, DWORD PTR _i$[ebp]
  00b5c 33 d2            xor     edx, edx
  00b5e 8b 55 f0         mov     edx, DWORD PTR _this$[ebp]
  00b61 0f bf 52 4c      movsx   edx, WORD PTR [edx+76]
  00b65 03 c1            add     eax, ecx
  00b67 03 d0            add     edx, eax
  00b69 33 c0            xor     eax, eax
  00b6b 8b 45 f0         mov     eax, DWORD PTR _this$[ebp]
  00b6e 8b 48 08         mov     ecx, DWORD PTR [eax+8]
  00b71 33 c0            xor     eax, eax
  00b73 66 8b 41 02      mov     ax, WORD PTR [ecx+2]
  00b77 83 c0 01         add     eax, 1
  00b7a 0f af d0         imul    edx, eax
  00b7d 8b 4d f0         mov     ecx, DWORD PTR _this$[ebp]
  00b80 33 c0            xor     eax, eax
  00b82 66 8b 41 20      mov     ax, WORD PTR [ecx+32]
  00b86 8b 4d f0         mov     ecx, DWORD PTR _this$[ebp]
  00b89 0f bf 49 4e      movsx   ecx, WORD PTR [ecx+78]
  00b8d 03 c1            add     eax, ecx
  00b8f 8b 4d f0         mov     ecx, DWORD PTR _this$[ebp]
  00b92 0f bf 49 50      movsx   ecx, WORD PTR [ecx+80]
  00b96 03 c1            add     eax, ecx
  00b98 03 55 e0         add     edx, DWORD PTR _j$40474[ebp]
  00b9b 03 c2            add     eax, edx
  00b9d 33 d2            xor     edx, edx
  00b9f 8b 55 f0         mov     edx, DWORD PTR _this$[ebp]
  00ba2 8b 4a 0c         mov     ecx, DWORD PTR [edx+12]
  00ba5 33 d2            xor     edx, edx
  00ba7 8a 14 01         mov     dl, BYTE PTR [ecx+eax]
  00baa 83 ea 01         sub     edx, 1
  00bad 8b 45 f0         mov     eax, DWORD PTR _this$[ebp]
  00bb0 89 90 d8 00 00
        00               mov     DWORD PTR [eax+216], edx

> >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.

That is in NO way _optimised_, which is why I used it as an example. 
Optimized code would probably seem very differernt.  That was a small piece
of code.

> 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.

Java is the spawn of satan, the ultimate evil.

Get a grasp of C.  Learn how pointers work.  Learn it again.  Learn it again.
 Then learn C++.  There are 36 key words in C.  It's not that difficult.

_______________________________________________
http://www.mccmedia.com/mailman/listinfo/brin-l

Reply via email to