⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 014-017.html

📁 dshfghfhhgsfgfghfhfghgfhfghfgh fg hfg hh ghghf hgf hghg gh fg hg hfg hfh f hg hgfh gkjh kjkh g yj f
💻 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=014-017//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->

<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="012-014.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="017-019.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">The Bad</FONT></H4>
<P>Sometimes Java&#146;s best features are also some of its worst features. For example, garbage collection has both good points (hence its listing in the preceding section) and bad points.
</P>
<P><FONT SIZE="+1"><B>Sometimes Garbage Collection Is a Rotten Business</B></FONT></P>
<P>The drawbacks of garbage collection are as follows:
</P>
<DL>
<DD><B>&#149;</B>&nbsp;&nbsp;The garbage collector can lead to nondeterministic program run times.
<DD><B>&#149;</B>&nbsp;&nbsp;For large systems, garbage collection can use a significant amount of CPU time.
</DL>
<P>For example, during a time-critical interrupt, the Java virtual machine could sense that it is time for garbage collection, resulting in the loss of data, property, or even life. As far as we know, there is no way to turn off garbage collection from within the Java program. Some Java interpreters (such as the Metrowerks <I>javai</I>) have flags that disable asynchronous garbage collection. For example:</P>
<!-- CODE SNIP //-->
<PRE>
     javai -noasyncgc
</PRE>
<!-- END CODE SNIP //-->
<P>Keep in mind, however, that turning off asynchronous garbage collection doesn&#146;t mean you can stop worrying about it. The opposite is true. Turning off garbage collection means that you must invoke it yourself (or run out of memory).
</P>
<P>If you have experience in programming large, garbage-collection-based systems (such as Lisp machines), you know that finding garbage is no easy task. The Lisp machine&#146;s <I>gc-immediate()</I> function, when run, started the garbage collection (just like Java&#146;s <I>System.gc()</I>).</P>
<P>Garbage collection in virtual memory typically causes a condition known as <I>thrashing</I>. Thrashing occurs when virtual memory is accessed nonsequentially. Thrashing causes different parts of the memory to be continually swapped in and out of disk. Keep in mind that RAM access time (measured in nanoseconds) is six orders of magnitude faster than disk access time (measured in milliseconds), so thrashing can cripple even the fastest of machines.</P>
<P><FONT SIZE="+1"><B>Java Is Not a Pure Object-Oriented Language</B></FONT></P>
<P>Java is not a <I>pure</I> object-oriented language. You cannot make an instance of any primative data type. The basic data types in Java are <I>boolean</I>, <I>int</I>, <I>long</I>, <I>float</I>, <I>double</I>, <I>char</I>, and <I>byte</I>. By contrast, in Smalltalk all data types are classes.</P>
<P><FONT SIZE="+1"><B>We Want Our Overloaded Operators!</B></FONT></P>
<P>Java does not permit the creation of overloaded operators. Contrast this with C&#43;&#43;, which allows a programmer to give operators a context-dependent meaning. For example, in C&#43;&#43;, the * operator can take two arrays as arguments and then multiply the arrays together. The Java designers did not appear to trust programmers to use the overloaded operator feature without writing cryptic code.
</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>WARNING:&nbsp;&nbsp;</B>In Java, the &#43; operator is overloaded to concatenate strings. For example:<!-- CODE SNIP //-->
<PRE>
          int x = 2; int y=3; String z = &#147;4&#148;;
          System.out.println( x&#43;z&#43;y );
</PRE>
<!-- END CODE SNIP //-->
<P>This code will treat <I>x, y,</I> and <I>z</I> as string objects and will output the following:</P>
<!-- CODE SNIP //-->
<PRE>
          243
</PRE>
<!-- END CODE SNIP //-->
<P>But the following code will treat <I>x</I> and <I>y</I> as numeric objects, add them, convert the result to a string, and concatenate the string with <I>z</I>.</P>
<!-- CODE SNIP //-->
<PRE>
          int x = 2; int y=3; String z = &#147;4&#148;;
          System.out.println( x&#43;y&#43;z );
</PRE>
<!-- END CODE SNIP //-->
<P>Will output
</P>
<!-- CODE SNIP //-->
<PRE>
          54
</PRE>
<!-- END CODE SNIP //-->
<P>Thus, the overloaded operators have become argument-dependent and have permitted the kind of cryptic code the Java designers wanted to avoid.<HR></FONT>
</BLOCKQUOTE>
</P>
<P><FONT SIZE="+1"><B>The API is Missing Many Features</B></FONT></P>
<P>Java is missing key features from its supporting API. For example, you cannot write to a serial port (even though almost every computer has one). You cannot (as of this writing) output to a printer from within a Java program. The Java language is new, and because features are missing from the API, Java may not be easy to use for some applications.
</P>
<P><FONT SIZE="+1"><B>Java Has No Native Method Support for C&#43;&#43;</B></FONT></P>
<P>You may want to extend the features of the Java API by programming in another language. Unfortunately the choice of language is currently limited to C.
</P>
<P>There is no way, at present, to link between Java and C&#43;&#43;, in part because of the problem of <I>name-space mangling</I>. In C&#43;&#43;, source code function identifiers are mapped into different function names for the linker. This mapping is called name-space mangling. Functions are typically mangled according to their argument type. Different compilers may have different mangling schemes. Because Java has no way to know how functions will be mangled, the functions cannot be invoked.</P>
<P>The Java native language interface is not complete in JDK 1.0.2, but that is changing in JDK 1.1. When it is complete, circumstances are likely to get better.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="012-014.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="017-019.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>

<hr width="90%" size="1" noshade><div align="center"><font face="Verdana,sans-serif" size="1">Copyright &copy; <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 + -