Saturday, December 18, 2010

THE JAVA LANGUAGE


                                    History of Java

Before learning about Java, first let us know the history of Java.  Before 1990, Sun Microsystems use to maintain two departments, the first department was known as Sunsoft which was used to deal only with the development of new software and the other department use to deal with development of hardware components like processors. The processor developed by Sun is known as Spark processor. This processor is based on an architechture known as RISC architechture.
                    In the year 1990, Sun Microsystems received a software project by name Green Project (some books say as Stealth project) from some client. The purpose of this project was to develop software for consumer electronic devices like televisions, refrigerators, toasters, microwave ovens, washing machines etc.  As we already know that developing software consists of many stages or phases i.e. Analysis, Design, Coding, Testing and Maintenance. The job of coding the software was given to James Gosling. At that time, the languages used to develop softwares was C and C++. But James Gosling knew that C, C++ comes under system dependent languages category i.e. he has to develop different softwares for different electronic devices. In other words, for refrigerators there was be separate software, for washing machine there was be separate software, for ovens there was be separate software i.e. for different electronic devices there must exists different softwares. Then he thought that there is a need to develop a new language that can solve the problem of system dependency.
                 So, he started to develop a new language, which was initially known as Oak (It is the name of the tallest tree in America. It is said that there was an Oak tree, in the cottage where James started developing a new language). Later the name changed to Java. This language could successfully solve the problem of system dependency. Here we can conclude that Java was introduced to develop software that can run on any electronic device. It is said that Java was introduced in the year 1991 by James Gosling, but was announced to public in the year 1995 in a conference. In the year 1996, the first version of Java i.e. JDK 1.0 was released.
                    During 1990s, Internet and World Wide Web became popular because they can be accessible from any computer. Then they started thinking what will be the effect of Java on Internet. By keeping this in mind, they were successful in making impact of Java on Internet. The various java programs that can work on Internet were applets and servlets.

Creation of Java:

Before understanding the importance of Java to Internet, let us understand the disadvantages of previous languages like C and C++ with respect to Internet.
                                                          If user wants to write a program in C language, then the extension of the file will be .c that is if the name of the program is add, then the name of the file is add.c . This means add.c is a program, that contains source code of add program written in C Language. When we compile this program, then a file by name add.obj is created. This file add.obj contains an intermediary code known as object code. When we execute this object code, then we will get a file known as add.exe that contains executable code and this code contains machine code which is created based on the Instruction Set of the CPU and the type of operating system used in the computer on which the program was compiled. An Instruction Set is defined as a group of instructions that are understandable by the CPU that is, different processors will have different Instruction Sets. So, the instructions recognized by the Pentium processor will not be understandable by the Celeron processor and vice versa. Similarly, the instructions recognized by the Celeron processor will not be understandable by the Spark processor.
                In other words, it means that the executable code is totally dependent on the nature of hardware and the operating system present in the computer. It means that the executable file(here add.exe) is platform dependent. If user takes this executable file, and runs on a system that has same hardware and different operating system, then it does not get executed. Moreover this file does not get executed on a system that has different hardware and different operating system or different hardware and same operating system. To be more specific, this file will be executed only on that system that is having same hardware and same operating system as the computer on which it was compiled.
                                To be more general, if user develops a program and compiles a program on X processor and Y operating system, then the program can successfully gets executed on a computer with X processor and Y operating system only. In other words, if the processor is changed and the operating system is changed then the above code never gets executed. These programs are known as system dependent programs or platform dependent programs. Hence C and C++ are known as system dependent languages or platform dependent languages.

                           Now let’s understand the impact of C and C++ programming languages on Internet. An Internet is defined as collection of many computers spread all around the globe. It means that the computers that spread all around the globe have different operating system and different processors. So, if we develop a software on C or C++, and if we give the .exe file of the software, then this file cannot run on other system that have different processor and different operating system, due to the code being system dependent. So, it is not advisable to develop software in C and C++ for Internet. It means that we need a language, whose code is platform independent or system independent and that can run on any system present on the Internet. Then they introduced a language known as Java that could overcome the disadvantages of previous languages like C and C++.
                                                   If user wants to write a program in  Java language, then the extension of the file will be .java that is if the name of the program is add, then the name of the file is add.java . This means add.java is a program, that contains source code of add program written in Java Language. If user compiles this program, then a file by name add.class gets generated. This file contains a code known as byte code. This is known as byte code, because in this code the size of each instruction is 1 byte i.e. 8 bits. It is important to know that the byte code is totally different from machine code. A machine code is a code that can be understandable by the CPU. In other words, the byte code that is generated by the Java Compiler cannot be understandable to the microprocessor. When it is not understandable by the microprocessor then where is the question of being executed. Then they introduced a program known as JVM.
JVM stands for Java Virtual Machine. JVM is defined as a system program, whose job is to convert the byte code into machine code. In other words, the job of JVM is to convert byte code into understandable machine code so that it can be easily understandable by the CPU. This machine code is taken by the CPU that will execute it and displays the result. This paragraph explains us that how a java program gets compiled and how it gets executed.
                               Now, lets us understand the importance of Java on Internet. JVM is a system program that is different for different operating system. In other words, the JVM working for Windows operating system is different from the JVM working for Linux operating system. As we know that whenever user compiles a java program, it generates a code known as byte code. This code is system independent or platform independent. A byte code that is generated on a computer that is having windows operating system and Pentium processor can run on a computer that is having Sun Solaris operating system and Spark processor. In other words, a byte code generated on one computer having X operating system and Y hardware can run on a computer that is having Y operating system and X hardware. To be more specific, a byte code generated on a computer that is having any operating system and any processor can run on a computer that is having any operating system and any hardware. This concept made Java to be known as Platform Independent Language.
                                     If we consider an Internet, that contains millions of computers having different operating system and different processors and if we want to run the java byte code, then user can expect same result on all the systems. If user wants to develop a software using Java programming language, and wants to send this software to some other person in some other part of world, then the user can just send .class file containing of byte code and that person can download this file( .class file) from internet and can execute this file without any problem. Hence we can conclude that java is suitable for developing software on the internet.

Importance of Java to Internet:
Due to rise of Internet and World Wide Web, Java introduced a new type of programs known as Applets and Servlets. Moreover Java also addressed some strong issues associated with Internet like Security and Portability.


Applets:

An Applet is defined as a java program that is designed to be transmitted over the Internet and can execute on a web browser. The job of this program is to display the data that is provided by the Server.


Servlets:

Servlets are defined as a java program that gets executed on the server side of the Web Connection.

 
Byte Code:

A byte code is defined as a code that gets generated when a java program gets compiled. In other words, whenever user wants to compile a program with the help of a system program known as Java Compiler, then its job is to convert the java source code into byte code. This code is named as byte code, because the size of each instruction is 1 byte that is equal to 8 bits. Practically, this byte code is present in a file known as .class file. This code that is being generated neither depends on the operating system nor on the processor that is present in the computer, on which the program was compiled. This byte code can be executed on any computer that is having different operating system and different processor. JVM software for Windows operating system is different from the JVM software for Linux operating system that is different from the JVM software for Sun Solaris operating system. This new concept of byte code made Java famous to be known as a Platform Independent Language. The below diagram shows how a byte code gets generated.



An overview of the software development process.

Since the Java VM is available on many different operating systems, the same .class files are capable of running on Microsoft Windows, the Solaris operating System, Linux, or Mac OS.

Through the Java VM, the same application is capable of running on multiple platforms.

Java
Java is a programming language originally developed by Sun
Microsystems and the first public implementation of Java is Java 1.0 in 1995.

Java's Editions (In mid-1999, Sun defined three editions for Java)
          The Standard Edition: The Java 2 Standard Edition (J2SE) is the basic version for creating regular applications and applets.
The Enterprise Edition: The Java 2 Enterprise Edition (J2EE) is the Java version that comes bundled with support for EJB, JMS, JNDI, servlets, JSP, and other enterprise services.
The Micro Edition: The Java 2 Micro Edition (J2ME) is the Java version for developing programs on small platforms such as cell phones, PDAs, and printers.

JDK (SDK):
          A Java Developer's Kit (JDK) or Software Developer's Kit (SDK) includes a compiler for Java source code (.java files) as well as a runtime engine for Java classes (.class files).

JRE:
          This JRE (Java Runtime Environment) is a software bundle from sun Microsystems consists of the JVM and the programming interface (API).
          A Java Runtime Environment (JRE) includes only the runtime engine. If you plan on writing code, then you must have developers kit called “JDK" or "SDK", (depending on the Java version). If you only need to run java classes that someone else created, the runtime environment (which is much smaller) is enough.

API (Application Programming Interface)
          The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related classes and interfaces; these libraries are known as packages.
The API provides the core functionality of the Java programming language. It offers a wide array of useful classes ready for use in your own applications.




The API and Java Virtual Machine insulate the program from the underlying hardware.

Note: every version from 1.2 and beyond is known as "Java 2", and contains Java's advanced graphics libraries (Swing and Java 2D).

 
Java Versions
Java has had several releases in its early years and the language has quickly grown in size:





