CodeMusings

Kick back and get started at your own pace.

Skip to Content

Overview

The Java programming language is a class-based object-oriented language. It was developed by James Gosling, who was working at Sun Microsystems (acquired by Oracle in 2010).

Hello, world!

Java enforces modularization of classes. The public class name must match the .java file in which it's contained.

Hello.java

  1. class Hello() {
  2. public static void main(String[] args)
  3. {
  4. System.out.println("Hello, world!\n");
  5. }
  6. }

History

Photo of James Gosling

James Gosling, known as the father of the Java programming language.


Photo by Peter Campbell © CC BY-SA 3.0.

The Java programming language initially gained notice in 1995 when it was announced to be incorporated in the now-obsolete browser, Netscape Navigator, the "star dust" from which has seeded the creation of many modern browsers, like Firefox. The small team initially intended to design the Java platform to run interactive TV applications, but the technology was still too advanced for the Cable TV industry [1].

At Sun, during 1991, The work of the so-called "Green Team" was led by Patrick Naughton, Mike Sheridan, and James Gosling—their goal was to develop technology to capitalize on the perceived interlinking of entertainment and computing. After isolating themselves for 18 months in a nondescript office, the team emerged with a working demo of an interactive, hand held home entertainment device controller, which had an animated touchscreen interface. This was in 1992 [2]!

Design

It's important to understand that the Java programming language is actually a component of the overall Java platform. The Java platform consists of the language, the class library, and the JVM. The JVM is responsible for compiling the Java source code into bytecodes, which are instructions targeted for the JVM. The JVM is responsible for transparently producing the native code that runs on the computer [3].

Diagram showing how Java source ends up as bytecode, and then native code

The main takeaway from that is obviously that my Photoshop skills are out of this world. Back to reality. The Java platform is the reason why Java's slogan is, "Write once, run anywhere."

Type System

Java's type system is stronger than the C and C++ type systems. The fact that it runs programs in a managed environment also means that tracking down runtime errors is much easier, since the platform has more control over how the program runs. The Java development team also decided to veer from C++ design by not implementing operator overloading, which allows programmers to change how the language's operators behave, depending upon the operands associated with the operators. Java also supports generics (it was added to the language rather late in its development cycle), which allows programmers to design classes, methods, and interfaces that accept arbitrary types (including other objects). It is analogous to the C++ template system, though, as far as implementation goes, the two are quite different.

Good for Beginners?

The Java programming language comes with a rich class library, and most of it has detailed documentation on the Web. If your goal is to get started as soon as possible on interesting or flashy projects, Java can be a good starting point to get your feet wet.

The main drawback that I see with Java is how much of the machine it abstracts. If your preferred aim is to better learn the core concepts in computer science, and how the machine works at the lowest level, Java's probably not the direction to go. If you feel you fall more into this latter category, I personally feel starting with a scripting language, such as Python would be good for picking up the higher level, abstract concepts. From there, you might try tinkering at creating extensions in C to better understand how the interpreter itself works.

It's worth mentioning again, however, there's no set path in learning all this stuff. If you feel you're going down a road that either doesn't interest you or seems too difficult, there's nothing wrong with trying other approaches, taking breaks, etc.

References

  1. ^ - Sun Microsystems. Accessed from a Web archive tool. Archived by Wayback Machine: 20 Apr 2005.
  2. ^ - Sun Microsystems.
  3. ^ - Oracle Java Tutorials. Accessed 1 Oct 2014.