Steve Obbayi,
Tel: +1 202 470 0575
Just sharing another thought from the programming world.
Lattely I've been forced to look into assembly programming. And with
awe and surprise I was struck! I came to appreciate the processor and what
it goes through.
More importantly I came to appreciate the connection of what happens
in the processor and what is stored in memory. I was especially struck
with the hoops the processor has to go through in order to fetch data from
data structures in memory which are as a result of high level programming
language features.
I will take a simple case of data alignment. Those in the Java world
are probably in a worse of case because they cannot choose the alignment
for data allocated in memory (or may be Java does it for simple
cases). The processor loves when the memory address of the data it
fetches is aligned to a memory address value that is a multiple of the
size of the data type. For example an integer is 4 bytes in size therefore
an interger data should be in a memory address value that's a multiple of
4. For data structures then the alignment is according to the size of the
data structure and this is where a high level programming language might
screw up. Due to inheritance and polymophism a virtual table for function
mapping is created in memory and the programmer has no control of that
therefore the class data structure might not be aligned.
High level languages seem to be created for the purpose of making
modelling of real world concepts easier for the programmer, thus OOP. They
seem to ignore the other world, the processor world. However compilers
attempt to optimize the code for the processor but not always archieving
the optimizations.
Above is just a simple case. It's not completely explained but it
introduces the idea. It probably won't make sense to someone who doesn't
know C++ and processor stuff but atleast it's information for those
willing to go under the hood!
This doesn't matter for applications that are not concerned about
performance.
O_O.
|