There were five primary goals in the creation of the Java language:
Þ    It should use the object-oriented programming methodology.
    Þ    It should allow the same program to be executed on multiple operating systems.
Þ    It should contain built-in support for using computer networks.


  Þ    It should be designed to execute code from remote sources securely.
 Þ    It should be easy to use by selecting what were considered the good parts of other object-oriented languages.



Java Buzzwords or Features of Java:

When James Gosling developed Java, he kept a conference in his company Sunsoft, now known as Sun Microsystems and introduced a new language Java by saying the features of Java to the employees of the company and then later to the world. The various features of Java are:

  1.        Simple
  2.        Object Oriented
  3.        Secure
  4.        Portable
  5.        Interpreted
  6.        Architechture Neutral
  7.        Multithreaded
  8.        Distributed
  9.        Dynamic
  10. High Performance
 
The above features that made Java as a popular language are explained below:
               
Java is Simple

For a learner or a programmer the most difficult concepts in C and C++ are pointers, structures, unions. Pointers are useful in some applications, but if they are not used properly they result in unpredictable and undetectable results. The most confusing concepts in C++ is operator overloading. Hence Java has removed all complex issues making it more simple. Moreover Java was designed to be easy for the professional programmers so that they can learn and can use it efficiently. If a person is very good at C++, then learning Java becomes very easy i.e. at that time when Java was introduced, many programmers were working with C++.

Java is Object Oriented

Much of the syntax of Java is based on the earlier object oriented language like C++. Moreover the language Java is founded over the Object Oriented Paradigm. It is said that Java is more Object Oriented than C++, because variables and the methods never exists outside the boundary of the class.

Java is Interpreted

Java is said to be Interpreted i.e. java programs are compiled into a code known as byte code for an imaginary machine known as virtual machine. Any machine that supports java programs provides a simulator known as interpreter that could read byte code and convert it into machine code and then execute them to give output. This interpreter is known as Java Virtual Machine. So the job of JVM is to convert byte code to machine code and then to execute this machine code to give output. So, by doing this the performance of Java gets degraded i.e. it leads to slower execution.
                         Recent innovations in the java world, lead to increase in the performance of interpreters by introducing a system program with in JVM. This system program is known as JIT Compiler i.e. Just-In-Time Compiler. The job of JIT Compiler is to convert the byte code into machine code and relieving the JVM from doing this job.

Java is Robust
Java is said to be Robust, because java programs never crash if there are any software and hardware errors. The reason is that Java follows exception handling. A java program has some statements and if these statements lead to some error like division by zero, file operation that can attempt to read data from non-existent source, then it will generate an exception instead of performing an erroneous operation.
                             Another reason why Java is said to be robust, is automatic memory management. In case of C and C++, it is the responsibility of the programmer to write the functions in their programs that are used to release the memory that was used by the variables and object of the program. But in case of Java, the programmer need not feel burden of releasing the memory but it is the responsibility of a special program known as Garbage Collector is to detect and release the memory that is no longer used by the currently running program.
                      The above two features Exceptional Handling and use of Garbage Collector simplifies the programmer’s task and makes programs more reliable.




Java is Architechture Neutral

As we know, that the byte code generated by the Java Compiler, is neither dependent on the computer architechture of the system (where it was generated) nor the operating system of the computer.  Computer Architechture means the various components of the computer are connected to each other. In some books, architechture is nothing but the processor and the other components of the computer connected to each other to work with each other to perform a simple task. The processors can be Intel, AMD or Spark.
                                                       With this feature, there is a famous saying on Java: “write once, run anywhere, any time, forever”.

Java is Multithreaded

Java was the first programming language that introduced the concept of multithreaded i.e. they can be multiple threads in a single program so that they can perform many things simultaneously. Creating multiple threads, is known as multithreading.
              
Java is Distributed

Java is said to be distributed because of a feature known as RMI (Remote Method Invocation). If this feature is there, then we can access the files of a remote system on our local system, and making user to feel that the user is working on a local system. These features were also provided by previous languages like C and C++, but Java made it more easy.

Java is Portable

If a Java program gives same results on any machine regardless of the type of operating system and the type of computer architechture, then it is said to be portable.

Java is Dynamic

Before Java, people used to write web pages with the help of HTML. But viewing, data with the help of HTML gives an impression of static data getting displayed on a web browser. But with the help of applets, dynamically interacting programs with animations were made, on internet.

Java is High Performance

The problem with previous JVM was slow execution. This made java programs low performance. To increase their performance, a system program by name JIT Compiler was introduced in JVM that increased the performance of Java and that made JIT Compiler and JVM to work together.








No comments:

Post a Comment