📄 006-008.html
字号:
<HTML>
<HEAD>
<META name=vsisbn content="1558515682"><META name=vstitle content="Java Digital Signal Processing"><META name=vsauthor content="Douglas A. Lyon"><META name=vsimprint content="M&T Books"><META name=vspublisher content="IDG Books Worldwide, Inc."><META name=vspubdate content="11/01/97"><META name=vscategory content="Web and Software Development: Programming, Scripting, and Markup Languages: Java"><TITLE>Java Digital Signal Processing:Java and Its Promise</TITLE>
<!-- HEADER --><STYLE type="text/css"> <!-- A:hover { color : Red; } --></STYLE><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<!--ISBN=1558515682//-->
<!--TITLE=Java Digital Signal Processing//-->
<!--AUTHOR=Douglas A. Lyon//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=1//-->
<!--PAGES=006-008//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="003-006.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="008-010.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading5"></A><FONT COLOR="#000077">The Good</FONT></H4>
<P>In this section we describe the good points of Java. Sometimes a good point about a language is also a bad point. For example, garbage collection is good, because it permits the programmer to forget about memory management during a programming task. Garbage collection simplifies design and eliminates a source of errors. Garbage collection is also bad, because it consumes system resources and could make Java unsuitable for low-level embedded control, a task for which it was intended.
</P>
<P><FONT SIZE="+1"><B>Java Is a Strongly Typed Language</B></FONT></P>
<P>Java is a strongly typed language. All class names are treated as types and are used to check any reference to a class when passed as an argument to a method. Most modern languages have this feature, although the old-style C avoids it.
</P>
<P><FONT SIZE="+1"><B>Java Is Small</B></FONT></P>
<P>Java is based on a small byte code interpreter. Including the self-contained microkernel, the byte code interpreter plus supporting classes is 215KB. This is a remarkable achievement. It means that byte code interpreters can reside on small ROMs and can give microcontrollers a means of running Java programs.
</P>
<P><FONT SIZE="+1"><B>Java Is Portable</B></FONT></P>
<P>Java is a multi-platform language. Java’s trademark is “Write Once, Run Anywhere.” Because there is only one virtual machine specification, Java offers a standard, uniform programming interface to applets and applications on any hardware. The Java platform is therefore ideal for the Internet, where a program should be capable of running on any computer in the world. When you compile Java source, you obtain byte code. Byte code is output by the Java compiler and forms instructions to a Java virtual machine. Java is a portable language in that it can run on any hardware on which the Java virtual machine can run. Byte code is stored in a <I>class</I> file, that is downloaded to a Java virtual machine that contains a byte code interpreter. This concept is like the Pascal P-code of 20 years ago (which required a P-machine to execute the P-code) [Bowles]. When we speak of Java as a multiplatform language, we mean that it will run wherever there is an implementation of a Java virtual machine. Figure 1.3 shows the relationship between the Java program and the hardware.</P>
<P><A NAME="Fig3"></A><A HREF="javascript:displayWindow('images/01-03.jpg',449,446 )"><IMG SRC="images/01-03t.jpg"></A>
<BR><A HREF="javascript:displayWindow('images/01-03.jpg',449,446)"><FONT COLOR="#000077"><B>Figure 1.3</B></FONT></A> A sketch of the Java model.</P>
<P>The multiplatform nature of Java is one of its strongest selling points. It can have a profound impact on how we evaluate computing resources. For the first time, we can benchmark precompiled code on a wide variety of platforms, ignoring compiler optimization for a specific machine. If a Java virtual machine is optimized for the hardware on which it runs, we can obtain a good measure of the machine’s relative speed when running Java. Optimizing a Java virtual machine for specific hardware, however, is not an easy task. At present, for example, there are no Java virtual machines optimized for multiprocessor systems [Oaks et al.]. Thus, a threaded Java program cannot take advantage of the existence of more than one CPU. When this situation changes, Java will be a portable concurrent programming language.
</P>
<P><FONT SIZE="+1"><B>Java Is Object-Oriented</B></FONT></P>
<P>Java is an object-oriented programming language. In an object-oriented paradigm, an instance of an object contains data as well as the algorithms needed to manipulate the data. In contrast, non-object-oriented programming languages pass data as arguments to procedures. Unlike Pascal, C, FORTRAN, or C++, Java has no functions. In Java, all <I>methods</I> reside in <I>classes</I>. C++ is a language with object-oriented extensions. This means that non-object-oriented programs can be written in C++, something that is generally not true in Java.</P>
<P><FONT SIZE="+1"><B>Java Has No Pointers</B></FONT></P>
<P>Java is more crash-proof than C, C++, and Pascal—a very good feature indeed. One reason is that Java does not provide a mechanism for manipulating pointers directly. Thus, there is no way for the programmer to obtain a memory address. Further, there is no pointer arithmetic and there are no pointer operations. Java eliminates the possibility of overwriting memory and corrupting data.
</P>
<P>In C or C++ you can dereference a NULL pointer using</P>
<!-- CODE SNIP //-->
<PRE>
*ptr
</PRE>
<!-- END CODE SNIP //-->
<P>When <I>ptr</I> is NULL, this code causes a segmentation fault error on UNIX or an immediate crash on some other machines. Sometimes pointers in C or C++ are pointing to illegal locations in memory. Accessing these locations can also cause a crash. This type of error is called a <I>dangling reference</I>. Another type of error, a <I>memory leak</I>, is created when data that has been discarded is not reclaimed with a <I>delete</I> statement. This can create an out-of-memory error that will crash the program (or computer) if it is not checked [Spuler].</P>
<P>There are many ways in which incorrect pointer use can crash a computer or program. We don’t have enough space to list them all. We can be thankful that Java has no pointers.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="003-006.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="008-010.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<hr width="90%" size="1" noshade><div align="center"><font face="Verdana,sans-serif" size="1">Copyright © <a href="/reference/idgbooks00001.html">IDG Books Worldwide, Inc.</a></font></div>
<!-- all of the reference materials (books) have the footer and subfoot reveresed --><!-- reference_subfoot = footer --><!-- reference_footer = subfoot --></BODY></HTML><!-- END FOOTER -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -