interpreter - Why is java bytecode interpreted? -


as far understand java compiles java bytecode, can interpreted machine running java specific cpu. java uses jit interpret bytecode, , know it's gotten fast @ doing so, why doesn't/didn't language designers statically compile down machine instructions once detects particular machine it's running on? bytecode interpreted every single pass through code?

the original design in premise of "compile once run anywhere". every implementer of virtual machine can run bytecodes generated compiler.

in book masterminds programming, james gosling explained:

james: exactly. these days we’re beating c , c++ compilers pretty always. when go dynamic compiler, 2 advantages when compiler’s running right @ last moment. 1 know chipset you’re running on. many times when people compiling piece of c code, have compile run on kind of generic x86 architecture. none of binaries particularly tuned of them. download latest copy of mozilla,and it’ll run on pretty intel architecture cpu. there’s pretty 1 linux binary. it’s pretty generic, , it’s compiled gcc, not c compiler.

when hotspot runs, knows chipset you’re running on. knows how cache works. knows how memory hierarchy works. knows how pipeline interlocks work in cpu. knows instruction set extensions chip has got. optimizes precisely machine you’re on. other half of sees application it’s running. it’s able have statistics know things important. it’s able inline things c compiler never do. kind of stuff gets inlined in java world pretty amazing. tack onto way storage management works modern garbage collectors. modern garbage collector, storage allocation extremely fast.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -