Java Programming Language

Written by Larry Gray on . Posted in Java

Java Programming Language Explained

Computer Programming

What do you think of when you think of programming languages? Software right? Software is a set of instructions which the computer executes in, hopefully, logical sequences. Programming languages define and provide those instructions.
public class HelloWorld{
    public static void main(String args[]){
        System.out.println("Hello World");
    }
}

Cryptic

The base software on any machine is the Machine's own Language known as ML(Machine Language) or Assembly. I won't go into details here except to say that this is very cryptic to say the least. Each machine has its unique instruction set. Registers and Ram store data. There are very basic binary math functions. Memory functions. Different types of memory addressing etc. On windows DOS DEBUG command can give you some examples of ML by displaying it from ram directly.
     6897:026E 8D167802      LEA     DX,[0278]
     6897:0272 B409          MOV     AH,09
     6897:0274 CD21          INT     21
     6897:0276 EB05          JMP     027D
     6897:0278 1B5B32        SBB     BX,[BP+DI+32]
     6897:027B 4A            DEC     DX
     6897:027C 24B4          AND     AL,B4
     6897:027E 30CD          XOR     CH,CL
     6897:0280 213C          AND     [SI],DI
     6897:0282 027D0A        ADD     BH,[DI+0A]
     6897:0285 8D167C01      LEA     DX,[017C]
     6897:0289 B409          MOV     AH,09
     6897:028B CD21          INT     21
     6897:028D CD20          INT     20

Somewhat Human Readable Generic Code

In the 1960's programmers saw a need to come up with a more generic language which would make programs more portable across machines. They came up with a language called C. Yes. C was meant to be a cross hardware portable language so that you only had to make minor adjustments to the source code to get the same program to run on one machine or another. C is cryptic but not nearly as cryptic as machine language. C is one of what is called a Von Neumann language. I won't go into details but other Von Neumann languages might be BASIC, Pascal etc. Statements, branching, loops, subroutines and functions is what I think of when I think of a Von Neumann language . I'm assuming the reader knows enough about programming that I don't have to explain statements, branching, loops etc.
/* Hello World program */
#include<stdio.h>
main()
{
    printf("Hello World");
}

Software Execution Options

Software execution may appear to the user in different ways on different levels. Software does not have to interface with a user at all for example. It can run silently in the "background". However the user may experience some good indirect benefit hopefully (other than malware, spyware and viruses). This type is called Daemon software. Can also be called TSR, Drivers or background processes.

Text Based Consoles and Printers

The first software was most noticeable on what was called a text console. Text meaning alphabet and symbols were displayed in one color with a different background color. White, amber and green were the first text colors with black background. Text was arranged in perfectly spaced rows and columns. And then we had the printer whereby text was spaced in a very similar fashion with black text on white paper or green/white paper. The graphics screen was another mode where the screen was divided into rows and columns of pixels. Later we added color to the scene, first 4 colors, then 16, then 256, then 1000's and then Millions and so on. So to get to the point software first interfaced with humans as "output". And a program basically performed this sequence. "Input", "Process", "Output". We called these programs "console applications" or "terminal applications"

Graphical User Interface

As computers have developed or advanced over the years the types of manifestations of computer software have increased significantly. I doubt I can possibly cover all of them. I will talk about some of the types related to Java programming. From the Console we added a pointing device(mouse) and the Graphical user interface, along with multitasking. We call this kind of software GUI Applications or Desk Top Applications.

Web Applications

A very exciting new type of software has been the Web Application. Web sites, and web development. This is software which runs on the web server. The user experiences this software in the form of web pages and files sent to the web browser. And some software runs on the web page or in the web browser as well.

Object Oriented Programming vs (prior Functional or Procedural using structures called Records)

I have been progressing towards telling you about the C++ programming language. This is another Von Neumann language and it is an extension of the C language. This language most notably adds what is called OOP(Object oriented programming) to the C language. OOP most notably combines data and subroutines into a package called an object. It can be thought of as a way to group and reference data and logic which pertain to one another. Its literally a program within a program or software within software.

Where Java steps in "Write once Run anywhere"

This finally brings us to the Java Programming language which was meant like C to be portable, unlike C it is meant to be 100% cross platform(machine) portable. This means you do not have to change the source code at all or recompile and Java will run on any machine. Though there is a catch. The machine must have what is called a Virtual Machine and in this case a Java Virtual Machine. A Java virtual machine executes a generic machine code called "bytecode". By execute I mean it "interprets bytecode". So Java is first compiled to bytecode. Java like C++ is also an OOP language. In Java however everything is an Object and all things begin with Objects. All things are built upon Objects.

Compiled vs Interpreted execution

For those of you who don't know what compiled means I will explain a bit. The first languages other than assembly were not compiled. They were what is called "interpreted". Meaning the program steps are read as text commands each and every time the program was run. This text is known as source code or scripts. Software can be made to run more efficiently if it is converted from this source or scripts into straight binary machine code. I've heard this referred to as "running the application on the metal". I can't possibly go into why this is more efficient except to say that it removes a lot of decision making and branching from the execution process. Is this excess execution speed necessary? Maybe and maybe not. Faster is always better right? Maybe its always better but its not always necessary.

Hybrid Pros Cons

Java therefore can be thought of as being a hybrid between interpreted and compiled languages. By the way compilers have been written for many interpreted languages. And in fact there is an attempt to write a Java Interpreter. Java can also be completely compiled to the native platform but this defeats the purpose of Java and system independence. I guess the advantage of the interpreted langauge is that you don't have this compilation step. An advantage of fully compiled to the metal software is that it doesn't need the interpreter to be installed to run. So what we see here is pros and cons for each type of software execution. Java must be compiled and it must have an interpreter. So we loose both of those typical advantages. However we gain the advantage of 100% Cross Platform portability. Yes I can write a Java program and without change it will run on a Macintosh, a IBM PC or clone. It will run on different operating systems without change as well, OS X, Linux, Unix, Windows etc. It will run without change on any machine and operating system which has had a Java Virtual Machine created specifically for that machine and operating system. It should run on all cell phones for example but thats another story. A special version of Java and VM runs on the Android phones and tablets. Java can still run machine code via Java Native Interface and it can run scripts now via Nashorn. Like I say, Pros and Cons.

Platform or Foundation

Since Java is a generic Machine it is what is known as a "Platform" for software. An operating system for example is a Platform. Hardware set is a platform. Another word for this I would think would be foundation. One good note is that Java is not the only language which is being developed for the Java Virtual Machine. Scala is another and there are more. This means that the JVM will be getting plenty of support as time goes by. Hopefully changes to the JVM will always be favorable for Java.

Popularity, Long live Java!

Computer languages can be thought of as being more or less popular. I've heard some languages being said to be "dead" or "alive". Long live Java! Things are changing fast in computer programming. Java has its competition. J++ was one such and is in fact dead because of a Sun and Microsoft lawsuit. J++ became what is now C# (C-Sharp). J++ and C# is very similar to Java but not identical in many ways. The saga continues. Java has been purchased from Oracle, the database folks. However Java's continued development and growth is managed by the Java community (those that use and love it). So there is plenty of hope for Java. Also many books and a huge source(code) base have been developed. Java will continue to be used for many years to come. Will it loose popularity? Yes at times and it will regain popularity as well. Sometime after 2000 and the coming of virtual machines such as VMware, a new hope and era for Java was the VPS(Virtual Private Server) which promises to make Java web services more affordable. VPS means you can install any operating system on a virtual server and any web services you like. Like Quest Host ,you may therefore have Debian linux installed andTomcat 5.5 web server. You are therefore paying a competitive price for the virtual server not for expensive "Java" web services.

Use the right tool for the right Job

What types of software is Java good for? Ah you want my opinion? Sure, I'll list a few types and next to it show poor, fair, good, great and excellent.
  • TSR hardware drivers(impossible)
  • daemons(great)
  • console applications(poor) with a 3rd party api JCurses (fair)
  • GUI applications(good to great)
  • Games general(poor to great) depends on the type of game
  • Games 3D(poor) except for using what is called OpenGL or JOGL addon's in which case via the use of these 3rd party graphics api's or libraries great 3d graphics can be achieved
  • Servers(excellent)
  • Client software(great to excellent)
  • Web Applications(good to great) depending on who you ask. Java works as well as it ever did but may not be like the newest fads. We are talking here about Java Server Pages, Serlvets, Java Server Faces.
  • Applets[mini applications](poor as of lately) Webstart applications are favored now over applets.
  • Web Start[mini applications](great)
  • Networking apps(excellent)
  • Database (good to great)
Next I will list some uses for Java the same way.
  • Educational software.(sure)
  • Scientific software.(for many types)
  • Accounting software.(why not?)
  • Introductory Programming (excellent, the best)

Conclusion

So in conclusion I say that Java is a great programming language to use and learn. And Java software is very valuable software. Loosing some popularity? Yes. But dead? No by no means dead. Some say, "Use the right tool for the right job." I say, "Use the tool you enjoy using. Use the tool that you know how to use well." Much in the computer world and programming is fad. Java has been a fad. But more than a fad as well. Much in the computer world is experimental. The more things change the more they remain the same right? Reinvention of the wheel is all around us. The basics of programming remain the same. "Statements", "Iteration", "Decisions", "Subroutine". "Input","Process","Output". But things are added over time such as GUI, Networking, Mobile, Virtual Machine. Hardware is improved or added on to for backward compatibility sake. What you learn when using and learning Java will be a foundation for more to come in the future. Even a foundation for learning other programming languages and technologies. I hope I have convinced you to at least learn a little more about Java, to experiment with Java and to test and try it out. Maybe even from a Java application end users viewpoint aye?

Interesting Discussion and Links

Newest latest language features include.
  • Generics, Enumerations, Variable Argument list for methods.
  • Invoke compiler from Java code
  • Run javascript interpreter from Java code using something called Nashhorn. It also may be possible to use other scripting languages but I'm not totally sure right now.
  • Lambda Expresssions(closures) or simplified A REFERENCE OR LINK TO A FUNCTION (called a Method in Java) Previously in Java all methods could only be referenced using a reference to an object that contained the method. In some circles this was a step backward not forward unless used properly. Though just about everyone outside the Java world might call it a step forward.
  • Java Web Sockets (Ajax the proper way using Java)
Jet, an example of platform dependent Java Bean Shell, an example of fully interpreted Java Scala, an example of another JVM Language

Tags: ,

Trackback from your site.

Leave a comment