Understand Java

Java is general purpose, high level, object oriented language. Here the emphasis is on Object oriented. The main goal of the designer was the ability to run programs written in Java on any device and Operating system.

To achieve this instead of the traditional ways of translating a program (compilation) to a binary OR compiling on the fly and execute (interpretation) Java uses a third method. A Java vendor builds up a Virtual machine (a specialized application) according to rigid API specification i.e. this guarantees that all VMs from different vendors are equivalent and will behave the same. Then the Java compiler compiles the program to byte-code (mini-language that can be executed by the VM), in this way there is no worry that Java code can run on any platform by using intermediary layer.

Do you use Java or something else ?
– Yes !

Learn

Java is not very easy to learn, if you do not already know another programming language.

Let me illustrate this point with the canonical hello world program :

public class HelloWorld {
   public static void main(String []args) {
     System.out.println("Hello World"); // prints Hello World
   }
}

So before you even write this simple program :

  1. You have to know what Class and Object is ?
  2. What is a method ?
  3. What is the difference between public, private and protected access ? How it is impacted by inheritance ?
  4. What is inheritance ?
  5. What is the difference between Object-method and Class-method i.e. static ?
  6. What is void used for ?
  7. What is the purpose of main() method ?
  8. What is an Array ?
  9. Why use such verbose way to just print some text i.e. System.out.println() ?
  10. What is a package ?

Did you get headache yet ?

So this is the main obstacle you have to overcome. Once you do that Java is pretty bland and easy to follow.

One other advice. Of all the languages I learnt, Java is the only one for which I have to use IDE (Integrated Development Environment) so I don’t get lost. The verbosity instead of achieving readability in many cases causes the exactly opposite. We want our methods to be short 1-2 screen pages, so we can keep everything we are currently working on in short term memory.

Java was created by Sun Microsystem which being a big corporation at the time targeted the business community, rather than programmers. What do I mean by that ?

It is verbose, over engineered, fenced i.e. it is “cog-in-the-machine” language with the goal of making programmers replaceable. You can see why this could be preferable to a business. I’m not saying this in derogatory terms it is just different approach.

Java is the XML of the programming languages.

If Java is so “awful” why bother learning it at all ?

Usage

Java is used alot in big organizations and government because it is ideal bureaucratic language.
So it is a workhorse in many big applications that have to be supported and upgraded.

In addition it is heavily used to build phone apps and in Automation testing.
Apart from that useful frameworks and tools are built in Java, like :

  • Spring
  • Maven
  • Tomcat
  • Hibernate
  • Neo4j

Is it worth it ?

If you are stodgy, orderly, meticulous, verbose person and you don’t mind the drudgery to learn alot of theory before your feet get wet, you are right at home. But if you are artsy, impatient and clever one then pick another language to start with.

Of course there is one major exception ! O No ! O Yeah !

if you want to get paid well, then you have to grind your teeth and stick with it.

But it is not all bad. Java will teach you discipline and by necessity you have to learn some computer science which is good if you will pursue carrier in programming.

If you are here for the long run then learn an easy language first, then later try Java again.

Pros and Cons

Love

Multi method dispatch

Templates

Hate

Return only single value

Returning more than one scalar value from a method is a the worst. You have to explicitly create ArrayList and fill it. No other language is so obtuse.

; requirement

Java requires every statement to end with ; even when it is clutter. JavaScript can handle it pretty well w/o this requirement

Multiple very similar types

Miss

Where to start ?

One place is here : [Learn programming] and then [Learn Java]

What to do if I’m stuck ?

  • Do a search, somebody had probably had your problem already. I’m amazed of how many people don’t do a simple search.
  • Do something else for 30 minutes.
  • print/debug values at critical points of your program and check to see if you get back the correct values.
  • say() it.
  • check the other languages “What to do if I’m stuck ?” sections.

Questions you may have ?

Check the Java FAQ page