The complexity of compilation depends largely on the semantic gap between the source language and the target language and the level of optimization you want to apply while bridging this gap.įor example, compiling Java source code to JVM byte code is relatively straight forward, since there is a core subset of Java that maps pretty much directly to a subset of JVM byte code. Byte code compilers are simpler in practice because they shovel many complexities onto the VM that machine code compilers take on themselves. However, the complexity of linking is made up for at run-time when many linking concerns are handled by the VM (see my note below).īyte code compilers tend not to optimize as much because the VM can do this better on the fly (JIT compilers are a fairly standard addition to VMs nowadays).įrom this I conclude that byte code compilers can omit the complexity of most optimizations and all of linking, deferring both of these to the VM runtime. If so, byte code compilation would be slightly simpler. One could split hairs about whether linking is part of compiling in the context of this question. In general, a program with multiple compilation units requires linking when compiling to machine code and generally does not with byte code. There only two real differences between the two. Converting the AST to some form that a machine understands.removing dead code, reorder operations, other optimizations) Optional: process and improve the AST if the language specification allows it (e.g.Converting source to an abstract syntax tree.Scanning, parsing and validating source code.What broad steps have to happen to compile a program? However, on a more practical level, byte code compilers are simpler. If you take a step back and think about your question from this theoretical perspective, the complexity is roughly the same. A compiler is simply a program that takes human-readable 1 text files and translates them into binary instructions for a machine.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |