Is Java easy?

Java isn’t easy. It’s often more complex than needed. But being easy for beginners shouldn’t be a design goal with high priority.

Should a programming language be easy?

I don’t know why so many educational establishments use Java to teach programming. They often start with Java in the first semester. Even the Oracle tutorials expect the reader to already know some basics.  Java was designed for programmers who already know C/C++ as seen in this example.

The main method is similar to the main function in C and C++; it’s the entry point for your application and will subsequently invoke all the other methods required by your program. [Lesson: A Closer Look at the “Hello World!” Application]

It has a hello world, so you can check if you can compile and run that. But then it goes directly to OOP. There’s nothing about fundamental basics, such as methods and variables.

So why not learn C and C++ first? You would learn structured programming and how the  machine works.

It is a common misconception that Java is somehow “easy” to use and to learn. But that’s just not the case. You need to understand all kids of details about OOP and you must be familiar with dozens of design patterns and essential Java classes.

Java was game-changing in the 90ies. Bit still has weird and confusing features such as null references, primitives, type erasure, finalize, ironically depends on a platform (the JVM) instead of being truly platform independent, and concurrency in Java is still hard to grasp. Once you know about these quirks Java is still a good language. It’s very popular and you can use it on many platforms, if a JVM is available.

What still confuses me about Java is that you need to write more code for more basic things. You need to memorise a bunch of rules just to make an immutable type. Modern languages make you write more code for more complex structures (such as mutable types). And they allow you to use primitives just like objects. All this might change with Project Valhalla, but so far we are stuck with a language that was designed for making “Java beans”, which are mutable.

// Immutable Type in Java: Lots of boiler plate code
import java.math.BigDecimal;
public final class ImmutableType {
  private final BigDecimal value;
  public ImmutableType(BigDecimal value) {
    // defensive copy required because BigDecimal isn't final and therefore not immutable
    this.value = new BigDecimal(value.unscaledValue(), value.scale()); 
  public BigDecimal getValue() {
    return this.value;
  @Override protected Object clone() {
	return this;
// Scala case classes are immutable
case class ImmutableType(val value: BigDecimal)
// Note: scala.math.BigDecimal is immutable

Scala is great, but you have to lean lots of keywords and operators, such as <%. From this perspective Brainfuck is the easiest language. You only need
eight language commands and nothing else. But writing code in it makes your brain hurt a lot more than Java.

Another important question is this:

Should a programming language be easy?

I would argue that it should not be designed to be easy to learn and use by beginners. It should be efficient for professionals.

PHP was very successful and is still used for many websites. Many say it is easy to learn.
But is that really true? Getting fast results doesn’t really mean it’s easy to learn. A lot you have to learn about a language is about it’s design problems that force you to learn strategies to prevent problems. You need to learn a lot just to make PHP scripts secure. Beginners are not aware of this and mistakenly think it’s easy to learn. The Dunning-Kruger effect is strong when it comes to programming. Beginners think they are writing great code because they are not even aware of the flaws in their code and the language they are using. 
Facebook had to develop their own language based on PHP and a virtual machine, so they could port the code. No type checks and unclean design only led to problems, not easier development. They now use Hack/HHVM.

Leave a Reply

Your e-mail address will not be published. Required fields are marked *