View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

VMs and Bytecodes

Index of CoWeb Materials Squeak and Java: Comparing VMs and Bytecodes
John Meyer, gth630k

Click on the link you want more info on then, on the page you're taken to, search for the word "bytecode." This should take you directly to the information you're looking for.

Squeak is based Smalltalk-80, and any discussion of Squeak's virutal machine (VM) should begin with the book we use in this class, Squeak: Object-Oriented Design and Multimedia Applications, pp. 9-10. The discussion is brief, but should get you started.

In both Java and Squeak, the source code that is created by the user is translated by a compiler into bytecode. Discussion 5 - Daniel Kitchener The virtual machine, acting as an "interpreter," translates this bytecode into code native to the particular platform. The use of VMs and interpreters is not unique to these two languages. For example, Python and Phantom also use this approach. Discussion 1 - Daniel Kitchener

The primary advantage of such an arrangement is portability. However, having a virtual machine can also facilitate debugging because code on a VM can be tested without having to run the code on the actual device, which can be very important if the device is, say, a satellite. Sum02 Final Exam Review: Virtual Machines Also, one should note that the "advantage" of portability is not always an advantage. If the code will always be run on one type of device, that is, if the hardware is always the same, compiling the source code to native would almost certainly be faster a VM would serve no purpose. Sum00 Final Exam Review: Soccer Moms Communication System

The primary disadvantage of using VM is reduced speed vis-a-vis languages that can be compiled directly to executable code, such as C. Schedule: 2 September 2005 Executing native code is, of course, faster than executing bytecodes for any kind of operation. This disadvantage is particularly acute in applications using intensive 3D graphics: the added layer of the VM can make performance unacceptably slow. Spring 2004 Final Exam Review: Virtual Machines

The main culprit in the relative slowness of VMs is the necessity of converting bytecode to native code and vice-versa. F02 Final Exam Review: Virtual Machines However, while the Squeak VM is generally regarded as begin slower than the Java VM, this is not always the case: Squeak's port of StarLogo runs faster than Java's, primarily because the port was able to create a useful primitive type, something that could not be done under Java. Shaun Duncan

There are different types of VMs, not all of which use bytecodes. For example, tree-based VMs do not use bytecode at all. However, tree-based VMs are much slower than stack-based VMs. Java and Squeak both use stack-based VMs. David Shirley The stack-based approach makes portability simpler than the somewhat similar register-based approach because different platforms have different numbers of registers. S02 Final Exam Review: Virtual Machines

Squeak's VM and Java's VM differ in several important respects. As noted above, both Java and Squeak use stack-based VMs, both execute bytecodes, and both have garbage collection. Summer 2003 Final Exam Review: Virtual Machines However, Java bytecode is executed by a VM in the native environment, whereas Squeak bytecode is executed by a VM within the Squeak environment (which, in turn, exists in the native environment). Discussion 4 - Brandyn Roemer Further, Java bytecodes are typed and have more operands and Java threads are handled in the VM. Summer 2003 Final Exam Review: Virtual Machines Also, Java utilizes bytecode verification as a security measure, which is not done in Squeak. Sp02 Final Exam Review: Language Choices Finally, you can compile Java's VM bytecode to Squeak VM bytecode relatively easily, but the reverse is not true. Sp00 Final Exam Review: Virtual Machines

Links to this Page