Bytecode is computer object code that an interpreter converts into binary machine code so it can be read by a computer's hardware processor. The interpreter is typically implemented as a virtual machine (VM) that translates the bytecode for the target platform. The machine code consists of a set of instructions that the processor understands. Show
Many computer languages, such as C and C++, require a separate compiler for a specific computer platform. That is, a separate compiler is needed for each combination of operating system (OS) and hardware architecture. For example, Microsoft Windows and Intel's microprocessors represent one platform, and macOS and the Apple M-series chips represent another. With bytecode, the source code must be compiled only once. The platform-specific interpreter then converts it to machine code that can be executed by the OS and central processing unit, or CPU. How does bytecode work in application delivery?The creation and execution of bytecode is often part of an app delivery process. That process begins with creating a program's source code using the following three steps:
What is the advantage of bytecode?Bytecode eliminates the need to recompile source code for each target platform. Although the interpreters differ between platforms, the application's bytecode does not. This approach lets each system interpret the same bytecode files. The bytecode itself is in a binary format that consists of constants, references and numeric codes. The Java virtual machine interprets bytecode and converts it to machine language that is platform-specific.An example of bytecodeOne of the most common examples of bytecode in action is the Java programming language. When an application is written in Java, the Java compiler converts the source code to bytecode, outputting the bytecode to a CLASS file. The CLASS file is then read and processed by a Java virtual machine (JVM) running on a target system. The JVM, which is part of the Java Runtime Environment, interprets the bytecode and converts it to machine language specific to the intended platform. The JVM interpreter usually processes the bytecode instructions one instruction at a time, but a JVM can also support a just-in-time compiler. These compilers can process the bytecode more efficiently, which helps improve application performance. Programming languages that use bytecodeThe Lisp programming language, once commonly used for artificial intelligence applications, is an earlier language that uses bytecode as an intermediary step. Other languages that use bytecode or a similar approach include the following:
Learn more about Java and why it was designed to be platform-independent. This was last updated in June 2022 Continue Reading About bytecode
Related Termsapplication programming interface (API)An application programming interface (API) is code that enables two software programs to communicate. See complete definitionHofstadter's lawHofstadter's law states that a project always takes longer than expected, even when the law is taken into account. See complete definitionhotfixA hotfix is code -- sometimes called a patch -- that fixes a bug in a product. See complete definitionWord of the Day customer engagementCustomer engagement is the means by which a company creates a relationship with its customer base to foster brand loyalty and awareness. How does Java code translate to machine code?Rather than make you go write machine code, we use a program called a compiler. A compiler translated code written in one language to that written in another language. Thus, a compiler converts Java programs to machine code, which can then be run on the computer.
Which of the following makes Java a platform independent language?Java is platform-independent because it uses a virtual machine. The Java programming language and all APIs are compiled into bytecodes. Bytecodes are effectively platform-independent. The virtual machine takes care of the differences between the bytecodes for the different platforms.
What is JVM compiler or interpreter?JVM is Java Virtual Machine -- Runs/ Interprets/ translates Bytecode into Native Machine Code. JIT is Just In Time Compiler -- Compiles the given bytecode instruction sequence to machine code at runtime before executing it natively. It's main purpose is to do heavy optimizations in performance.
Which of the following is a program that translates an entire computer programming code into machine language before the program will run?A compiler is a special program that translates a programming language's source code into machine code, bytecode or another programming language. The source code is typically written in a high-level, human-readable language such as Java or C++.
|