【Core Java】【Volume I ~Fundamentals】【Chapter 1】【1.5】【Common Misconceptions about Java】...

Common Misconceptions about Java

We close this chapter with a list of some common misconceptions about Java, along with commentary.

1.5  关于Java的常见误解

在结束本章之前,我们列出了一些关于Java的常见误解,同时给出了解释。

Java is an extension of HTML.
Java is a programming language; HTML is a way to describe the structure of a web page. They have nothing in common except that there are HTML extensions for placing Java applets on a web page.

1)Java是HTML的扩展

Java是一种程序设计语言;HTML是一种描述网页结构的方式。除了用户放置Java applet的HTML扩展之外,两者没有任何共同之处。

I use XML, so I don’t need Java.
Java is a programming language; XML is a way to describe data. You can process XML data with any programming language, but the Java API contains excellent support for  XML processing. In addition, many important third-party XML tools are implemented in Java. See Volume II for more information.

2)使用XML,就不需要Java。

Java是一种程序设计语言;XML是一种描述数据的方式。可以使用任何一种程序设计语言处理XML数据,而Java API对处理XML提供了很好的支持。此外,许多重要的第三方XML工具采用Java编写。有关这方面更加详细的信息请参看卷II.

Java is an easy programming language to learn.
No programming language as powerful as Java is easy. You always have to distinguish between how easy it is to write toy programs and how hard it is to do serious work. Also, consider that only four chapters in this book discuss the Java language. The remaining chapters of both volumes show how to put the language to work, using the Java libraries. The Java libraries contain thousands of classes and interfaces, and tens of thousands of functions. Luckily, you do not need to know every one of them, but you do
need to know surprisingly many to use Java for anything realistic.

3)Java是一种非常容易学习的程序设计语言。

像Java这种功能强大的语言大都不太容易学习。首先,必须将编写玩具式程序的轻松和开发实际项目的艰难区分开来。需要注意的是:本书只用了四章讨论Java语言。在两卷中,其他的章节介绍如何使用Java类库将Java语言应用到实际中去。Java类库包含了数千种类和接口与几万个方法。幸运的是,并不需要知道它们中的每一个,然而,要想Java解决实际问题,还是需要了解不少内容的。

Java will become a universal programming language for all platforms.
This is possible, in theory, and it is certainly the case that every vendor but Microsoft seems to want this to happen. However, many applications, already working perfectly well on desktops, would not work well on other devices or inside a browser. Also, these applications have been written to take advantage of the speed of the processor and the native user interface library and have been ported to all the important platforms anyway. Among these kinds of applications are word processors, photo editors, and web
browsers. They are typically written in C or C++, and we see no benefit to the end user in rewriting them in Java.

4)Java将成为使用于所有平台的通用性编程语言。

从理论上讲,这是完全可能的。的确,除了微软之外的每一个厂商都希望如此。然而,有很多桌面计算机上已经工作良好的应用程序,在其他设备上或浏览器中或许不能正常地工作。同时,在编写这些应用程序时,利用了相应处理器的速度和本地的用户接口库,而且它们已经移植到所有重要的平台上。这类应用程序包括:字处理程序、图片编辑器以及Web浏览器。它们通常是用C或C++编写的,采用Java语言重新编写似乎对最终的用户不会带来什么特别的好处。

Java is just another programming language.
Java is a nice programming language; most programmers prefer it over C, C++, or C#. But there have been hundreds of nice programming languages that never gained widespread popularity, whereas languages with obvious flaws, such as C++ and Visual Basic, have been wildly successful.

Why? The success of a programming language is determined far more by the utility of the support system surrounding it than by the elegance of its syntax. Are there useful, convenient, and standard libraries for the features that you need to implement? Are there tool vendors that build great programming and debugging environments? Does the language and the toolset integrate with the rest of the computing infrastructure? Java is successful because its class libraries let you easily do things that were hard before, such as networking and multithreading. The fact that Java reduces pointer errors  is a bonus and so programmers seem to be more productive with Java, but these factors are not the source of its success.

5)Java只不过是另外一种程序设计语言。

Java是一种很好的程序设计语言,很多程序设计人员喜欢Java胜过C、C++或C#。有上百种好的程序设计语言没有广泛地流行,而带有缺陷的语言,如:C++和Visual Basic却大行其道。

这是为什么呢?程序设计语言的成功更多地取决于其支撑系统的能力,而不是优美的语法。人们主要关注:是否提供了易于实现某些功能的易用、便捷和标准的库?是否拥有强大的程序设计能力与调试工具?语言和工具是否能够与计算机的其他基础结构整合在一起?Java的成功源于其类库能够让人们轻松地完成原本有一定难度的事情。例如:联网和多线程。Java减少了指针错误,因此使用Java编程的效率更高。但这些并不是Java成功的全部原因。

Now that C# is available, Java is obsolete.
C# took many good ideas from Java, such as a clean programming language, a virtual
machine, and garbage collection. But for whatever reasons, C# also left some good stuff
behind, in particular security and platform independence. If you are tied to Windows,
C# makes a lot of sense. But judging by the job ads, Java is still the language of choice
for a majority of developers.

6)现在有了C#,Java过时了

C#借鉴了许多Java好的思想,例如:清晰的语言结构、虚拟机和垃圾收集器。无论怎样,C#还是沿用了一些好的特性,其中最重要的是安全性和平台无关性。如果再能够与Windows捆绑在一起,就更加具有现实意义了。但是,从求职广告判定,Java仍然是大都数开发者选择的语言。

Java is proprietary, and it should therefore be avoided.
Sun Microsystems licenses Java to distributors and end users. Although Sun has ultimate control over Java through the “Java Community Process,” they have involved many other companies in the development of language revisions and the design of new libraries. Source code for the virtual machine and the libraries has always been freely available, but only for inspection, not for modification and redistribution. Up to this point, Java has been “closed source, but playing nice.”
This situation changed dramatically in 2007, when Sun announced that future versions of Java will be available under the General Public License, the same open source license that is used by Linux. It remains to be seen how Sun will manage the governance of Java in the future, but there is no question that the open sourcing of Java has been a very courageous move that will extend the life of Java by many years.

7)Java有专利,应该避免使用。

Sun Microsystems负责将Java的许可发放给销售者以及最终用户。尽管Sun公司通过Java Community Process最终控制着Java,但他们同时与许多其他的公司联手一起进行着语言修订版的开发及新类库的设计。虚拟机和类库的源代码都可以免费获取,但是,只能查阅,不能修改,也不能再发布。至此,Java已经“关闭源代码,但运转良好”。

这种情况在2007年发生了戏剧性的变化,Sun声称Java未来的版本将在General Public License下可用。Linux使用的是同一个开发源代码许可。要看到Sun管理Java未来的支配权还需要一段时间。然而,毋庸置疑,Java开发源代码已经算是一个非常勇敢的举动了,这会让Java的生存期延长很多年。

Java is interpreted, so it is too slow for serious applications.
In the early days of Java, the language was interpreted. Nowadays, except on “micro” platforms such as cell phones, the Java virtual machine uses a just-in-time compiler. The “hot spots” of your code will run just as fast in Java as they would in C++, and in some cases, they will run faster.
Java does have some additional overhead over C++. Virtual machine startup time is slow, and Java GUIs are slower than their native counterparts because they are painted in a platform-independent manner.
People have complained for years that Java applications are too slow. However, today’s computers are much faster than they were when these complaints started. A slow Java program will still run quite a bit better than those blazingly fast C++ programs did a few years ago. At this point, these complaints sound like sour grapes, and some detractors have instead started to complain that Java user interfaces are ugly rather than slow.

8)Java是解释型的,因此对于关键的应用程序速度太慢了。

早期的Java是解释型的。现在除了像手机这样的“微型”平台之外,Java虚拟机使用了即时编译器,因此采用Java编写的“热点”代码其运行速度与C++相差无几。

Java有一些C++没有的额外开销。虚拟机的启动时间要慢一些,并且Java GUI要比本地的GUI慢一些,这是因为它们采用了与平台无关的绘图方式。

对于Java比C++慢,人们已经抱怨很多年了。但是,今天的计算机速度远比人们发出抱怨的时候快了很多。一个较慢的Java程序与几年前相当快的C++程序相比还要快一些。就着一点来说,那些抱怨听起来有点像狐狸抱怨葡萄酸,有些人已经转过来攻击Java用户界面不够漂亮而不再攻击速度慢了。

All Java programs run inside a web page.
All Java applets run inside a web browser. That is the definition of an applet—a Java program running inside a browser. But most Java programs are stand-alone applications that run outside of a web browser. In fact, many Java programs run on web servers and produce the code for web pages.
Most of the programs in this book are stand-alone programs. Sure, applets can be fun. But stand-alone Java programs are more important and more useful in practice.

9)所有的Java程序都是在网页中运行的。

所有的Java applet都是在网页浏览器中运行的。这也恰恰是applet的定义,即一种在网页中运行的Java程序。然而,大多数Java程序是运行在Web浏览器之外的独立应用程序。实际上,很多Java程序都是Web服务器上运行并生成用于网页的代码。

本书的大多数程序都是独立的应用程序。诚然applet的确有趣,但是独立的Java程序在实际中更重要、更有用。

Java programs are a major security risk.
In the early days of Java, there were some well-publicized reports of failures in the Java security system. Most failures were in the implementation of Java in a specific browser. Researchers viewed it as a challenge to try to find chinks in the Java armor and to defy the strength and sophistication of the applet security model. The technical failures that they found have all been quickly corrected, and to our knowledge, no actual systems were ever compromised. To keep this in perspective, consider the literally millions of virus attacks in Windows executable files and Word macros that cause real grief but surprisingly little criticism of the weaknesses of the attacked platform. Also, the ActiveX mechanism in Internet Explorer would be a fertile ground for abuse, but it is so boringly obvious how to circumvent it that few researchers have bothered to publicize their findings.
Some system administrators have even deactivated Java in company browsers, while continuing to permit their users to download executable files, ActiveX controls, and Word documents. That is pretty ridiculous—currently, the risk of being attacked by hostile Java applets is perhaps comparable to the risk of dying from a plane crash; the risk of being infected by opening Word documents is comparable to the risk of dying while crossing a busy freeway on foot.

10)Java程序是主要的安全风险。

早期的Java,有过关于安全系统失效的报道,曾经一度引起公众哗然。大都数安全问题都存在于Java的特定浏览器中。研究人员将这视为一种挑战,即努力找出Java的漏洞,对applet安全模型的强度和复杂度发起挑战。随后,人们很快就解决了引发问题的所有技术因素。据我们所知,任何实用系统都有安全危机。想想看:毫不夸张地说,有数百万中病毒攻击着Windows的可执行文件和Word宏,这给系统造成了巨大的损害,但却很少有人批评被攻击平台的脆弱。同样,Internet Explorer中Active X机制始终作为被攻击的目标,但由于阻止这种攻击非常简单,所以人们也就懒得将它们公布于众了。

有些系统程序员在公司的浏览器中禁用Java,却允许其用户下载可执行文件、Active X控件和Word文档。这是多么荒唐可笑啊!通常,不友好的Java applet的袭击的风险大约相当于因飞机失事遇难的风险;而打开Word文档遭到袭击的风险则相当于步行横穿繁忙的高速公路遇难的风险。

JavaScript is a simpler version of Java.
JavaScript, a scripting language that can be used inside web pages, was invented by Netscape and originally called LiveScript. JavaScript has a syntax that is reminiscent of Java, but otherwise there are no relationships (except for the name, of course). A subset of JavaScript is standardized as ECMA-262. JavaScript is more tightly integrated with browsers than Java applets are. In particular, a JavaScript program can modify the document that is being displayed, whereas an applet can only control the appearance of a limited area.

11)JavaScript是Java的简易版。

JavaScript是一种在网页中使用的脚本语言,它是有Netscape发明的,原来的名字叫做LiveScript。JavaScript的语法类似Java,除此之外,两者无任何关系。当然,名字有些相像。JavaScript的一个子集已经标准化为ECMA-262.与Java applet相比,JavaScript更紧密地与浏览器集成在一起。特别是JavaScript程序可以修改正在现实的文档,而applet只能在有限的区域内控制外观。

With Java, I can replace my computer with a $500 “Internet appliance.”
When Java was first released, some people bet big that this was going to happen. Ever since the first edition of this book, we have believed it is absurd to think that home users are going to give up a powerful and convenient desktop for a limited machine with no local storage. We found the Java-powered network computer a plausible option for a “zero administration initiative” to cut the costs of computer ownership in a business, but even that has not happened in a big way.
On the other hand, Java has become widely distributed on cell phones. We must confess that we haven’t yet seen a must-have Java application running on cell phones, but the usual fare of games and screen savers seems to be selling well in many markets.

12)使用Java可以用价值500美元的Internet设备取代电脑。

当Java刚刚发布的时候,一些人打赌:肯定会有这样的好事情发生。从本书的第1版开始,我们就已经认定“家庭用户将会放弃功能强大且便利的桌面系统,而使用没有本地存储的网络设备”是一种荒谬的想法。我们发现基于Java的网络计算机,对利用“零管理”降低计算机所有者得商业成本是一种很好的选择。即便如此,这种好事也没有发生。

另一方面,Java已经广泛地用在手机上。我们必须承认还没有看到一个运行在手机上的Java应用程序是必不可少的。但是,常见的游戏和屏幕保护程序在许多市场上销售的很好。

TIP: For answers to common Java questions, turn to one of the Java FAQ (frequently asked
question) lists on the Web—see http://www.apl.jhu.edu/~hall/java/FAQs-and-Tutorials.html.

提示:有关Java常见问题的解答可以通过Java FAQ(Java Frequently Question)列出的网站查找:http://www.apl.jhu.edu/~hall/java/FAQs-and-Tutorials.html.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值