View Single Post
  #1  
Old Wednesday, February 20, 2008
pakfame's Avatar
pakfame pakfame is offline
Member
 
Join Date: Feb 2008
Location: Lahore
Posts: 82
Thanks: 0
Thanked 42 Times in 25 Posts
pakfame is on a distinguished road
Default What is JavaScript & Java

Introduction
JavaScript is a scripting language used in many websites. A scripting language is a language, which is easy and fast to learn. So is this reference. A scripting language is interpreted in run-time. It is not compiled like other languages as C++, C#, VB.NET etc. JavaScript is a client side language and it runs on the client browser. Netscape developed it and because of its simplicity it is one of the most known scripting languages. However JavaScript can be also used on the server-side. JavaScript can be used on all most known browsers. It can be easily used to interact with HTML elements. You can validate text fields, disable buttons, validate forms, or change the background color of your page. All this is possible with JavaScript. Like each programming language, it contains variables, arrays, functions, operators, objects and much more which can be help you to create better scripts for your pages. On the server side you can use JavaScript for example to manage your database entry. JavaScript code can be inserted directly in the HTML or you can place it in a separate file with the .js extension and link the web page with the .js file.

Is JavaScript a lighter version of Java?
Many who haven’t worked before with java or scripting languages think that JavaScript is the same as Java or a lighter version of it. This is not true. Java is a different language developed by Sun Micro Systems. Java is much more complex then JavaScript. In Java you have to declare each variable with the type, in JavaScript you don’t need to do that. All variables are declared when you first time use them. Furthermore in Java you have to declare all variables, functions and classes. In JavaScript you don’t even need to think about these things. Java is compiled to byte codes on the server and the result is send to the client. JavaScript is interpreted on the client side it doesn’t require any compilation.

Usage of JavaScript
Usually web-designers design pages and coders code applications. However with JavaScript a designer has the possibility to create a client side application with very less efforts. He can easily create some kind of dynamic pages – i.e.: you can easily show a prompt box and asks the user to enter his name whenever the page loads for the first time. He can then use the entered value to create a welcome string. These procedures are called events. Events can be used and called when something occurs – like loading the page for the first time. You could also write another event which is called whenever the page is closed. JavaScript is also mostly used to validate text fields. For example in asp.net you have the possibility to validate your controls with some validator controls. These validator controls are basically nothing more then a JavaScript file. This validation can be easily written with JavaScript to verify if a text field is empty or not.

Java is a technology that allows software designed and written just once for an idealized "virtual machine" to run on a variety of real computers, including Windows PCs, Macintoshes, and Unix computers. On the web, Java is quite popular on web servers, used "under the hood" by many of the largest interactive websites. Here it serves the same role that PHP, ASP or Perl might, although traditionally Java has been used for larger-scale projects.
Java can also be used to create small programs, known as "applets," to be embedded in web pages. For instance, a web page using Java could contain an interactive weather map, a live display of subway trains, or a video game, without the need for the web server to do all of the work. Unlike normal software such as .EXE files, these "applets" can not access or delete your personal files unless they ask for and are given express permission to do so. In the real world, users hardly ever give permission for this, so applets generally don't ask.
As of this writing, Java is usually (though not always) included as standard equipment on Windows PCs. If you choose to use Java applets on your site, you can invite your users to download the Java plug-in from Sun's website (http://www.java.com/en/index.jsp), using the "Get It Now" button on that site.
Reply With Quote
The Following User Says Thank You to pakfame For This Useful Post:
sibgakhan (Sunday, February 24, 2008)