[][src]Constant blogs::_2018_::july::_30_

pub const _30_: ()

Java should be banned from universities

To sum up, Java also should be banned from the technology industry.

Contracts

When 2 people work together on a common subject, they agree upon a contract. Break this contract and everything fails.

In its nature, Java provides tools and encourages developers to break contracts.

For example, if you're a teacher or a university professor who teaches Java. Could you tell what is wrong with this code?

public class Program {

    public static void main(String... args) {
        System.out.println("Hello World");
    }

}

Of course, nothing is wrong. Now let's use some external code:

import big.enterprise.Api;

public class Program {

    public static void main(String... args) {
        System.out.println(Api.hello_world());
    }

}

We agree to this contract here:

Now, don't cheat by scrolling down to the answer below. But, look at above code and think. In 30 seconds, could you tell what is wrong?

Ready. Go!

The answer: it forgot to catch RuntimeException.

java.lang.RuntimeException

  1. First of all, to use anything, you have to import.

    For example:

    import java.util.Locale;
    

    But, except for things stayed inside java.lang package: you don't have to explicitly import them.

  2. Second, RuntimeException is destructive

    That exception is unrecoverable. When thrown, it crashes the running process. Throwing a RuntimeException (or its subclasses) is not required to be declared in method signature. That simply breaks any contract between two Java partners.

  3. Third: java.lang.RuntimeException

    Means:

    • Out of the box, Java provides developers a most convenient way to use it.
    • Java encourages developers to use it.

    For instance, here is a list of its subclasses: https://docs.oracle.com/javase/10/docs/api/java/lang/RuntimeException.html

    There are over 80+ built-in runtime exceptions. Beside, there are n+ runtime exceptions developed by third parties; where n is an unsigned integer value.

Java 2

There won't be Java 2. They're afraid of breaking changes.

Ironic. Changes are much less dangerous than the language design.

To sum up

Java, in its nature, breaks its own contracts inside, by:

Hence, I declare:

I predict the language will fade out and decay; with the condition that developers see how dangerous its design is.