Thursday, May 5, 2011

1. Introduction to Java


Who made it?
Java was developed by James Gosling for Sun Microsystems(now Oracle).


A BIG problem...
Before getting down to the dirty work, let us understand how 'programming' works-
Step 1: Write a program in a certain 'language'.
Step 2: 'COMPILE' it. During compilation, your program is converted into machine code(Zeros and Ones), as that is the only language that your computer understands.
Step 3: The compilation produces an executable file, for example, an 'exe' file, that you can run.

There is an exception to the second step. Some languages(called 'SCRIPTING' languages) like python, javascript, etc. do not need to be compiled. They can be run directly by the system. The problem with scripting languages is that your code is not safe, and the programs run slower.

Now, just like human cultures, different operating-systems have different languages as well. The machine language for a Mac is not the same as that for a Windows PC. So when you compile a program on a computer, that program can be understood and run by computers with the same hardware-software configuration(called 'PLATFORM') as yours. As a result, Mac-compiled software will run ONLY on another Mac. Same goes for Windows. This is the BIG problem we're talking about.


The (Final) Solution
No, I'm not racist. The heading is a reference to the song by Pere Ubu.
The objective of Java was to solve the problem we just talked about, and to develop a truly' PLATFORM-INDEPENDENT' language... and it did. But how?? Let's see-
Java is divided into two parts:
1. The Java 'language', and (drumrolls, please!)
2. The Java 'PLATFORM'.
Yes, you read that right. Java is, in itself, a seperate platform!

This platform is officially called the 'Java Runtime Environment'(JRE), the main component of which is the 'Java Virtual Machine'(JVM). As such, a computer MUST have a JRE installed in order to run software written in Java, which is not a big deal, as it is mostly open-source, and can be downloaded from the net free of cost. Most computers come pre-installed with Java, anyhow, so that is not a problem.

So, the thing is, when you compile a Java program, it gets converted NOT to the machine language of your platform, but to the 'machine' language of the Java Platform(the JVM). This is called Java Bytecode. Now, this software can run on ANY machine in the world that has Java installed, thus overcoming the handicap COMPLETELY!


Problems and Critisizms
Java has, since it's inception, been criticized for it's slow performance... and to be true, it always has been a little slower than other languages(like C/C++). But that is something that is changing RAPIDLY.


White Light
I.T. companies have constantly been trying to come up with better and faster versions of JVMs. Java 6 has a new class-loading feature that is MUCH faster than the previous versions.
Heard of the game called Quake 2? Obviously, you have! Right? Kill yourself if you haven't. Okay. if you're still alive, here are some fun facts:
=>The original engine for quake 2 had been written in C/C++. In 2006, a group of programming enthusiasts rewrote the game engine using Java.... and guess what? It actually gives BETTER GRAPHICS AND PERFORMANCE than the original!! Woot! The engine is called Jake 2. Here are some screenshots.
=>Quake 2 is an old game, and hence, the sad graphics. Now let's see what it can today, in the time of advanced pixel shaders and ragdoll physics. JMonkeyEngine is a game-engine under development. It is still in it's alpha phase, and is completely Free and Open Source!! Heck, it is PLATFORM-INDEPENDENT!!! Check the video out!
Java is now being considered as a serious language for desktop programming, although it has always been used for other stuff:
Blu-ray discs, and many Set-top-box systems use Java technology. Heard of Android? Even Android is written in Java. In fact, most of the handheld devices like cell-phones use Java.


Conclusion
That's all for today, folks! In the next post, we'll start-off with the actual sh*t. The addictive junk that geeks like you and me call.....CODING.
See ya.

PREVIOUS|NEXT

2 comments:

  1. nice and informative post! but android is actually just heavily modified linux. so '3 million lines of XML, 2.8 million lines of C, 2.1 million lines of Java, and 1.75 million lines of C++'. however if you wanna make a program for android and have it listed on the android market, it has to be written in java.
    your effort seems promising. in fact i'll be following it so that i can learn something useful: java programming. do tell quickly what things to download. ion net won't go any faster than 50kbps:(

    ReplyDelete
  2. @perryizgr8 thanks for the response!

    ...and just read the second chapter. you'll get your answers there.

    ReplyDelete