Sunday 9 October 2011

Big endian representation is the reason behind java's platform independency

we all know that java is famous for platform independency , but do you ever think that how a machine or just a software can be a reason for some thing ... so in JVM there is something pretty interesting which create JVM as platform independent language ...

" so please find something in this world which gives you some confidence and proves you as a engineer . "

i tried my best and i am true to 70-80 % but still i am a learner and still i am working  .
now in java  , JVM is every thing so , inside JVM there is a endianship , which is representation of any thing ... but this is a heavy thing to understand  ...

now first understand what is language-text and data 

language-text is like "i love my nature" means  " human is saying that he loves his nature " , there is a meaning of this thing , and please write this text without any sense "i l o v e m y n a t u r e" dont consider the meaning of this text now read it ... will you understand the text ... and my answer is no ...

take another example "|0" understand it 
:- |0 - can be - 10
:- |0 - can be - io (input output)
:- |0 - can be - I/O ( input output devices)

we have three things which are related to |0 now how we differentiate between these three ...
and the answer is , there must be some interpreter which will make sense or will understand it means interpreter which makes a sense that |0 is for io and is for 10 ...

and the same case is also followed in case of java's class file .
now for this we have a compiler or interpreter which makes class file for java program ...
now think in class file ... arrange your class file according to your mind and arrange the data "tushar" in hexadecimal form .
                             tushar --- 0xtu 0xsh 0xar { only for your understanding }
and some another person will arrange this name as
                             tushar --- 0xsh 0xtu 0xar { only for your understanding }

now think when machine will understand this code or when resources are allocated to this data then what will happen ... machine will understand this thing differently and perform those task which are never expected from machine ... now now now the problem is in machine so surely there will be solution ...

so for this you have to create something from where you will get some definite thing which can be easily understandable by any machine because our machine is also is typical type of thing means all follow different things ...

than what type of things they are ...
see what is published or provided to machine is never accepted in the same way ... means we generally add things from left to right but machine accepts those things from right to left ...

now the time is to understand what is endian representation ... 
two types of endian in representation ..
big-endian 
little-endian 

java uses big-endian but why , because java or class file highly depend upon representation 
because JVM heavily depend upon storage and debugging and by endian representaion we provide these two things easily .

but sorry i can only explain .. endian representation because i can not find any thing related to debugger and i can not work for debugging in ma machine .

but please now look at memory storage
use big-endian for representing 0x1234 
0x34 --- will store at 0 address
0x12 --- will store at 1 address 
but why because the higher order bit is stored in base ..

but in little endian 0x1234 
0x12 is stored in 0 address
0x34 is stores in 1 address 

so thats why 123400 and 1234 and 12340000 is equal numbers in little endian 
but in big-endian they all are different 
because big-endian believe in strictness or in restrictness ...

so class file is built from or used big-endian representation ... for strict storage and restrictness of memory .
now JVM who will understand this data ... 
means when ever we will compile our program ... we get a constant thing means that thing is represented by big-endian ... and now any jvm or any machine can understand it ... because jvm is also built from big-endian representation ... 

" so i simple words BIG-ENDIAN representation is the reason behind java's platform independency "

     

No comments: