Inside Java : Java myths – fact versus fiction

Posted on Jan 29, 2011 by celax

There are so many myths about . This month, I’ll look at some of the more persistent ones, and try to dispel any doubt.

Fiction :
Applets can read your hard-drive, and delete files

Fact :
Any attempt by an applet to access local files will throw a SecurityException. If uncaught, the applet will crash, but no file access will occur.

The only exception to this rule is for digitally signed applets, which may be granted additional privileges. Your browser will display a dialog box, asking you if you want to accept the identity of the applet author. Choose no if unsure, and you’ll always be safe.

Fiction :
requires a web browser. only runs in a web browser.

Fact :
code comes in many forms. The most familiar to users is the applet, which runs inside a web browser. However, this is only the tip of the iceberg.

applications can be run just like normal programs. By installing a JVM from vendors like Sun or Microsoft, you gain the ability to run programs. It’s just like normal programs, such as Microsoft Word.

servlets run inside a web server. Servlets are a replacement for CGI scripts, and Active Server Pages (ASP). Servlets are actually really fast, and can be more efficient than CGI scripts.

Fiction :
is a hundred times slower than C, so you shouldn’t ever use it for “serious” programming.

Fact :Fiction :
The original Virtual Machines were slow, so slow that a comparable C application was about twenty times faster. The gap between C/C++ and is growing smaller though, thanks to better designed JVMs, and Just-In-Time (JIT) compilers that convert bytecode to native machine code at runtime.

Much of the cause for speed concerns is actually over applet loading – large applets take a long time to load initially. Thankfully, applications and servlets are not subject to such slow loading times.

Fiction :
There’s no point learning any language other than – it will dominate the software industry and put C++ programmers out of work.

Fact :
There are many languages suited to very narrow and specific tasks (such as artificial intelligence) that will never overcome. While it is true that has had phenomenal growth, and significantly eroded the role of C++, it still has a long way to go. excels in portability and Internet support – but C++ still offers better performance and the ability to interact with the operating system.

Fiction :
Applets are inherently unreliable. The differences between Netscape and Internet Explorer make it impossible to write stable applets.

Fact :
The problems with the behavior of applets running under browsers is due to the different JVMs – between browsers and browser versions. These differences can be frustrating for developers and users. There are often workarounds though, and applets should always be tested with a variety of browsers.

The optimal solution is to use a single JVM, which will be used across all browsers. Sound like fantasy? Sun Microsystems, the creators of , have come up with the Plug-in. The Plug-in bypasses the browser’s JVM, and uses its own. This means that users with the plug-in installed can always rely on uniform performance, regardless of which browser they use. For more information, see the Plug-in page.

Summary

actually holds a lot more potential than many people realize. It’s more than just applets – software can run inside a web server, or standalone. However, isn’t the only programming language around, and it’s wise to learn at least the basics of a language like C++, Visual Basic, or Delphi. applets are secure, and won’t delete your hard drive. And if you find that applets aren’t working properly in one browser but do in another, consider using the Plug-in.

By David Reilly