advertisement
javaboutique
Search Tips
Articles  |   Tutorials  |   Reviews  |   Tools  |   by Category  |   by Date  |   by Name  |   Submit  |   Source  |   Forums  |  
javaboutique
Browse DevX


Partners & Affiliates











advertisement

Articles : JavaBoutique's Introduction to Java : Q and A :

Java versus JavaScript

Q

Can you compare/contrast java vs javascript?
I don't know which to tackle first.
I'd like to use it for both web-based and non web stuff.

A

Java is essentially a plug-in that was integrated into the browsers almost as soon as it was released. Java is a programming language that can be used by anyone to code add-on features which can be executed within the browser.

Browsers include Java Virtual Machines to interpret the Java code downloaded from web servers. In fact, the browser became a sort of worldwide desktop upon which application developers could distribute their own full-featured applications with high performance scalable widgets such as trees, grids, tables, image buttons, etc...

Java was originally developed at Sun Microsystems in 1991 to provide a platform-independent programming language and operating system for consumer electronics (TV sets, toasters and VCRs).

In syntax and execution, Java is a lot like a simplified version of C++. ("simplified" should be read in the previous sentence as "an improved"). It is a highly robust, distributed, high performance, object-oriented, multi-threaded language with all of the usual features. As such, it builds upon years of C++ development, taking the good and dispensing with the bad.

As it so happened however, Java did not make it into the consumer electronics market. Instead it wound up in our web browsers.

Java seemed to be a perfect fit for the web. The language itself was extremely small (as it was built to go inside toasters and alarm clocks with tiny amounts of memory). Thus it could quickly be transferred over the web.

Further, Java was platform independent. That is, any computer with a Java Virtual Machine can run a Java program. Programs can be written anywhere and be run anywhere. This is crucial because if a language can not run on any machine, it cannot be used on the web that must service every machine, language, and environment imaginable.

Platform independence works because Java is an interpreted rather than a compiled language. Unlike C or C++ code, when Java is compiled, it is not compiled into platform specific machine code, but into platform-independent byte code. This byte code is distributed over the web and interpreted by a virtual machine (typically built right into a web browser these days) on whichever platform it is being run.

Thus, as a programmer, you need only concern yourself with the generic Java programming language and compile your applications into bytecode on whatever system you are using. You can then be assured that your bytecode will be executed correctly whether your clients are using Macs, Pcs, Unix boxes or anything else.

What's more, Java is a full-featured programming language complete with a complete collection of user interface widgets in its AWT library, networking capabilities, database connectivity, internationalization features, and much, much more.

Though Java was sadly reduced to tickers and bouncing balls for the first few years of its life, now many high quality production applications have been completed and are running happily with java served through web pages.

NOTE: To a certain degree, I also like to think of client-side Active-X components as plug-ins. Active-X technology allows web browsers on Microsoft systems to leverage the vast resource of Windows. Like Java applets, Active-X components can be instantiated within the context of the web browser itself making it appear that the web browser is providing the functionality when in fact the Active-X component is simply piggy-backing off the browser.

Since any COM object in Windows can be an Active-X control, almost every Windows resource can thus be embedded in the browser window. Controls can be as simple as a custom stock ticker or as complex as an application like Microsoft Excel.

Of course, beware that Active-X is a Microsoft-specific technology so it may not ever work on Netscape or on Macintosh.

Exposing the Browser API with Client-side Scripting...

As you might imagine, adding all these add-on features to the web browsers began to cause problems. Specifically, distributing functionality in the form of Active-X controls, plug-ins, or Java applets could mean unacceptable download times for users. In some cases, users would be willing to wait. Specifically, if the applications they required demanded the rich texture provided by plug-in technologies, users would accommodate download times.

However, in other cases, users wanted a less complex solution. Granted, the solution should be more complex than HTML forms, but not necessarily as complex as Java.

Enter JavaScript.

Netscape 2.0 introduced JavaScript (initially LiveScript), a distant cousin of the Java language, as a means for achieving some special effects in the web browser without actually having to resort to a plug-in technology.

NOTE: Soon after the release of JavaScript by Netscape, Microsoft released their own semi-compatible version called JScript in Internet Explorer 3.0. JScript, however eventually lost much of its appeal after Microsoft released VBScript, which leveraged the Visual Basic programming language to do the same thing as JavaScript. VBScript would fast become Microsoft's preferred Web Language however because most developers like to keep their applications cross-browser compatible. VBScript has receded to a large degree onto the server side for ASP, which we will talk about later. Most client-side development is done in JavaScript.

Actually, to tell you the truth, JavaScript is a bit of a misnomer (or a marketing ploy) because though JavaScript is indeed a scripting language (browsers include a JavaScript interpreter), it actually is very different from Java. Whereas Java is a self-contained programming language capable of full featured application development on its own, JavaScript is built as a programming glue that developers can use to tie together other technologies (HTML or the browser itself) within the scope of the web browser. That is, you would rarely say that you had finished work on a JavaScript application, but you might say that you had added some JavaScript functionality to your web page.

JavaScript is not so much about adding new functionality as it is about tweaking existing functionality to make it seem more cool.

The most important thing to understand about JavaScript is that it exposed much of the browser API to developers. Specifically, the browser and many of the widgets inside the browser could be talked to, listened to and controlled.

Developers quickly began to use JavaScript for such purposes as

  • animation
  • accessing the bookmarks and history
  • event handling (like mouse over effects such as when a graphical image button lights up when the mouse crosses over it)
  • form field validation (such as when you make sure the user has entered in data for all the required fields before you let them submit the HTML form to a web server)
  • and the spawning of event dialogs and new windows.

What was nice was that JavaScript was written for the common person and required little programming background to master. Web designers could add a great deal more functionality and bells and whistles to their existing HTML pages without needing to resort to server-side programming like CGI.

JavaScript has gone through several iterations of versioning and though there are still compatibility problems between IE and Netscape, the standard features of the language have been nailed down pretty well.


Selena Sol contributes to the JavaBoutique's Introduction to Java. Selena curently works for Barclays Capital in London, one of the leading global investment banks in Europe and has worked as a software developer for the National Center for Human Genome research, Microline Software, Neuron Data, and Electric Eye in Singapore. Selena is perhaps best-known for creating the Public Domain Web Script Archive (Extropia) and writing several books on Web Programming (Perl, CGI, Java).
Email: selena@extropia.com

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.

 DevX Skillbuilding from IBM developerWorks
 RIA Run Contest: Build Next-Gen Apps in Microsoft Silverlight 2
 Avaya DevConnect Center
 Intel Go Parallel Portal
 Internet.com eBook Library
 Microsoft RIA Development Center
 Destination .NET
XML error: not well-formed (invalid token) at line 53
advertisement
Receive Articles via our XML/RSS feed
Receive Articles via our XML/RSS feed

JavaBytes
Internet Cyclone
This powerful, easy-to-use, internet optimizer is for Windows 95, 98, ME, NT, 2000 and XP. It's designed to automatically optimize your Windows settings, boosting your Internet connection up to 200%.

SaaS Tool Offers Custom Database Development
Microsoft’s Automated Agent: Can We Talk?
Borland Finally Sells CodeGear
Red Hat Heads For The JON 2.0
Out with the Old, in with the New at JavaOne
Trolltech Expands WebKit Footprint
Oracle: Eating its Own Open Source Food
Big Money and Open Source May Not Compute
Open Source Embrace Gives Sun New Fans
NetBeans, OpenSolaris Also in Spotlight at JavaOne

Taming Trees: Building Branching Structures
Clean Up Function Syntax Mess with decltype
Sutter Speaks: The Future of Concurrency
INTEL SCAVENGER HUNT, LENOVO X300 AND APPLE IPOD TOUCH GIVEAWAY (the "Giveaway")
Comparing Multi-Core Processors for Server Virtualization
Intel® Desktop Business Computing Solutions
Intel: What Downturn?
Managing the Evolving Data Center
Implement Drag and Drop in Your Windows Forms Applications
Processing Linked Web Data with XSLT

Advertising Info  |   Member Services  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About



JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: HyperV-The Killer Feature in WinServer ‘08
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Win Server ‘08
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES