在线图书管理系统外文文献原文及译文内容摘要:

Java puts a lot of emphasis on early checking for possible problems, later dynamic (runtime) checking, and eliminating situations that are errorprone. The single biggest difference between Java and C/C++ is that Java has a pointer model that eliminates the possibility of overwriting memory and corrupting data. This feature is also very useful. The Java piler detects many problems that, in other languages, would show up only at runtime. As for the second point, anyone who has spent hours chasing memory corruption caused by a pointer bug will be very happy with this feature of Java. If you are ing from a language like Visual Basic that doesn’t explicitly use pointers, you are probably wondering why this is so important. C programmers are not so lucky. They need pointers to access strings, arrays, objects, and even files. In Visual Basic, you do not use pointers for any of these entities, nor do you need to worry about memory allocation for them. On the other hand, many data structures are difficult to implement in a pointerless language. Java gives you the best of both worlds. You do not need point ers for everyday constructs like strings and arrays. You have the power of pointers if you need it, for example, for linked lists. And you always have plete safety, because you can never access a bad pointer, make memory allocation errors, or have to protect against memory leaking away. Architecture Neutral The piler generates an architectureneutral object file format—the piled code is executable on many processors, given the presence of the Java runtime sys tem. The Java piler does this by generating bytecode instructions which have nothing to do with a particular puter architecture. Rather, they are designed to be both easy to interpret on any machine and easily translated into native machine code on the fly. This is not a new idea. More than 30 years ago, both Niklaus Wirth’s original implemen tation of Pascal and the UCSD Pascal system used the same technique. Of course, interpreting bytecodes is necessarily slower than running machine instruc tions at full speed, so it isn’t clear that this is even a good idea. However, virtual machines have the option of translating the most frequently executed bytecode sequences into machine code, a process called justintime pilation. This strategy has proven so effective that even Microsoft’s .NET platform relies on a virtual machine. The virtual machine has other advantages. It increases security because the virtual machine can check the behavior of instruction sequences. Some programs even produce bytecodes on the fly, dynamically enhancing the capabilities of a running program. Portable Unlike C and C++, there are no “implementationdependent” aspects of the specifi cation. The sizes of the primitive data types are specified, as is the behavior of arith metic on them. For example, an int in Java is always a 32bit integer. In C/C++, int can mean a 16bit integer, a 32bit integer, or any other size that the piler vendor likes. The only restriction is that the int type must have at least as many bytes as a short int and cannot have more bytes than a long int. Having a fixed size for number types eliminates a major porting headache. Binary data is stored an。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。